Enable local development using fig/docker setup
With this change, you can create a local development environment using fig, make changes to local code, causing the uwsgi application to be automatically reloaded in the poppy Docker container. This change also fixes the repose/init.sh file to account for the new location of the repose-valve.jar file. Change-Id: I4e1ac57cecdba717a6f92917103ac778be449cc5
This commit is contained in:
parent
a4c3ed1b52
commit
05675b813d
|
@ -40,3 +40,5 @@ tests/logs
|
||||||
.pydevproject
|
.pydevproject
|
||||||
venv
|
venv
|
||||||
docker_rsa*
|
docker_rsa*
|
||||||
|
|
||||||
|
Dockerfile
|
||||||
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
##
|
||||||
|
## 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
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
#RUN /usr/local/bin/uwsgi --ini /root/uwsgi.ini
|
||||||
|
|
||||||
|
# Start Poppy
|
||||||
|
EXPOSE 8081
|
||||||
|
CMD ["/usr/local/bin/uwsgi", "--ini", "/root/uwsgi.ini"]
|
|
@ -0,0 +1,29 @@
|
||||||
|
Before Starting
|
||||||
|
---------------
|
||||||
|
|
||||||
|
The following files should exist in this folder before running Dockerfile
|
||||||
|
* docker_rsa (private key) -> public key should be published to the private git repo
|
||||||
|
* poppy.conf (desired configuration for poppy api)
|
||||||
|
* logging.conf (desired logging configuration file)
|
||||||
|
|
||||||
|
Install Fig::
|
||||||
|
|
||||||
|
$ sudo pip install -U fig
|
||||||
|
|
||||||
|
|
||||||
|
Building and Running the Poppy API Server
|
||||||
|
-----------------------------------------
|
||||||
|
|
||||||
|
From this folder, run::
|
||||||
|
|
||||||
|
$ dev up
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
Testing
|
||||||
|
--------
|
||||||
|
|
||||||
|
Access the running poppy api instance home document::
|
||||||
|
|
||||||
|
$ curl <docker_ip>/v1.0/
|
|
@ -0,0 +1,11 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
THIS_DIR=$(dirname $0)
|
||||||
|
PROJECT_ROOT_DIR=$THIS_DIR/../..
|
||||||
|
|
||||||
|
# Copy Dockerfile from this folder to project root folder
|
||||||
|
cp $THIS_DIR/Dockerfile $PROJECT_ROOT_DIR/
|
||||||
|
|
||||||
|
# Bring up development environment
|
||||||
|
cd $THIS_DIR/../fig
|
||||||
|
FIG_FILE=fig_dev.yml fig $@
|
|
@ -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=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
|
|
@ -0,0 +1,53 @@
|
||||||
|
# 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
|
||||||
|
|
||||||
|
[drivers:provider:fastly]
|
||||||
|
apikey = "MYAPIKEY"
|
|
@ -0,0 +1,15 @@
|
||||||
|
[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
|
|
@ -1,4 +1,6 @@
|
||||||
Install Fig::
|
## Prerequisites
|
||||||
|
|
||||||
|
1. Install Fig::
|
||||||
|
|
||||||
$ sudo pip install -U fig
|
$ sudo pip install -U fig
|
||||||
|
|
||||||
|
@ -22,4 +24,3 @@ To get the most-updated code of poppy::
|
||||||
|
|
||||||
$ fig run poppy git --git-dir=/home/poppy/.git pull
|
$ fig run poppy git --git-dir=/home/poppy/.git pull
|
||||||
$ fig run poppy uwsgi --reload /var/run/poppy/poppy.pid
|
$ fig run poppy uwsgi --reload /var/run/poppy/poppy.pid
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
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"
|
||||||
|
links:
|
||||||
|
- cassandra
|
||||||
|
volumes:
|
||||||
|
- ../../:/home/poppy
|
||||||
|
cassandra:
|
||||||
|
build: ../cassandra/.
|
||||||
|
ports:
|
||||||
|
- "9160:9160"
|
||||||
|
- "9042:9042"
|
|
@ -11,4 +11,4 @@ sed -i -e "s/DESTINATION_HOST/$DESTINATION_HOST/" $CONFIG/system-mo
|
||||||
sed -i -e "s/DESTINATION_PORT/$DESTINATION_PORT/" $CONFIG/system-model.cfg.xml
|
sed -i -e "s/DESTINATION_PORT/$DESTINATION_PORT/" $CONFIG/system-model.cfg.xml
|
||||||
|
|
||||||
echo "Starting Repose"
|
echo "Starting Repose"
|
||||||
java -jar /usr/share/lib/repose/repose-valve.jar
|
java -jar /usr/share/repose/repose-valve.jar
|
||||||
|
|
Loading…
Reference in New Issue