Migrate Docker from fig to docker-compose

Also updated the docker files to support the poppy-server and
poppy-worker distributed architecture.

Change-Id: Ib7f2d07631995329f9273aa4b0c4f661ef66fbd6
This commit is contained in:
amitgandhinz 2015-06-26 17:46:44 -04:00
parent 3d19474cf0
commit fb0ac10de1
32 changed files with 282 additions and 795 deletions

3
.gitignore vendored
View File

@ -44,7 +44,8 @@ write_file
.settings/*
/Dockerfile
/docker/fig/fig_local.yml
/docker/*/secret.yml
/docker/api/poppy.conf
/.idea
# patch files

View File

@ -1,9 +1,7 @@
Poppy
=======
CDN Provider Management as a Service
Note: This is a work in progress and is not currently recommended for production use.
CDN as a Service
What is Poppy
============
@ -23,17 +21,22 @@ Features
---------
+ Wraps third party CDN provider API's
- Fastly (http://www.fastly.com)
- Amazon CloudFront
- MaxCDN
- Akamai (Production Ready)
- Fastly (In Development)
- Amazon CloudFront (In Development)
- MaxCDN (In Development)
- Your CDN Here...
+ Sends configurations to *n* configured CDN providers
+ Supports multiple backends (CassandraDB recommended)
- CassandraDB
- Your DB provider here
+ Supports multiple dns providers
- Rackspace DNS
- Openstack Designate (Coming Soon)
+ Openstack Compatable
- Uses Keystone for authentication
+ Multiple Origins to pull from (including Rackspace Cloud Files)
- Uses Swift for log delivery
+ Multiple Origins to pull from (Public Servers, Amazon S3 Buckets, ...)
+ Supports Multiple Domains
+ Custom Caching and TTL rules
+ Set Restrictions on who can access cached content
@ -50,8 +53,8 @@ Getting Started
-------------------------------------------
**Note:** These instructions are for running a local instance of CDN and
not all of these steps are required. It is assumed you have `CassandraDB`
installed and running.
not all of these steps are required. It is assumed you have `CassandraDB` and `Zookeeper`
installed and running in a Docker Container.
1. From your home folder create the ``~/.poppy`` folder and clone the repo::
@ -69,14 +72,10 @@ installed and running.
to your local casssandra cluster::
[drivers:storage:cassandra]
cluster = "localhost"
cluster = <docker ip>
keyspace = poppy
migrations_path = /home/poppy/poppy/storage/cassandra/migrations
4. By using cassandra storage plugin, you will need to create the default
keyspace "poppy" on your cassandra host/cluster. So log into cqlsh, do::
cqlsh> CREATE KEYSPACE poppy WITH REPLICATION = { 'class' : 'SimpleStrategy' , 'replication_factor' : 1} ;
5. For logging, find the ``[DEFAULT]`` section in
``~/.poppy/poppy.conf`` and modify as desired::
@ -100,13 +99,10 @@ installed and running.
To install additional dependencies, see `Additional Dependencies`_.
8. Install and start zookeeper driver::
8. Install and start cassandra and zookeeper driver::
http://zookeeper.apache.org/doc/trunk/zookeeperStarted.html
or more easily use a zookeeper docker:
https://registry.hub.docker.com/u/jplock/zookeeper/
$ pip install docker-compose
$ docker-compose -f docker/compose/dependencies.yml up -d
9. Start poppy task flow worker::
@ -150,10 +146,10 @@ Then start a poppy server::
Additional Dependencies
-------------------------------------------------
-----------------------
Ubuntu 14.04
-----------------------------
------------
For Python 2.7::
@ -174,28 +170,12 @@ Install these two packages regardless of the Python version::
$ sudo apt-get install libssl-dev
Installing Cassandra Locally
-----------------------------
Installing Cassandra and Zookeeper Locally
------------------------------------------
Mac OSX
-------
1. Update your Java SDK to the latest version (v7+)::
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
You can check the version currently running with::
$java -version
2. Follow the instructions on the datastax site to install cassandra for Mac OSX::
http://www.datastax.com/2012/01/working-with-apache-cassandra-on-mac-os-x
3. Create a Keyspace with Replication::
CREATE KEYSPACE poppy WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };
We recommend running Cassandra and Zookeeper in a docker container when developing locally.
Follow the instuctions in the /poppy/docker/compose/README.md file for running Poppy locally.
Running tests

View File

@ -10,7 +10,7 @@ RUN apt-get -qq update
RUN apt-get -qq upgrade
# Install Pip, Python, etc
RUN apt-get -qqy install git-core wget curl libpython-dev vim memcached libev4 libev-dev python-dev
RUN apt-get -qqy install git-core wget curl libpython-dev libev4 libev-dev libffi6 libffi-dev libssl-dev python-dev
# setuptools
RUN wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py
@ -32,12 +32,12 @@ RUN sudo pip install -r /home/poppy/requirements/requirements.txt
RUN sudo pip install -e /home/poppy/.
# Set up the configuration files
ADD ./docker/api/poppy.conf /etc/poppy.conf
ADD ./docker/api/logging.conf /etc/logging.conf
ADD ./docker/api/uwsgi.ini /root/uwsgi.ini
ADD poppy.conf /etc/poppy.conf
ADD logging.conf /etc/logging.conf
ADD uwsgi.ini /root/uwsgi.ini
# Deploy startup script
ADD ./docker/api/init.sh /usr/local/bin/poppy_startup
# Deploy the startup script
ADD startup.sh /usr/local/bin/poppy_startup
RUN chmod 755 /usr/local/bin/poppy_startup
# create uwsgi log directory
@ -48,6 +48,10 @@ RUN chmod -R +w /var/log/poppy
RUN mkdir -p /var/run/poppy
RUN chmod -R +w /var/run/poppy
# Start Poppy
EXPOSE 8081
CMD poppy-startup
# Run the startup script
RUN chmod 755 /usr/local/bin/poppy_startup
EXPOSE 8080
# wait for the cassandra container to initialize before starting up
CMD poppy_startup

