mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2025-08-15 09:24:52 +03:00
Making docs file smaller by around 40% using multi-stage builds
This commit is contained in:
parent
33eca9d121
commit
8d6c4387ba
|
@ -1,28 +1,58 @@
|
||||||
|
FROM python:3.8-slim-buster as build_stage
|
||||||
|
|
||||||
|
ENV PYTHONUNBUFFERED 1
|
||||||
|
ENV PYTHONDONTWRITEBYTECODE 1
|
||||||
|
|
||||||
|
# Requirements are installed here to ensure they will be cached.
|
||||||
|
COPY ./requirements /requirements
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get install --no-install-recommends -y \
|
||||||
|
# dependencies for building Python packages
|
||||||
|
build-essential \
|
||||||
|
# psycopg2 dependencies
|
||||||
|
libpq-dev \
|
||||||
|
# Translations dependencies
|
||||||
|
gettext \
|
||||||
|
# Uncomment below lines to enable Sphinx output to latex and pdf
|
||||||
|
# texlive-latex-recommended \
|
||||||
|
# texlive-fonts-recommended \
|
||||||
|
# texlive-latex-extra \
|
||||||
|
# latexmk \
|
||||||
|
# cleaning up unused files
|
||||||
|
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
|
||||||
|
&& rm -rf /var/lib/apt/lists/* \
|
||||||
|
# install python dependencies
|
||||||
|
&& pip install --no-cache-dir --use-feature=2020-resolver -r /requirements/local.txt -r /requirements/production.txt \
|
||||||
|
&& rm -rf /requirements
|
||||||
|
|
||||||
|
|
||||||
FROM python:3.8-slim-buster
|
FROM python:3.8-slim-buster
|
||||||
|
|
||||||
ENV PYTHONUNBUFFERED 1
|
ENV PYTHONUNBUFFERED 1
|
||||||
ENV PYTHONDONTWRITEBYTECODE 1
|
ENV PYTHONDONTWRITEBYTECODE 1
|
||||||
|
|
||||||
RUN apt-get update \
|
|
||||||
|
RUN apt-get update && apt-get install --no-install-recommends -y \
|
||||||
# dependencies for building Python packages
|
# dependencies for building Python packages
|
||||||
&& apt-get install -y build-essential \
|
build-essential \
|
||||||
# psycopg2 dependencies
|
# psycopg2 dependencies
|
||||||
&& apt-get install -y libpq-dev \
|
libpq-dev \
|
||||||
# Translations dependencies
|
# Translations dependencies
|
||||||
&& apt-get install -y gettext \
|
gettext \
|
||||||
# Uncomment below lines to enable Sphinx output to latex and pdf
|
# Uncomment below lines to enable Sphinx output to latex and pdf
|
||||||
# && apt-get install -y texlive-latex-recommended \
|
# texlive-latex-recommended \
|
||||||
# && apt-get install -y texlive-fonts-recommended \
|
# texlive-fonts-recommended \
|
||||||
# && apt-get install -y texlive-latex-extra \
|
# texlive-latex-extra \
|
||||||
# && apt-get install -y latexmk \
|
# latexmk \
|
||||||
# cleaning up unused files
|
# cleaning up unused files
|
||||||
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
|
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Requirements are installed here to ensure they will be cached.
|
|
||||||
COPY ./requirements /requirements
|
# copy python dependencies from python-build-stage
|
||||||
# All imports needed for autodoc.
|
COPY --from=build_stage /usr/local/lib/python3.8/site-packages/ /usr/local/lib/python3.8/site-packages/
|
||||||
RUN pip install -r /requirements/local.txt -r /requirements/production.txt
|
COPY --from=build_stage /usr/local/bin/ /usr/local/bin/
|
||||||
|
|
||||||
|
|
||||||
WORKDIR /docs
|
WORKDIR /docs
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user