From 22d579c2b21cf380008edb896fa347f77d288e6e Mon Sep 17 00:00:00 2001 From: Rob Beal Date: Wed, 4 Oct 2017 11:40:37 +0100 Subject: [PATCH 1/3] Improve layering of the Dockerfile (reduces image size from ~400mb to ~220mb) --- Dockerfile | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index cf1963d..c329202 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,23 +1,33 @@ -FROM alpine:latest +FROM alpine:3.6 + +WORKDIR /tmp +COPY ./requirements/prod.txt requirements.txt # Install Python RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \ - && apk add --update \ - bash \ + && apk add --update --no-cache --virtual=build-dependencies \ build-base \ - git \ libffi-dev \ musl \ + python-dev \ + postgresql-dev \ + && apk add --update \ + bash \ + git \ nodejs \ nodejs-npm \ - postgresql-dev \ py2-pip \ python \ - python-dev \ redis \ runit \ + && pip install --upgrade pip \ && npm install -g bower less \ + && pip install -r /tmp/requirements.txt \ + && pip install 'gunicorn==19.6.0' \ + + # clean up + && apk del --purge build-dependencies \ && rm /var/cache/apk/* # Make some useful symlinks that are expected to exist @@ -27,11 +37,6 @@ RUN cd /usr/bin \ && ln -sf python2.7-config python-config \ && ln -sf pip2.7 pip -# Copy and install our requirements first, so they can be cached -COPY ./requirements/prod.txt /tmp/requirements.txt -RUN pip install -r /tmp/requirements.txt \ - && pip install 'gunicorn==19.6.0' - # Add our application to the container COPY . /src/ From a488851b3ed5bc9d1690a6d70ffd7d6e858722f3 Mon Sep 17 00:00:00 2001 From: Rob Beal Date: Wed, 4 Oct 2017 13:39:44 +0100 Subject: [PATCH 2/3] Clean the /tmp directory after installing dependencies --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index c329202..924685e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,7 +28,8 @@ RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repos # clean up && apk del --purge build-dependencies \ - && rm /var/cache/apk/* + && rm /var/cache/apk/* \ + && rm -rf /tmp/* # Make some useful symlinks that are expected to exist RUN cd /usr/bin \ From 71f5412481a7668255bd7e68813e35c9ede974f7 Mon Sep 17 00:00:00 2001 From: Rob Beal Date: Tue, 24 Oct 2017 10:17:38 +0100 Subject: [PATCH 3/3] Fixes #132: Update the example docker command with correct env variable name --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2bd28a7..ef944ac 100644 --- a/README.md +++ b/README.md @@ -234,8 +234,8 @@ $ docker run \ -e DOORMAN_SECRET_KEY=secret-key \ -e POSTGRES_USER=doorman \ -e POSTGRES_PASSWORD=pass \ - -e POSTGRES_ENV_POSTGRES_PORT=your-host-here \ - -p host-port:5000 \ + -e POSTGRES_PORT=5432 \ + -p 5000:5000 \ doorman ```