View File

@ -1,37 +0,0 @@
Before Starting
---------------
The following files should exist in this folder before running Dockerfile
* poppy.conf (desired configuration for poppy api)
* logging.conf (desired logging configuration file)
Building the Poppy Server Docker Image
--------------------------------------
From the docker/api folder::
$ docker build -t poppy .
Running the Poppy Docker Container
--------------------------------------
Name the container 'poppy'::
$ docker run -d -p 81:8081 --name poppy poppy
Testing
--------
Access the running poppy api instance home document::
$ curl <docker_ip>/v1.0/
Next Steps
----------
If running locally with Cassandra, ensure the Cassandra Docker Container is running and linked.

View File

@ -1,25 +0,0 @@
#!/usr/bin/env bash
# Setup Configs
echo "Setting Configs"
CONFIG=/etc/poppy.conf
sed -i -e "s/DNS_USERNAME/$DNS_USERNAME/" $CONFIG
sed -i -e "s/DNS_APIKEY/$DNS_APIKEY/" $CONFIG
sed -i -e "s/DNS_URL/$DNS_URL/" $CONFIG
sed -i -e "s/DNS_EMAIL/$DNS_EMAIL/" $CONFIG
sed -i -e "s/FASTLY_APIKEY/$FASTLY_APIKEY/" $CONFIG
sed -i -e "s/AKAM_POLICY_API_CLIENT_TOKEN/$AKAM_POLICY_API_CLIENT_TOKEN/" $CONFIG
sed -i -e "s/AKAM_POLICY_API_CLIENT_SECRET/$AKAM_POLICY_API_CLIENT_SECRET/" $CONFIG
sed -i -e "s/AKAM_POLICY_API_ACCESS_TOKEN/$AKAM_POLICY_API_ACCESS_TOKEN/" $CONFIG
sed -i -e "s/AKAM_POLICY_API_BASE_URL/$AKAM_POLICY_API_BASE_URL/" $CONFIG
sed -i -e "s/AKAM_CCU_API_CLIENT_TOKEN/$AKAM_CCU_API_CLIENT_TOKEN/" $CONFIG
sed -i -e "s/AKAM_CCU_API_CLIENT_SECRET/$AKAM_CCU_API_CLIENT_SECRET/" $CONFIG
sed -i -e "s/AKAM_CCU_API_ACCESS_TOKEN/$AKAM_CCU_API_ACCESS_TOKEN/" $CONFIG
sed -i -e "s/AKAM_CCU_API_BASE_URL/$AKAM_CCU_API_BASE_URL/" $CONFIG
sed -i -e "s/AKAM_ACCESS_URL_LINK/$AKAM_ACCESS_URL_LINK/" $CONFIG
/usr/local/bin/uwsgi --ini /root/uwsgi.ini

View File

@ -0,0 +1,80 @@
[DEFAULT]
log_file = poppy.log
log_config_append = /etc/logging.conf
debug = True
[drivers]
transport = pecan
manager = default
dns = rackspace
storage = cassandra
providers = akamai
[drivers:storage:cassandra]
cluster = "cassandra"
keyspace = poppy
archive_on_delete = True
[drivers:dns]
retries = 5
[drivers:distributed_task:taskflow]
jobboard_backend_type = zookeeper
persistent_backend_type = zookeeper
jobboard_backend_host = "zookeeper"
jobboard_backend_port = 2181
persistent_backend_host = "zookeeper"
persistent_backend_port = 2181
[drivers:provider:akamai]
policy_api_client_token = "MY_POLICY_API_CLIENT_TOKEN"
policy_api_client_secret = "MY_POLICY_API_CLIENT_SECRET"
policy_api_access_token = "MY_POLICY_API_ACCESS_TOKEN"
policy_api_base_url = "MY_POLICY_API_BASE_URL"
ccu_api_client_token = "MY_CCU_API_CLIENT_TOKEN"
ccu_api_client_secret = "MY_CCU_API_CLIENT_SECRET"
ccu_api_access_token = "MY_CCU_API_ACCESS_TOKEN"
ccu_api_base_url = "MY_CCU_API_BASE_URL"
akamai_access_url_link = "MY_ACCESS_URL_LINK.mdc.edgesuite.net"
akamai_https_access_url_suffix = edgekey.net
akamai_http_config_number = 'MY_AKAMAI_HTTP_CONFIG_NUMBER'
akamai_https_shared_config_number = 'MY_AKAMAI_HTTPS_CONFIG_SHARED_NUMBER'
akamai_https_san_config_numbers = 'MY_AKAMAI_HTTPS_CONFIG_SAN_NUMBER'
akamai_https_custom_config_numbers = 'MY_AKAMAI_HTTPS_CONFIG_CUSTOM_NUMBER'
san_cert_cnames = "MY_SAN_CERT_LIST"
san_cert_hostname_limit = "MY_SAN_HOSTNAMES_LIMIT"
[drivers:provider:fastly]
apikey = "MYAPIKEY"
scheme = "https"
host = "api.fastly.com"
[drivers:provider:maxcdn]
alias = "MYALIAS"
consumer_secret = "MYCONSUMER_SECRET"
consumer_key = "MYCONSUMERKEY"
[drivers:provider:cloudfront]
aws_access_key_id = "MY_AWS_ACCESS_KEY_ID"
aws_secret_access_key = "MY_AWS_SECRET_ACCESS_KEY"
[drivers:dns:rackspace]
username = "<operator_username>"
api_key = "<operator_api_key>"
use_shards = True
num_shards = 400
shard_prefix = "cdn"
shared_ssl_num_shards = 5
shared_ssl_shard_prefix = "scdn"
shared_ssl_domain_suffix = "secure.poppycdn.net"
url = "poppycdn.net"
url_404 = notfound.com
email = "your@email.com"
auth_endpoint = ""
timeout = 30
delay = 1
[log_delivery]
identity_url = https://KEYSTONE_URI/v2.0/tokens
preferred_dcs = 'IAD'
container_name = .CDN_ACCESS_LOGS

