From 07fa3d88d5e56dd73b2a17f408ee391bbcfb2251 Mon Sep 17 00:00:00 2001 From: Ben Rometsch Date: Tue, 26 May 2020 18:36:15 +0100 Subject: [PATCH] more docker refactoring --- .gitignore | 2 ++ Dockerfile | 34 ++++++++++++++++++++-------------- bin/docker | 4 ++-- 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index 8cbb4a15f4ba..981265a803ef 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,5 @@ venv checkstyle.txt .python-version .env +.direnv +.envrc diff --git a/Dockerfile b/Dockerfile index a530d6c07228..60cf3246727f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,24 +1,30 @@ -FROM python:3.8 -ENV PYTHONUNBUFFERED 1 - -RUN rm /var/lib/dpkg/info/format -RUN printf "1\n" > /var/lib/dpkg/info/format -RUN dpkg --configure -a -RUN apt-get clean && apt-get update \ - && apt-get install -y --no-install-recommends \ - postgresql-client \ - && rm -rf /var/lib/apt/lists/* \ - && apt-get purge -y --auto-remove gcc +FROM python:3.8 as build + +#RUN rm /var/lib/dpkg/info/format +#RUN printf "1\n" > /var/lib/dpkg/info/format +#RUN dpkg --configure -a +#RUN apt-get clean && apt-get update \ +# && apt-get install -y --no-install-recommends \ +# postgresql-client \ +# && rm -rf /var/lib/apt/lists/* \ +# && apt-get purge -y --auto-remove gcc RUN pip install pipenv -RUN mkdir /app + +WORKDIR /app +COPY Pipfile Pipfile.lock /app/ +RUN bash -c 'PIPENV_VENV_IN_PROJECT=1 pipenv install' + + +FROM python:3.8-slim as application + WORKDIR /app +COPY --from=build /app /app/ -COPY src/ /app/ +COPY src/ /app/src/ COPY bin/ /app/bin/ COPY Pipfile* /app/ -RUN pipenv install ENV DJANGO_SETTINGS_MODULE=app.settings.master-docker EXPOSE 8000 diff --git a/bin/docker b/bin/docker index 5eeaa3ec955a..0b94a0ff04e0 100755 --- a/bin/docker +++ b/bin/docker @@ -1,5 +1,5 @@ #!/bin/bash set -e -pipenv run python /app/src/manage.py migrate -pipenv run python src/manage.py runserver 0.0.0.0:8000 +.venv/bin/python src/manage.py migrate +.venv/bin/python src/manage.py runserver 0.0.0.0:8000