diff options
author | Ben Copeland <ben.copeland@linaro.org> | 2017-09-05 11:51:50 +0100 |
---|---|---|
committer | Ben Copeland <ben.copeland@linaro.org> | 2017-09-12 16:37:22 +0100 |
commit | d803a188503f6cc9db4f74025db246195ac0c103 (patch) | |
tree | bf1905ec0da2adfffba6409191393f316dce1107 | |
parent | 850b3cd3b0f08ac0dc232626d7ee05b210680137 (diff) |
LLP: Add Docker Alpine image to build our LLP servers
Change-Id: If86863434815db42e2f1a2211a6357c94c4a9c38
-rw-r--r-- | ci-amd64-llp-alpine/Dockerfile | 27 | ||||
-rwxr-xr-x | ci-amd64-llp-alpine/build.sh | 9 | ||||
-rwxr-xr-x | ci-amd64-llp-alpine/docker_run.sh | 25 |
3 files changed, 61 insertions, 0 deletions
diff --git a/ci-amd64-llp-alpine/Dockerfile b/ci-amd64-llp-alpine/Dockerfile new file mode 100644 index 00000000..5d4fc2d2 --- /dev/null +++ b/ci-amd64-llp-alpine/Dockerfile @@ -0,0 +1,27 @@ +FROM alpine + +ARG APP_VERSION=? +ENV APP_VERSION=$APP_VERSION +ENV APPDIR=/srv/linaro-license-protection +ENV PORT=8080 +ENV LLP_APP=linaro-license-protection.wsgi_production +ENV DJANGO_SETTINGS_MODULE=settings_production + +# Setup flask application +RUN mkdir -p $APPDIR + +WORKDIR $APPDIR + +RUN apk --update --no-cache add python2 py2-pip mysql-client git py-gunicorn sqlite postgresql-dev && \ + apk --no-cache add gcc g++ python2-dev musl-dev && \ + git clone https://git.linaro.org/infrastructure/linaro-license-protection.git/ $APPDIR && \ + pip2 install --upgrade pip setuptools six && \ + pip2 install -r $APPDIR/requirements.txt && \ + apk del gcc g++ python3-dev musl-dev + +EXPOSE $PORT + +# Start gunicorn +COPY ./ /srv +WORKDIR /srv +CMD ["/srv/docker_run.sh"] diff --git a/ci-amd64-llp-alpine/build.sh b/ci-amd64-llp-alpine/build.sh new file mode 100755 index 00000000..d95f74fa --- /dev/null +++ b/ci-amd64-llp-alpine/build.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +set -e + +export LANG=C + +image=linaro/ci-amd64-llp-alpine:latest +docker build --pull --tag=$image . +echo $image > .docker-tag diff --git a/ci-amd64-llp-alpine/docker_run.sh b/ci-amd64-llp-alpine/docker_run.sh new file mode 100755 index 00000000..43ab62d6 --- /dev/null +++ b/ci-amd64-llp-alpine/docker_run.sh @@ -0,0 +1,25 @@ +#!/bin/sh -e + +# if DJANGO_DEBUG is defined, we'll run via django with dynamic reloading of +# code changes to disk. This is helpful for debugging something already in k8s + +if [ -z "$DJANGO_DEBUG" ] ; then + # Double quotes are important, otherwise docker strips the newlines + # These are set as a env in our playbook + echo "$secrets_file" >> /srv/secrets.py + echo "$allowed_hosts" >> /srv/allowed_hosts.txt + if [ ! -z "$html_header" ] ; then + echo "$html_header" >> /srv/header_override.html + fi + + if [ ! -z "$DJANGO_MIGRATE" ]; then + python $APPDIR/manage.py migrate --noinput + fi + if [ ! -z "$DJANGO_COLLECTSTATIC" ]; then + python $APPDIR/manage.py collectstatic --noinput + fi + + exec /usr/bin/gunicorn -w4 -b 0.0.0.0:$PORT $LLP_APP +fi + +exec python $APPDIR/manage.py runserver |