View File

@ -1,75 +0,0 @@
# By default, this should live in one of:
# ~/.poppy/poppy.conf
# /etc/poppy/poppy.conf
[DEFAULT]
# Show more verbose log output (sets INFO log level output)
verbose = True
# Show debugging output in logs (sets DEBUG log level output)
;debug = False
# Log to this file
log_file = poppy.log
;auth_strategy =
# ================= Syslog Options ============================
# Send logs to syslog (/dev/log) instead of to file specified
# by `log_file`
;use_syslog = False
# Facility to use. If unset defaults to LOG_USER.
;syslog_log_facility = LOG_LOCAL0
# ================= Driver Options ============================
[drivers]
# Transport driver module (e.g., falcon, pecan)
transport = pecan
# Manager driver module (e.g. default)
manager = default
# Storage driver module (e.g., mongodb, sqlite, cassandra)
storage = cassandra
# Provider modules list (a list of comma separated provider module list)
providers = fastly
# DNS driver module (e.g., default, designate, rackspace)
dns = rackspace
[drivers:transport:pecan]
bind = 0.0.0.0
port = 8081
[drivers:storage:cassandra]
cluster = "cassandra"
keyspace = poppy
# Path to directory containing CQL migration scripts
migrations_path = /home/poppy/poppy/storage/cassandra/migrations
[drivers:dns:rackspace]
username = DNS_USERNAME
api_key = DNS_APIKEY
use_shards = True
num_shards = 499
shard_prefix = "cdn"
url = DNS_URL
email = DNS_EMAIL
[drivers:provider:fastly]
apikey = FASTLY_APIKEY
[drivers:provider:akamai]
policy_api_client_token = AKAM_POLICY_API_CLIENT_TOKEN
policy_api_client_secret = AKAM_POLICY_API_CLIENT_SECRET
policy_api_access_token = AKAM_POLICY_API_ACCESS_TOKEN
policy_api_base_url = AKAM_POLICY_API_BASE_URL
ccu_api_client_token = AKAM_CCU_API_CLIENT_TOKEN
ccu_api_client_secret = AKAM_CCU_API_CLIENT_SECRET
ccu_api_access_token = AKAM_CCU_API_ACCESS_TOKEN
ccu_api_base_url = AKAM_CCU_API_BASE_URL
akamai_access_url_link = AKAM_ACCESS_URL_LINK

31
docker/api/startup.sh Executable file
View File

@ -0,0 +1,31 @@
#!/bin/bash
is_ready() {
nc -z cassandra 9042
}
# wait until cassandra is ready
while ! is_ready -eq 1
do
echo "$(date) - still trying to connect to cassandra"
sleep 1
done
echo "$(date) - connected successfully to cassandra"
# start the poppy-workers
exec poppy-worker > /dev/null 2>&1 &
exec poppy-worker > /dev/null 2>&1 &
exec poppy-worker > /dev/null 2>&1 &
exec poppy-worker > /dev/null 2>&1 &
exec poppy-worker > /dev/null 2>&1 &
exec poppy-worker > /dev/null 2>&1 &
exec poppy-worker > /dev/null 2>&1 &
exec poppy-worker > /dev/null 2>&1 &
exec poppy-worker > /dev/null 2>&1 &
# start the poppy-server (via uwsgi)
exec /usr/local/bin/uwsgi --ini /root/uwsgi.ini

View File

@ -2,8 +2,8 @@
master = true
chdir = /home/poppy/
workers = 4
http-socket = 0.0.0.0:8081
logger = file:/var/log/poppy/poppy.log
http-socket = 0.0.0.0:8080
logger = file:/var/log/poppy.log
pidfile = /var/run/poppy/poppy.pid
die-on-term = true
enable-threads = true

