diff options
author | Kelley Spoon <kelley.spoon@linaro.org> | 2018-03-06 23:04:35 -0600 |
---|---|---|
committer | Kelley Spoon <kelley.spoon@linaro.org> | 2018-03-06 23:04:35 -0600 |
commit | e63649c2b18143f7e37568032349a4e73c10e646 (patch) | |
tree | 618dd128a179052f98e10fc2cc87d73191f99d4e | |
parent | 0994aba3a4a5901d70e5439e70715b68c2c56786 (diff) |
LLP: RFC Add LLP dockerfile and compose file.publishing
This changes adds a Dockerfile to build a container for the
linaro-license-protection app and an example compose file
for deploying three sample sites with it
Change-Id: I641bb277332e6df805db96693fdfb0182cb6cf69
-rw-r--r-- | llp/Dockerfile.python | 28 | ||||
-rw-r--r-- | llp/docker_init.sh | 26 | ||||
-rw-r--r-- | llp/requirements.txt | 16 | ||||
-rw-r--r-- | publishing/docker-compose.yml | 67 |
4 files changed, 137 insertions, 0 deletions
diff --git a/llp/Dockerfile.python b/llp/Dockerfile.python new file mode 100644 index 0000000..2a51966 --- /dev/null +++ b/llp/Dockerfile.python @@ -0,0 +1,28 @@ +# There is no base django image and instead they +# suggest using the python base image. We're +# going with the Debian Stretch base python 2.x +# option for now as it's closest to what we +# currently run +FROM python:2.7.14 + +ENV GUNICORN_WORKERS 4 +ENV WSGI_SCRIPT ${WSGI:-wsgi_production:application} +ENV LLP_PORT ${LLP_PORT:-8000} +ENV SITE_NAME ${SITE_NAME:-Protected Downloads} +ENV DJANGO_SETTINGS_MODULE ${DJANGO_SETTINGS_MODULE:-settings_production} + +EXPOSE 8000 +VOLUME /srv + +ADD ./requirements.txt /tmp/requirements.txt +ADD docker_init.sh /bin/docker_init.sh +RUN chmod 755 /bin/docker_init.sh + +# install reqs +RUN pip install -r /tmp/requirements.txt +# add this manually for the docker environment +RUN pip install gunicorn + +WORKDIR /srv/project + +CMD /bin/docker_init.sh diff --git a/llp/docker_init.sh b/llp/docker_init.sh new file mode 100644 index 0000000..45dac22 --- /dev/null +++ b/llp/docker_init.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +# This script is meant to be run inside of a docker +# container. It takes care of some housekeeping +# commands before the app is started by gunicorn +# and set to run on port 8000. + +cd /srv/project + +./manage.py migrate --noinput +./manage.py collectstatic --noinput + +# These are set by the Dockerfile or at container run time +# GUNICORN_WORKERS +# WSGI_SCRIPT +# DJANGO_SETTINGS_MODULE +# LLP_PORT + +# These should all be present as environment variables from +# the Dockerfile. +gunicorn -w$GUNICORN_WORKERS \ + --pythonpath /srv/project \ + -e DJANGO_SETTINGS_MODULE="$DJANGO_SETTINGS_MODULE" \ + -e SITE_NAME="$SITE_NAME" \ + -b 0.0.0.0:$LLP_PORT \ + $WSGI_SCRIPT diff --git a/llp/requirements.txt b/llp/requirements.txt new file mode 100644 index 0000000..f0c57c8 --- /dev/null +++ b/llp/requirements.txt @@ -0,0 +1,16 @@ +Django==1.11 +IP2Location +beautifulsoup +boto +django-openid-auth +html2text +mock +pep8 +psycopg2 +pyOpenSSL +pyflakes +python-openid +requests +testrepository +textile +whitenoise diff --git a/publishing/docker-compose.yml b/publishing/docker-compose.yml new file mode 100644 index 0000000..7784abc --- /dev/null +++ b/publishing/docker-compose.yml @@ -0,0 +1,67 @@ +--- +version: '3.2' + +services: + hostsdns: + image: linaro/hostsdns + container_name: hostsdns + network_mode: bridge + build: + context: ../hostsdns + dockerfile: Dockerfile + volumes: + - /var/run/docker.sock:/var/run/docker.sock + - /etc/hosts:/tmp/hosts + releases: + image: linaro/llp + container_name: releases + network_mode: bridge + build: + context: ../llp + dockerfile: Dockerfile + hostname: releases + environment: + - GUNICORN_WORKERS=4 + - WSGI_SCRIPT=wsgi_production + - SITE_NAME=Test Releases + - DJANGO_SETTINGS_MODULE=settings_production + volumes: + - type: bind + source: /srv/releases + target: /srv + + snapshots: + image: linaro/llp + container_name: snapshots + network_mode: bridge + build: + context: ../llp + dockerfile: Dockerfile + hostname: snapshots + environment: + - GUNICORN_WORKERS=4 + - WSGI_SCRIPT=wsgi_production + - SITE_NAME=Test Snapshots + - DJANGO_SETTINGS_MODULE=settings_production + volumes: + - type: bind + source: /srv/snapshots + target: /srv + + publishing: + image: linaro/llp + container_name: publishing + network_mode: bridge + build: + context: ../llp + dockerfile: Dockerfile + hostname: publishing + environment: + - GUNICORN_WORKERS=4 + - WSGI_SCRIPT=wsgi_production + - SITE_NAME=Test Publishing + - DJANGO_SETTINGS_MODULE=settings_production + volumes: + - type: bind + source: /srv/publishing + target: /srv |