2021-12-24 14:55:47 +03:00
|
|
|
ARG PYTHON_VERSION=3.9-slim-bullseye
|
|
|
|
|
|
|
|
# define an alias for the specfic python version used in this file.
|
|
|
|
FROM python:${PYTHON_VERSION} as python
|
|
|
|
|
|
|
|
|
|
|
|
# Python build stage
|
|
|
|
FROM python as python-build-stage
|
2020-04-24 17:23:41 +03:00
|
|
|
|
|
|
|
ENV PYTHONDONTWRITEBYTECODE 1
|
|
|
|
|
2021-12-24 14:55:47 +03:00
|
|
|
RUN apt-get update && apt-get install --no-install-recommends -y \
|
|
|
|
# dependencies for building Python packages
|
|
|
|
build-essential \
|
|
|
|
# psycopg2 dependencies
|
|
|
|
libpq-dev \
|
|
|
|
# cleaning up unused files
|
|
|
|
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
|
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
2020-04-24 17:23:41 +03:00
|
|
|
|
|
|
|
# Requirements are installed here to ensure they will be cached.
|
|
|
|
COPY ./requirements /requirements
|
2021-12-24 14:55:47 +03:00
|
|
|
|
|
|
|
# create python dependency wheels
|
|
|
|
RUN pip wheel --no-cache-dir --no-deps --wheel-dir /usr/src/app/wheels \
|
|
|
|
-r /requirements/local.txt -r /requirements/production.txt \
|
|
|
|
&& rm -rf /requirements
|
|
|
|
|
|
|
|
|
|
|
|
# Python 'run' stage
|
|
|
|
FROM python as python-run-stage
|
|
|
|
|
|
|
|
ARG BUILD_ENVIRONMENT
|
|
|
|
ENV PYTHONUNBUFFERED 1
|
|
|
|
ENV PYTHONDONTWRITEBYTECODE 1
|
|
|
|
|
|
|
|
RUN apt-get update && apt-get install --no-install-recommends -y \
|
|
|
|
# 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/*
|
|
|
|
|
|
|
|
# copy python dependency wheels from python-build-stage
|
|
|
|
COPY --from=python-build-stage /usr/src/app/wheels /wheels
|
|
|
|
|
|
|
|
# use wheels to install python dependencies
|
|
|
|
RUN pip install --no-cache /wheels/* \
|
|
|
|
&& rm -rf /wheels
|
2020-04-24 17:23:41 +03:00
|
|
|
|
2020-11-04 20:17:02 +03:00
|
|
|
COPY ./compose/local/docs/start /start-docs
|
|
|
|
RUN sed -i 's/\r$//g' /start-docs
|
|
|
|
RUN chmod +x /start-docs
|
2020-04-24 17:23:41 +03:00
|
|
|
|
2020-11-04 20:17:02 +03:00
|
|
|
WORKDIR /docs
|