View File

@ -1,54 +0,0 @@
##
## Poppy
##
##
FROM ubuntu:14.04
MAINTAINER Amit Gandhi <amit.gandhi@rackspace.com>
RUN apt-get -qq update
RUN apt-get -qq upgrade
# Install Pip, Python, etc
RUN apt-get -qq install git-core wget curl libpython-dev vim memcached libev4 libev-dev python-dev
# setuptools
RUN wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py
RUN python ez_setup.py
# pip
RUN wget https://raw.github.com/pypa/pip/master/contrib/get-pip.py
RUN python get-pip.py
# uwsgi
RUN pip install uwsgi
# Copy project from local sources
VOLUME /home/poppy
ADD . /home/poppy
# Install Requirements
RUN sudo pip install -r /home/poppy/requirements/requirements.txt
RUN sudo pip install -e /home/poppy/.
# Set up the configuration files
ADD ./docker/api_dev/poppy.conf /etc/poppy.conf
ADD ./docker/api_dev/logging.conf /etc/logging.conf
ADD ./docker/api_dev/uwsgi.ini /root/uwsgi.ini
# Deploy startup script
ADD ./docker/api_dev/init.sh /usr/local/bin/poppy_startup
RUN chmod 755 /usr/local/bin/poppy_startup
# create uwsgi log directory
RUN mkdir -p /var/log/poppy
RUN chmod -R +w /var/log/poppy
# create uwsgi pid directory
RUN mkdir -p /var/run/poppy
RUN chmod -R +w /var/run/poppy
# Start Poppy
EXPOSE 8081
CMD poppy_startup

View File

@ -1,37 +0,0 @@
Before Starting
---------------
The following files should exist in this folder before running Dockerfile
* poppy.conf (desired configuration for poppy api)
* logging.conf (desired logging configuration file)
Building the Poppy Server Docker Image
--------------------------------------
Copy the Dockerfile to the /poppy root folder, then run::
$ docker build -t poppy .
Running the Poppy Docker Container
--------------------------------------
Name the container 'poppy'::
$ docker run -d -p 81:8081 --name poppy poppy
Testing
--------
Access the running poppy api instance home document::
$ curl <docker_ip>/v1.0/
Next Steps
----------
If running locally with Cassandra, ensure the Cassandra Docker Container is running and linked.

View File

@ -1,27 +0,0 @@
#!/usr/bin/env bash
# Setup Configs
echo "Setting Configs"
CONFIG=/etc/poppy.conf
sed -i -e "s/DNS_USERNAME/$DNS_USERNAME/" $CONFIG
sed -i -e "s/DNS_APIKEY/$DNS_APIKEY/" $CONFIG
sed -i -e "s/DNS_URL/$DNS_URL/" $CONFIG
sed -i -e "s/DNS_EMAIL/$DNS_EMAIL/" $CONFIG
sed -i -e "s/FASTLY_APIKEY/$FASTLY_APIKEY/" $CONFIG
sed -i -e "s/AKAM_POLICY_API_CLIENT_TOKEN/$AKAM_POLICY_API_CLIENT_TOKEN/" $CONFIG
sed -i -e "s/AKAM_POLICY_API_CLIENT_SECRET/$AKAM_POLICY_API_CLIENT_SECRET/" $CONFIG
sed -i -e "s/AKAM_POLICY_API_ACCESS_TOKEN/$AKAM_POLICY_API_ACCESS_TOKEN/" $CONFIG
sed -i -e "s/AKAM_POLICY_API_BASE_URL/$AKAM_POLICY_API_BASE_URL/" $CONFIG
sed -i -e "s/AKAM_CCU_API_CLIENT_TOKEN/$AKAM_CCU_API_CLIENT_TOKEN/" $CONFIG
sed -i -e "s/AKAM_CCU_API_CLIENT_SECRET/$AKAM_CCU_API_CLIENT_SECRET/" $CONFIG
sed -i -e "s/AKAM_CCU_API_ACCESS_TOKEN/$AKAM_CCU_API_ACCESS_TOKEN/" $CONFIG
sed -i -e "s/AKAM_CCU_API_BASE_URL/$AKAM_CCU_API_BASE_URL/" $CONFIG
sed -i -e "s/AKAM_ACCESS_URL_LINK/$AKAM_ACCESS_URL_LINK/" $CONFIG
sed -i -e "s/AKAM_SECURE_URL_LINK/$AKAM_SECURE_URL_LINK/" $CONFIG
sed -i -e "s/AKAM_HTTP_POLICY/$AKAM_HTTP_POLICY/" $CONFIG
sed -i -e "s/AKAM_HTTPS_POLICY/$AKAM_HTTPS_POLICY/" $CONFIG
/usr/local/bin/uwsgi --ini /root/uwsgi.ini

View File

