diff --git a/{{cookiecutter.project_slug}}/compose/local/django/Dockerfile b/{{cookiecutter.project_slug}}/compose/local/django/Dockerfile index 5c3e3f1a..a7cf54ae 100644 --- a/{{cookiecutter.project_slug}}/compose/local/django/Dockerfile +++ b/{{cookiecutter.project_slug}}/compose/local/django/Dockerfile @@ -15,8 +15,8 @@ RUN apt-get update && apt-get install --no-install-recommends -y \ # cleaning up unused files && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \ && rm -rf /var/lib/apt/lists/* \ - # create python dependency wheels - && pip wheel --no-cache-dir --no-deps --use-feature=2020-resolver --wheel-dir /usr/src/app/wheels -r /requirements/local.txt \ + # install python dependencies + && pip install --no-cache-dir --use-feature=2020-resolver -r /requirements/local.txt \ && rm -rf /requirements @@ -61,11 +61,10 @@ RUN apt-get update && apt-get install --no-install-recommends -y \ && rm -rf /var/lib/apt/lists/* -# copy python dependency wheels from python-build-stage -COPY --from=python-build-stage /usr/src/app/wheels /wheels -# install python dependencies -RUN pip install --no-cache /wheels/* +# copy python dependencies from python-build-stage +COPY --from=build_stage /usr/local/lib/python3.8/site-packages/ /usr/local/lib/python3.8/site-packages/ +COPY --from=build_stage /usr/local/bin/ /usr/local/bin/ diff --git a/{{cookiecutter.project_slug}}/compose/production/django/Dockerfile b/{{cookiecutter.project_slug}}/compose/production/django/Dockerfile index 9fd75f7e..15708dcd 100644 --- a/{{cookiecutter.project_slug}}/compose/production/django/Dockerfile +++ b/{{cookiecutter.project_slug}}/compose/production/django/Dockerfile @@ -11,7 +11,7 @@ RUN npm run build # Python build stage FROM python:3.8-slim-buster as python-build-stage - +ENV PYTHONDONTWRITEBYTECODE 1 # Requirements are installed here to ensure they will be cached. COPY ./requirements /requirements @@ -26,14 +26,15 @@ RUN apt-get update && apt-get install --no-install-recommends -y \ # cleaning up unused files && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \ && rm -rf /var/lib/apt/lists/* \ - # create python dependency wheels - && pip wheel --no-cache-dir --no-deps --use-feature=2020-resolver --wheel-dir /usr/src/app/wheels -r /requirements/production.txt \ + # install python dependencies + && pip install --no-cache-dir --use-feature=2020-resolver -r /requirements/production.txt \ && rm -rf /requirements # Python 'run' stage FROM python:3.8-slim-buster +ENV PYTHONDONTWRITEBYTECODE 1 ENV PYTHONUNBUFFERED 1 RUN addgroup --system django \ @@ -76,11 +77,9 @@ RUN apt-get update && apt-get install --no-install-recommends -y \ && rm -rf /var/lib/apt/lists/* -# copy python dependency wheels from python-build-stage -COPY --from=python-build-stage /usr/src/app/wheels /wheels - -# install python dependencies -RUN pip install --no-cache /wheels/* +# copy python dependencies from python-build-stage +COPY --from=build_stage /usr/local/lib/python3.8/site-packages/ /usr/local/lib/python3.8/site-packages/ +COPY --from=build_stage /usr/local/bin/ /usr/local/bin/ {%- if cookiecutter.js_task_runner == 'Gulp' %} COPY --from=client-builder --chown=django:django /app /app