2022-06-11 21:05:46 +00:00
|
|
|
FROM alpine:3.16 as pre-build
|
2022-03-01 18:59:17 +00:00
|
|
|
|
|
|
|
# We need this additional step to avoid having poetrys deps interacting with our
|
|
|
|
# dependencies. This is only required until alpine 3.16 is released, since this
|
|
|
|
# allows us to install poetry as package.
|
|
|
|
|
2022-06-11 21:57:17 +00:00
|
|
|
RUN apk add --no-cache python3 py3-cryptography py3-pip poetry
|
2022-03-01 18:59:17 +00:00
|
|
|
COPY pyproject.toml poetry.lock /
|
|
|
|
RUN poetry export --without-hashes > requirements.txt
|
|
|
|
RUN poetry export --dev --without-hashes > dev-requirements.txt
|
|
|
|
|
2022-11-09 18:58:58 +00:00
|
|
|
|
2022-06-11 21:05:46 +00:00
|
|
|
FROM alpine:3.16 as builder
|
2017-06-23 21:00:42 +00:00
|
|
|
|
2019-01-21 12:54:46 +00:00
|
|
|
RUN \
|
|
|
|
echo 'installing dependencies' && \
|
2021-09-12 11:33:52 +00:00
|
|
|
apk add --no-cache \
|
|
|
|
git \
|
|
|
|
musl-dev \
|
2019-01-21 12:54:46 +00:00
|
|
|
gcc \
|
|
|
|
postgresql-dev \
|
2021-09-12 11:33:52 +00:00
|
|
|
python3-dev \
|
|
|
|
py3-psycopg2 \
|
2021-12-13 19:31:13 +00:00
|
|
|
py3-cryptography \
|
2021-09-12 11:33:52 +00:00
|
|
|
libldap \
|
|
|
|
libffi-dev \
|
|
|
|
make \
|
|
|
|
zlib-dev \
|
|
|
|
jpeg-dev \
|
2020-02-04 10:43:08 +00:00
|
|
|
openldap-dev \
|
2021-05-28 09:39:27 +00:00
|
|
|
openssl-dev \
|
|
|
|
cargo \
|
2021-06-30 15:41:12 +00:00
|
|
|
libxml2-dev \
|
|
|
|
libxslt-dev \
|
2022-01-19 14:15:50 +00:00
|
|
|
curl \
|
2020-02-02 08:43:54 +00:00
|
|
|
&& \
|
2022-03-01 18:59:17 +00:00
|
|
|
ln -s /usr/bin/python3 /usr/bin/python
|
2019-01-11 12:50:42 +00:00
|
|
|
|
2020-03-09 16:04:06 +00:00
|
|
|
# create virtual env for next stage
|
2021-12-13 19:31:13 +00:00
|
|
|
RUN python -m venv --system-site-packages /venv
|
2020-03-09 16:04:06 +00:00
|
|
|
# emulate activation by prefixing PATH
|
2022-01-19 14:15:50 +00:00
|
|
|
ENV PATH="/venv/bin:/root/.local/bin:$PATH" VIRTUAL_ENV=/venv
|
2020-03-09 16:04:06 +00:00
|
|
|
|
2022-07-10 17:31:37 +00:00
|
|
|
COPY --from=pre-build /requirements.txt /requirements.txt
|
|
|
|
COPY --from=pre-build /dev-requirements.txt /dev-requirements.txt
|
2019-01-24 10:04:29 +00:00
|
|
|
# hack around https://github.com/pypa/pip/issues/6158#issuecomment-456619072
|
2022-11-09 18:58:58 +00:00
|
|
|
ARG PIP_DOWNLOAD_CACHE=/noop/
|
2019-01-21 12:54:46 +00:00
|
|
|
RUN \
|
|
|
|
echo 'installing pip requirements' && \
|
2022-01-19 14:15:50 +00:00
|
|
|
pip3 install --upgrade pip && \
|
2019-01-24 10:04:29 +00:00
|
|
|
pip3 install setuptools wheel && \
|
2022-11-01 14:01:46 +00:00
|
|
|
# Currently we are unable to relieably build rust-based packages on armv7. This
|
|
|
|
# is why we need to use the packages shipped by Alpine Linux.
|
|
|
|
# Since poetry does not allow in-place dependency pinning, we need
|
2022-01-12 13:06:15 +00:00
|
|
|
# to install the deps using pip.
|
2022-11-09 18:58:58 +00:00
|
|
|
grep -Ev 'cryptography|uvicorn|watchgod|watchfiles' /requirements.txt | pip3 install -r /dev/stdin cryptography==3.4.8 uvicorn==0.17.6 watchgod==0.8.2 && \
|
|
|
|
rm -rf "$PIP_DOWNLOAD_CACHE"
|
2017-06-23 21:00:42 +00:00
|
|
|
|
2019-01-21 12:54:46 +00:00
|
|
|
ARG install_dev_deps=0
|
|
|
|
RUN \
|
2022-01-10 14:48:38 +00:00
|
|
|
if [ "$install_dev_deps" = "1" ] ; then \
|
|
|
|
echo "Installing dev dependencies" && \
|
2022-11-09 18:58:58 +00:00
|
|
|
grep -Ev 'cryptography|uvicorn|watchgod|watchfiles' /dev-requirements.txt | pip3 install -r /dev/stdin cryptography==3.4.8 uvicorn==0.17.6 watchgod==0.8.2 && \
|
|
|
|
rm -rf "$PIP_DOWNLOAD_CACHE" \
|
|
|
|
; else \
|
2022-01-10 14:48:38 +00:00
|
|
|
echo "Skipping dev deps installation" \
|
|
|
|
; fi
|
2017-06-23 21:00:42 +00:00
|
|
|
|
2020-03-09 16:04:06 +00:00
|
|
|
|
2022-11-09 18:58:58 +00:00
|
|
|
FROM alpine:3.16 as image
|
2020-03-09 16:04:06 +00:00
|
|
|
|
|
|
|
COPY --from=builder /venv /venv
|
|
|
|
# emulate activation by prefixing PATH
|
|
|
|
ENV PATH="/venv/bin:$PATH"
|
|
|
|
|
|
|
|
RUN apk add --no-cache \
|
|
|
|
libmagic \
|
2021-09-12 11:33:52 +00:00
|
|
|
bash \
|
|
|
|
gettext \
|
|
|
|
python3 \
|
2020-03-09 16:04:06 +00:00
|
|
|
jpeg-dev \
|
2021-09-12 11:33:52 +00:00
|
|
|
ffmpeg \
|
|
|
|
libpq \
|
2021-06-30 15:41:12 +00:00
|
|
|
libxml2 \
|
|
|
|
libxslt \
|
2021-12-13 19:31:13 +00:00
|
|
|
py3-cryptography \
|
2022-06-20 20:56:28 +00:00
|
|
|
libldap \
|
2020-03-09 16:04:06 +00:00
|
|
|
&& \
|
|
|
|
ln -s /usr/bin/python3 /usr/bin/python
|
|
|
|
|
2021-09-12 11:33:52 +00:00
|
|
|
COPY . /app
|
|
|
|
WORKDIR /app
|
|
|
|
|
2021-09-20 10:42:41 +00:00
|
|
|
RUN find . -type d -exec chmod 755 {} \+
|
2020-03-09 16:04:06 +00:00
|
|
|
|
2022-07-16 18:16:13 +00:00
|
|
|
ENV CACHE_URL="redis://redis:6379/0"
|
|
|
|
ENV CELERY_BROKER_URL="redis://redis:6379/0"
|
|
|
|
|
2017-06-23 21:00:42 +00:00
|
|
|
ENTRYPOINT ["./compose/django/entrypoint.sh"]
|
2019-06-19 08:26:09 +00:00
|
|
|
CMD ["./compose/django/server.sh"]
|