@ -1,49 +0,0 @@
[loggers]
keys=root,server,combined
[formatters]
keys=normal,normal_with_name,debug
[handlers]
keys=production,file,devel
[logger_root]
level=NOTSET
handlers=devel
[logger_server]
level=DEBUG
handlers=devel
qualname=poppy-server
[logger_combined]
level=DEBUG
handlers=devel,file
qualname=poppy-combined
[handler_production]
class=handlers.SysLogHandler
level=ERROR
formatter=normal_with_name
args=(('localhost', handlers.SYSLOG_UDP_PORT), handlers.SysLogHandler.LOG_USER)
[handler_file]
class=FileHandler
level=DEBUG
formatter=normal_with_name
args=('poppy.log', 'w')
[handler_devel]
class=StreamHandler
level=NOTSET
formatter=debug
args=(sys.stdout,)
[formatter_normal]
format=%(asctime)s %(levelname)s %(message)s
[formatter_normal_with_name]
format=(%(name)s): %(asctime)s %(levelname)s %(message)s
[formatter_debug]
format=(%(name)s): %(asctime)s %(levelname)s %(module)s %(funcName)s %(message)s

View File

@ -1,78 +0,0 @@
# By default, this should live in one of:
# ~/.poppy/poppy.conf
# /etc/poppy/poppy.conf
[DEFAULT]
# Show more verbose log output (sets INFO log level output)
verbose = True
# Show debugging output in logs (sets DEBUG log level output)
;debug = False
# Log to this file
log_file = poppy.log
;auth_strategy =
# ================= Syslog Options ============================
# Send logs to syslog (/dev/log) instead of to file specified
# by `log_file`
;use_syslog = False
# Facility to use. If unset defaults to LOG_USER.
;syslog_log_facility = LOG_LOCAL0
# ================= Driver Options ============================
[drivers]
# Transport driver module (e.g., falcon, pecan)
transport = pecan
# Manager driver module (e.g. default)
manager = default
# Storage driver module (e.g., mongodb, sqlite, cassandra)
storage = cassandra
# Provider modules list (a list of comma separated provider module list)
providers = fastly,akamai
# DNS driver module (e.g., default, designate, rackspace)
dns = rackspace
[drivers:transport:pecan]
bind = 0.0.0.0
port = 8081
[drivers:storage:cassandra]
cluster = "cassandra"
keyspace = poppy
# Path to directory containing CQL migration scripts
migrations_path = /home/poppy/poppy/storage/cassandra/migrations
[drivers:dns:rackspace]
username = DNS_USERNAME
api_key = DNS_APIKEY
use_shards = True
num_shards = 499
shard_prefix = "cdn"
url = DNS_URL
email = DNS_EMAIL
[drivers:provider:fastly]
apikey = FASTLY_APIKEY
[drivers:provider:akamai]
policy_api_client_token = AKAM_POLICY_API_CLIENT_TOKEN
policy_api_client_secret = AKAM_POLICY_API_CLIENT_SECRET
policy_api_access_token = AKAM_POLICY_API_ACCESS_TOKEN
policy_api_base_url = AKAM_POLICY_API_BASE_URL
ccu_api_client_token = AKAM_CCU_API_CLIENT_TOKEN
ccu_api_client_secret = AKAM_CCU_API_CLIENT_SECRET
ccu_api_access_token = AKAM_CCU_API_ACCESS_TOKEN
ccu_api_base_url = AKAM_CCU_API_BASE_URL
akamai_access_url_link = AKAM_ACCESS_URL_LINK
akamai_https_access_url_suffix = AKAM_SECURE_URL_LINK
akamai_http_config_number = AKAM_HTTP_POLICY
akamai_https_config_number = AKAM_HTTPS_POLICY

View File

@ -1,16 +0,0 @@
[uwsgi]
master = true
chdir = /home/poppy/
workers = 4
http-socket = 0.0.0.0:8081
logger = file:/var/log/poppy/poppy.log
pidfile = /var/run/poppy/poppy.pid
die-on-term = true
enable-threads = true
buffer-size = 32768
max-requests = 15000
no-orphans = true
vacuum = true
module = poppy.transport.app:app
py-auto-reload = 1
virtualenv = /usr/

View File

@ -1,44 +0,0 @@
##
## Cassandra
##
##
FROM ubuntu:14.04
MAINTAINER Tony Tan, tonytan198211@gmail.com
# Add PPA for the necessary JDK
RUN echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu precise main" | tee /etc/apt/sources.list.d/webupd8team-java.list
RUN echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu precise main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list
RUN apt-key adv --keyserver "hkp://keyserver.ubuntu.com:80" --recv-keys EEA14886
RUN apt-get update
# Install other packages
RUN apt-get install -y curl
# Preemptively accept the Oracle License
RUN echo "oracle-java7-installer shared/accepted-oracle-license-v1-1 boolean true" > /tmp/oracle-license-debconf
RUN /usr/bin/debconf-set-selections /tmp/oracle-license-debconf
RUN rm /tmp/oracle-license-debconf
# Install the JDK
RUN apt-get install -y oracle-java7-installer oracle-java7-set-default
RUN apt-get update
# Install Cassandra
RUN echo "deb http://debian.datastax.com/community stable main" | sudo tee -a /etc/apt/sources.list.d/datastax.sources.list
RUN curl -L http://debian.datastax.com/debian/repo_key | sudo apt-key add -
RUN apt-get update
RUN apt-get install -y dsc20 cassandra=2.0.*
# Deploy startup script
ADD init.sh /usr/local/bin/cass-dock
RUN chmod 755 /usr/local/bin/cass-dock
# Deploy shutdown script
ADD shutdown.sh /usr/local/bin/cass-stop
RUN chmod 755 /usr/local/bin/cass-stop
EXPOSE 7199 7000 7001 9160 9042
USER root
CMD cass-dock

