diff --git a/README.rst b/README.rst index 1a2e9ef6..dc2da48a 100644 --- a/README.rst +++ b/README.rst @@ -87,7 +87,7 @@ installed and running. 6. Install general requirements:: - $ pip install -r requirements.txt + $ pip install -r requirements/requirements.txt Install Requirements for each Provider configured:: diff --git a/docker/api-cdn/Dockerfile b/docker/api-cdn/Dockerfile index 0324d8a8..716e49ec 100644 --- a/docker/api-cdn/Dockerfile +++ b/docker/api-cdn/Dockerfile @@ -16,7 +16,18 @@ RUN apt-get -qq update RUN apt-get -qq upgrade # Install Pip, Python, etc -RUN apt-get -qqy install git-core python-pip curl libpython-dev uwsgi memcached libev4 libev-dev +RUN apt-get -qqy 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 # Make ssh dir RUN mkdir /root/.ssh/ @@ -32,20 +43,28 @@ RUN echo "IdentityFile ~/.ssh/id_rsa" >> /etc/ssh/ssh_config RUN touch /root/.ssh/known_hosts # Pull project -RUN git clone git@github.com:rackerlabs/cdn.git /home/cdn +RUN git clone git@github.com:rackerlab/cdn /home/cdn # Install Requirements -RUN sudo pip install -r /home/cdn/requirements.txt -# RUN sudo pip install -r /home/cdn/cdn/provider/fastly/requirements.txt -RUN sudo pip install -e git+https://github.com/zebrafishlabs/fastly-python@b98a756b2a03687d76c3cfa0e024a445af85b38d#egg=fastly-python -RUN sudo pip install httplib2>=0.8 +RUN sudo pip install -r /home/cdn/requirements/requirements.txt RUN sudo pip install -e /home/cdn/. # Set up the configuration files -ADD cdn.conf /etc/cdn.conf -ADD logging.conf /etc/logging.conf +ADD ./cdn.conf /etc/cdn.conf +ADD ./logging.conf /etc/logging.conf +ADD ./uwsgi.ini /root/uwsgi.ini + +# create uwsgi log directory +RUN mkdir -p /var/log/cdn +RUN chmod -R +w /var/log/cdn + +# create uwsgi pid directory +RUN mkdir -p /var/run/cdn +RUN chmod -R +w /var/run/cdn + +#RUN /usr/local/bin/uwsgi --ini /root/uwsgi.ini # Start CDN -EXPOSE 8888 -ENTRYPOINT ["cdn-server"] +EXPOSE 80 +CMD ["/usr/local/bin/uwsgi", "--ini", "/root/uwsgi.ini"] diff --git a/docker/api-cdn/cdn.conf b/docker/api-cdn/cdn.conf new file mode 100644 index 00000000..e98fa7a1 --- /dev/null +++ b/docker/api-cdn/cdn.conf @@ -0,0 +1,53 @@ +# By default, this should live in one of: +# ~/.cdn/cdn.conf +# /etc/cdn/cdn.conf + +[DEFAULT] +# Show more verbose log output (sets INFO log level output) +;verbose = False + +# Show debugging output in logs (sets DEBUG log level output) +;debug = False + +# Log to this file +log_file = cdn.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 = falcon + +# Storage driver module (e.g., mongodb, sqlite, cassandra) +# change to cassandra if you want to use cassandra storage +storage = mockdb + + +[drivers:transport:falcon] +bind = 0.0.0.0 +port = 8888 + +[drivers:storage:mongodb] +uri = mongodb://localhost +database = cdn + +[drivers:storage:cassandra] +cluster = "" +keyspace = cdn + +[drivers:storage:mockdb] +database = cdn + +[drivers:provider:fastly] +apikey = "" diff --git a/docker/api-cdn/logging.conf b/docker/api-cdn/logging.conf new file mode 100644 index 00000000..990cee07 --- /dev/null +++ b/docker/api-cdn/logging.conf @@ -0,0 +1,49 @@ +[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=cdn-server + +[logger_combined] +level=DEBUG +handlers=devel +qualname=cdn-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=('cdn.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 diff --git a/docker/api-cdn/uwsgi.ini b/docker/api-cdn/uwsgi.ini new file mode 100644 index 00000000..cc3cf486 --- /dev/null +++ b/docker/api-cdn/uwsgi.ini @@ -0,0 +1,14 @@ +[uwsgi] +master = true +chdir = /home/cdn/ +workers = 4 +http-socket = 0.0.0.0:80 +logger = file:/var/log/cdn/cdn.log +pidfile = /var/run/cdn/cdn.pid +die-on-term = true +enable-threads = true +buffer-size = 32768 +max-requests = 15000 +no-orphans = true +vacuum = true +module = cdn.transport.falcon.app:app \ No newline at end of file diff --git a/requirements.txt b/requirements/common.txt similarity index 78% rename from requirements.txt rename to requirements/common.txt index 6e56c617..55f577f6 100644 --- a/requirements.txt +++ b/requirements/common.txt @@ -2,12 +2,10 @@ pbr>=0.5.21,<1.0 Babel>=1.3 netaddr>=0.7.6 -falcon>=0.1.6,<0.1.7 jsonschema>=1.3.0,!=1.4.0 iso8601>=0.1.8 msgpack-python -pymongo>=2.4 -cassandra-driver>=1.0.0 + python-keystoneclient>=0.4.1 python-memcached WebOb>=1.2.3,<1.3 diff --git a/requirements/provider/fastly.txt b/requirements/provider/fastly.txt new file mode 100644 index 00000000..e3c250e5 --- /dev/null +++ b/requirements/provider/fastly.txt @@ -0,0 +1,2 @@ +fastly-python=git+https://github.com/zebrafishlabs/fastly-python@b98a756b2a03687d76c3cfa0e024a445af85b38d#egg=fastly-python +httplib2>=0.8 \ No newline at end of file diff --git a/requirements/requirements.txt b/requirements/requirements.txt new file mode 100644 index 00000000..9c4441a1 --- /dev/null +++ b/requirements/requirements.txt @@ -0,0 +1,4 @@ +-r common.txt +-r storage/cassandra.txt +-r transport/falcon.txt +-r provider/fastly.txt \ No newline at end of file diff --git a/requirements/storage/cassandra.txt b/requirements/storage/cassandra.txt new file mode 100644 index 00000000..3cb3cf2d --- /dev/null +++ b/requirements/storage/cassandra.txt @@ -0,0 +1 @@ +cassandra-driver>=1.0.0 \ No newline at end of file diff --git a/requirements/storage/mongo.txt b/requirements/storage/mongo.txt new file mode 100644 index 00000000..f7b56e2b --- /dev/null +++ b/requirements/storage/mongo.txt @@ -0,0 +1 @@ +pymongo>=2.4 \ No newline at end of file diff --git a/requirements/transport/falcon.txt b/requirements/transport/falcon.txt new file mode 100644 index 00000000..d0803e4a --- /dev/null +++ b/requirements/transport/falcon.txt @@ -0,0 +1 @@ +falcon>=0.1.6,<0.1.7 \ No newline at end of file diff --git a/requirements/transport/pecan.txt b/requirements/transport/pecan.txt new file mode 100644 index 00000000..e69de29b