View File

@ -1,35 +0,0 @@
Building the Cassandra Docker Image
--------------------------------------
From the docker/cassandra folder:
$ docker build -t db .
Running the Cassandra Docker Container
--------------------------------------
Open the 9160 and 9042 ports for Cassandra.
Name the container 'cassandra'
$ docker run -d -p 9160:9160 -p 9042:9042 --name cassandra db
Testing
--------
Access the running cassandra instance (you may need to ``pip install cqlsh``):
$ cqlsh <local ip> 9160
Where local ip is the ip address of your running docker container
Import Schema
---------------
Import the schema file from the [poppy/storage/cassandra/schema.cql](../poppy/storage/cassandra/schema.cql) file:
$ cqlsh -f ../../poppy/storage/cassandra/schema.cql <local ip> 9160

View File

@ -1,22 +0,0 @@
#!/usr/bin/env bash
IP=`hostname --ip-address`
SEEDS=`env | grep CASS[0-9]_PORT_9042_TCP_ADDR | sed 's/CASS[0-9]_PORT_9042_TCP_ADDR=//g' | sed -e :a -e N -e 's/\n/,/' -e ta`
if [ -z "$SEEDS" ]; then
SEEDS=$IP
fi
echo "Listening on: "$IP
echo "Found seeds: "$SEEDS
# Setup Cassandra
CONFIG=/etc/cassandra/
sed -i -e "s/^listen_address.*/listen_address: $IP/" $CONFIG/cassandra.yaml
sed -i -e "s/^rpc_address.*/rpc_address: 0.0.0.0/" $CONFIG/cassandra.yaml
sed -i -e "s/- seeds: \"127.0.0.1\"/- seeds: \"$SEEDS\"/" $CONFIG/cassandra.yaml
sed -i -e "s/# JVM_OPTS=\"$JVM_OPTS -Djava.rmi.server.hostname=<public name>\"/ JVM_OPTS=\"$JVM_OPTS -Djava.rmi.server.hostname=$IP\"/" $CONFIG/cassandra-env.sh
# Start Cassandra
echo Starting Cassandra...
cassandra -f -p /var/run/cassandra.pid

View File

@ -1,2 +0,0 @@
echo "Stopping Cassandra..."
sudo kill `cat /var/run/cassandra.pid`

73
docker/compose/README.md Normal file
View File

@ -0,0 +1,73 @@
Before you begin
----------------
Install Docker-Compose::
$ sudo pip install -U docker-compose
Warning - never git commit your secret credentials to upstream!
Install the Full Poppy stack (poppy_stack.yml)
----------------------------------------------
1. Create your poppy.conf Configuration file:
$ cp docker/api/poppy-sample.conf docker/api/poppy.conf
2. Update docker/api/poppy.conf with your secret settings (this file is git-ignored).
3. Build and Run::
$ docker-compose -f docker/compose/poppy_stack.yml up -d
Running Poppy Locally
---------------------
During development, you want to run poppy locally, but use dependencies like Zookeeper and Cassandra within a Docker Container.
1. Build and Run::
$ docker-compose -f dependencies.yml up -d
Testing
-------
Access the running poppy api instance home document::
$ curl <docker_ip>/v1.0/
Useful Commands
---------------
Kill All Containers:
$ docker kill $(docker ps -aq)
Remove All Containers:
$ docker rm $(docker ps -aq)
List All Containers:
$ docker ps -a
Rebuild Stack:
$ docker-compose -f docker/compose/poppy_stack.yml build
Known Issues
------------
Docker Cassandra Image:
Killing the container (docker kill ...) will remove the data, but not the structure. This will cause issues with schema migration next time you run the container. It is recommended to remove the container completely (docker rm ...) to restart with a clean slate.
Akamai Driver:
Interacting with the Akamai API via the egcurl client requires the host to be running with time synced with an NTP server. Any time skew will cause policy updates to fail with a 'Invalid Timestamp' error. Restart your docker host (boot2docker) and try again.

View File

@ -0,0 +1,10 @@
zookeeper:
image: jplock/zookeeper
ports:
- 2181:2181
cassandra:
image: library/cassandra
ports:
- 9160:9160
- 9042:9042

View File

@ -0,0 +1,17 @@
poppy:
build: ../api/.
ports:
- "80:8080"
links:
- cassandra
- zookeeper
zookeeper:
extends:
file: dependencies.yml
service: zookeeper
cassandra:
extends:
file: dependencies.yml
service: cassandra

View File

@ -1,87 +0,0 @@
Install Fig::
$ sudo pip install -U fig
Before you begin
----------------
Update the appropriate fig file being used with the appropriate credentials.
Warning - never git commit your secret credentials to upstream! We recommend you create a new file named fig_local.yml (this will be ignored by git) and add your credentials in there. Reference that file in the -f parameter in the instructions below.
Install Poppy from Upstream (fig.yml)
-------------------------------------
Build and Run::
$ fig -f docker/fig/fig_local.yml up -d
Build && Rebuild::
$ fig -f fig_local.yml build
To stop all your fig containers::
$ fig stop
To start all your fig containers without rebuilding::
$ fig start
To get the most-updated code of poppy::
$ fig run poppy git --git-dir=/home/poppy/.git pull
$ fig run poppy uwsgi --reload /var/run/poppy/poppy.pid
Mounting a local Poppy Volume (copy from fig_dev.yml)
-------------------------------------------
1. Build and Run::
$ ./docker/fig/dev -f fig_local.yml up -d
Note that `dev` is a wrapper around the [`fig` CLI](http://www.fig.sh/cli.html) so
any sub-commands that work with the fig CLI will work with `dev` as well.
Also note that the `fig_dev.yml` file in this folder cannot be used directly with
`fig`. Please invoke `dev` instead as it does some extra setup before internally
invoking `fig`.
Building and Running the Poppy API Server w/Mimic (fig_mimic.yml)
-----------------------------------------------------------------
From this folder, run:
$ ./docker/fig/dev_mimic -f docker/fig/fig_local.yml up -d
This will bring up a poppy server with your local poppy repository mounted as a volume
and will run it with any local changes. Cassandra and Mimic will also be started and
wired together.
If you are running docker locally, you can then access the API at:
$ curl http://<docker_ip>/v1.0/
If local changes are made, simply restart the services to run them:
$ ./docker/fig/dev_mimic restart
You can run the API tests against the poppy container according to the
[API testing](https://github.com/stackforge/poppy/blob/master/tests/api/README.rst)
documentation.
Note that `dev_mimic` is a wrapper around [`fig`](http://www.fig.sh/cli.html) so
any sub-commands that work with the fig CLI will work with `dev_mimic` as well.
Note that `dev_mimic` does not run a repose container.
Testing
--------
Access the running poppy api instance home document::
$ curl <docker_ip>/v1.0/

View File

@ -1,11 +0,0 @@
#!/bin/sh
THIS_DIR=$(dirname $0)
PROJECT_ROOT_DIR=$THIS_DIR/../..
# Copy Dockerfile from this folder to project root folder
cp $PROJECT_ROOT_DIR/docker/api_dev/Dockerfile $PROJECT_ROOT_DIR/
# Bring up development environment
cd $THIS_DIR
FIG_FILE=fig_dev.yml fig $@

View File

@ -1,10 +0,0 @@
#!/bin/sh
THIS_DIR=$(dirname $0)
PROJECT_ROOT_DIR=$THIS_DIR/../..
# Copy Dockerfile from this folder to project root folder
cp -f $PROJECT_ROOT_DIR/docker/api_ci/Dockerfile $PROJECT_ROOT_DIR/Dockerfile
# Bring up development environment
FIG_FILE=fig_mimic.yml fig $@

View File

@ -1,47 +0,0 @@
repose:
build: ../repose/.
ports:
- "80:8080"
environment:
KEYSTONE_ADMIN: Username
KEYSTONE_PASSWORD: Password
KEYSTONE_URI: Uri
DESTINATION_HOST: poppy
DESTINATION_PORT: 8081
links:
- poppy
poppy:
build: ../api/.
ports:
- "81:8081"
environment:
DNS_USERNAME: CloudUsername
DNS_APIKEY: CloudApiKey
DNS_URL: DNSUrlToUse
DNS_EMAIL: YourEmailAddress
FASTLY_APIKEY: FastlyApiKey
AKAM_POLICY_API_CLIENT_TOKEN: value
AKAM_POLICY_API_CLIENT_SECRET: value
AKAM_POLICY_API_ACCESS_TOKEN: value
AKAM_POLICY_API_BASE_URL: value
AKAM_CCU_API_CLIENT_TOKEN: value
AKAM_CCU_API_CLIENT_SECRET: value
AKAM_CCU_API_ACCESS_TOKEN: value
AKAM_CCU_API_BASE_URL: value
AKAM_ACCESS_URL_LINK: value
links:
- cassandra
- zookeeper
zookeeper:
image: jplock/zookeeper
ports:
- "2181:2181"
cassandra:
build: ../cassandra/.
ports:
- "9160:9160"
- "9042:9042"

View File

@ -1,5 +0,0 @@
cassandra:
build: ../cassandra/.
ports:
- "9160:9160"
- "9042:9042"

View File

@ -1,42 +0,0 @@
repose:
build: ../repose/.
ports:
- "80:8080"
environment:
KEYSTONE_ADMIN: Username
KEYSTONE_PASSWORD: Password
KEYSTONE_URI: Uri
DESTINATION_HOST: poppy
DESTINATION_PORT: 8081
links:
- poppydev
poppydev:
build: ../../.
ports:
- "81:8081"
environment:
DNS_USERNAME: CloudUsername
DNS_APIKEY: CloudApiKey
DNS_URL: DNSUrlToUse
DNS_EMAIL: YourEmailAddress
FASTLY_APIKEY: FastlyApiKey
AKAM_POLICY_API_CLIENT_TOKEN: value
AKAM_POLICY_API_CLIENT_SECRET: value
AKAM_POLICY_API_ACCESS_TOKEN: value
AKAM_POLICY_API_BASE_URL: value
AKAM_CCU_API_CLIENT_TOKEN: value
AKAM_CCU_API_CLIENT_SECRET: value
AKAM_CCU_API_ACCESS_TOKEN: value
AKAM_CCU_API_BASE_URL: value
AKAM_ACCESS_URL_LINK: value
links:
- cassandra
volumes:
- ../../:/home/poppy
cassandra:
build: ../cassandra/.
ports:
- "9160:9160"
- "9042:9042"

View File

@ -1,16 +0,0 @@
cassandra:
build: ../cassandra/.
mimic:
build: ../mimic/.
poppy:
build: ../../.
ports:
- "8888:8081"
volumes:
- ../../:/home/poppy
- /etc/localtime:/etc/localtime:ro
command:
- /root/start_poppy.sh
links:
- cassandra
- mimic

View File

@ -1,10 +1,9 @@
# Dockerfile for Repose (www.openrepose.org)
FROM ubuntu:14.04
FROM ubuntu
MAINTAINER Felix Sargent (felix.sargent@rackspace.com)
MAINTAINER Damien Johnson (damien.johnson@rackspace.com)
RUN apt-get update
RUN apt-get install -y wget
RUN wget -O - http://repo.openrepose.org/debian/pubkey.gpg | apt-key add - && echo "deb http://repo.openrepose.org/debian stable main" > /etc/apt/sources.list.d/openrepose.list
RUN apt-get update && apt-get install -y repose-valve repose-filter-bundle repose-extensions-filter-bundle
@ -13,15 +12,15 @@ RUN apt-get update && apt-get install -y repose-valve repose-filter-bundle repos
RUN rm /etc/repose/*.cfg.xml
# Copy our configuration files in.
COPY ./repose_configs /etc/repose
ADD ./repose_configs/*.cfg.xml /etc/repose/
# Deploy startup script
ADD init.sh /usr/local/bin/repose-docker
RUN chmod 755 /usr/local/bin/repose-docker
# Expose Port 8080 -- Change this to use other ports for Repose
# Change this to use other ports for Repose
EXPOSE 8080
# Start Repose
USER root
CMD repose-docker
CMD repose-docker

View File

@ -26,10 +26,11 @@ def main(args):
if len(args) != 3:
print("usage: python get.py [env] [domain]")
print(
"example : python get.py [prod|test] www.mysite.com")
"example : python get.py [prod|test|prod_staging] www.mysite.com")
sys.exit(2)
env = args[1]
env = args[1].replace('_staging', '')
use_staging = args[1].endswith('_staging')
domain = args[2]
config_parser = ConfigParser.RawConfigParser()
@ -44,7 +45,7 @@ def main(args):
print("")
print("querying akamai api for policy definition: ")
akamai_request(env, domain, config_parser)
akamai_request(env, domain, use_staging, config_parser)
print("")
print("")
@ -53,7 +54,7 @@ def main(args):
print("")
print("")
browser_request(domain)
# browser_request(domain)
print("")
print("")
@ -69,16 +70,20 @@ def edge_session(env, config):
return s
def akamai_request(env, domain, config):
def akamai_request(env, domain, use_staging, config):
base_url = config.get(env, 'base_url')
policy_num = config.get(env, 'policy_number')
env_var = "production"
if use_staging:
env_var = "staging"
policy_url = ('{0}partner-api/v1/network/production/properties/'
policy_url = ('{0}partner-api/v1/network/{3}/properties/'
'{1}/sub-properties/{2}/policy')
policy_url = policy_url.format(
base_url,
policy_num,
domain
domain,
env_var
)
print ("API URL: " + policy_url)

View File

@ -23,12 +23,13 @@ from akamai.edgegrid import EdgeGridAuth
def main(args):
if len(args) != 3:
print("usage: python get.py [env] [domain]")
print("usage: python put.py [env] [domain]")
print(
"example : python get.py [prod|test] www.mysite.com")
"example : python put.py [prod|test|prod_staging] www.mysite.com")
sys.exit(2)
env = args[1]
env = args[1].replace('_staging', '')
use_staging = args[1].endswith('_staging')
domain = args[2]
config_parser = ConfigParser.RawConfigParser()
@ -39,7 +40,7 @@ def main(args):
print("")
print("updating api with policy definition: ")
akamai_request(env, domain, config_parser)
akamai_request(env, domain, use_staging, config_parser)
print("")
print("")
@ -55,16 +56,21 @@ def edge_session(env, config):
return s
def akamai_request(env, domain, config):
def akamai_request(env, domain, use_staging, config):
base_url = config.get(env, 'base_url')
policy_num = config.get(env, 'policy_number')
policy_url = ('{0}partner-api/v1/network/production/properties/'
env_var = "production"
if use_staging:
env_var = "staging"
policy_url = ('{0}partner-api/v1/network/{3}/properties/'
'{1}/sub-properties/{2}/policy')
policy_url = policy_url.format(
base_url,
policy_num,
domain
domain,
env_var
)
print ("API URL: " + policy_url)
@ -78,7 +84,7 @@ def akamai_request(env, domain, config):
{
"name": "origin",
"params": {
"cacheKeyType": "origin",
"cacheKeyType": "digital_property",
"cacheKeyValue": "-",
"digitalProperty": domain,
"hostHeaderType": "digital_property",
@ -90,7 +96,7 @@ def akamai_request(env, domain, config):
{
"name": "caching",
"type": "fixed",
"value": "3600s"
"value": "172800s"
}
],
"matches": [