2023-12-10 12:12:24 +00:00
|
|
|
FROM alpine:3.19 as requirements
|
2022-03-01 18:59:17 +00:00
|
|
|
|
2022-12-19 20:49:13 +00:00
|
|
|
RUN set -eux; \
|
|
|
|
apk add --no-cache \
|
|
|
|
poetry \
|
|
|
|
py3-cryptography \
|
|
|
|
py3-pip \
|
|
|
|
python3
|
2022-03-01 18:59:17 +00:00
|
|
|
|
2022-12-19 20:49:13 +00:00
|
|
|
COPY pyproject.toml poetry.lock /
|
|
|
|
RUN set -eux; \
|
2023-05-17 15:48:02 +00:00
|
|
|
poetry export --without-hashes --extras typesense > requirements.txt; \
|
2022-12-19 20:49:13 +00:00
|
|
|
poetry export --without-hashes --with dev > dev-requirements.txt;
|
2022-11-09 18:58:58 +00:00
|
|
|
|
2023-12-10 12:12:24 +00:00
|
|
|
FROM alpine:3.19 as builder
|
2017-06-23 21:00:42 +00:00
|
|
|
|
2023-01-11 15:21:16 +00:00
|
|
|
ENV PYTHONDONTWRITEBYTECODE=1
|
2023-01-11 15:24:51 +00:00
|
|
|
ENV PYTHONUNBUFFERED=1
|
2023-01-11 15:43:32 +00:00
|
|
|
ARG PIP_NO_CACHE_DIR=1
|
2023-08-28 13:13:09 +00:00
|
|
|
ENV CARGO_NET_GIT_FETCH_WITH_CLI=true
|
2023-01-11 15:21:16 +00:00
|
|
|
|
2023-01-11 16:10:30 +00:00
|
|
|
RUN set -eux; \
|
|
|
|
apk add --no-cache \
|
|
|
|
cargo \
|
|
|
|
curl \
|
|
|
|
gcc \
|
2023-09-28 07:43:14 +00:00
|
|
|
g++ \
|
2023-01-11 16:10:30 +00:00
|
|
|
git \
|
|
|
|
jpeg-dev \
|
|
|
|
libffi-dev \
|
|
|
|
libldap \
|
|
|
|
libxml2-dev \
|
|
|
|
libxslt-dev \
|
|
|
|
make \
|
|
|
|
musl-dev \
|
|
|
|
openldap-dev \
|
|
|
|
openssl-dev \
|
|
|
|
postgresql-dev \
|
|
|
|
zlib-dev \
|
2023-12-11 13:30:43 +00:00
|
|
|
py3-cryptography=41.0.7-r0 \
|
2023-07-20 11:00:40 +00:00
|
|
|
py3-lxml=4.9.3-r1 \
|
2024-01-30 16:05:15 +00:00
|
|
|
py3-pillow=10.2.0-r0 \
|
2023-12-11 13:30:43 +00:00
|
|
|
py3-psycopg2=2.9.9-r0 \
|
|
|
|
py3-watchfiles=0.19.0-r1 \
|
2023-01-11 16:10:30 +00:00
|
|
|
python3-dev
|
2019-01-11 12:50:42 +00:00
|
|
|
|
2022-12-19 20:49:13 +00:00
|
|
|
# Create virtual env
|
2023-01-13 14:22:05 +00:00
|
|
|
RUN python3 -m venv --system-site-packages /venv
|
2023-01-20 16:18:40 +00:00
|
|
|
ENV PATH="/venv/bin:$PATH"
|
2020-03-09 16:04:06 +00:00
|
|
|
|
2023-02-12 12:53:42 +00:00
|
|
|
COPY --from=requirements /requirements.txt /requirements.txt
|
|
|
|
COPY --from=requirements /dev-requirements.txt /dev-requirements.txt
|
2017-06-23 21:00:42 +00:00
|
|
|
|
2023-07-20 12:09:17 +00:00
|
|
|
RUN --mount=type=cache,target=~/.cache/pip; \
|
|
|
|
set -eux; \
|
2023-01-11 15:55:30 +00:00
|
|
|
pip3 install --upgrade pip; \
|
|
|
|
pip3 install setuptools wheel; \
|
|
|
|
# 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
|
|
|
|
# to install the deps using pip.
|
|
|
|
grep -Ev 'cryptography|lxml|pillow|psycopg2|watchfiles' /requirements.txt \
|
|
|
|
| pip3 install -r /dev/stdin \
|
2023-12-11 13:30:43 +00:00
|
|
|
cryptography==41.0.7 \
|
2023-07-20 11:00:40 +00:00
|
|
|
lxml==4.9.3 \
|
2024-01-30 16:05:15 +00:00
|
|
|
pillow==10.2.0 \
|
2023-12-11 13:30:43 +00:00
|
|
|
psycopg2==2.9.9 \
|
|
|
|
watchfiles==0.19.0
|
2017-06-23 21:00:42 +00:00
|
|
|
|
2023-01-11 15:55:30 +00:00
|
|
|
ARG install_dev_deps=0
|
2023-07-20 12:09:17 +00:00
|
|
|
RUN --mount=type=cache,target=~/.cache/pip; \
|
2023-07-20 13:06:52 +00:00
|
|
|
set -eux; \
|
2023-01-11 15:55:30 +00:00
|
|
|
if [ "$install_dev_deps" = "1" ] ; then \
|
2023-07-20 11:00:40 +00:00
|
|
|
grep -Ev 'cryptography|lxml|pillow|psycopg2|watchfiles' /dev-requirements.txt \
|
|
|
|
| pip3 install -r /dev/stdin \
|
2024-01-30 16:05:15 +00:00
|
|
|
cryptography==41.0.7 \
|
2023-07-20 11:00:40 +00:00
|
|
|
lxml==4.9.3 \
|
2024-01-30 16:05:15 +00:00
|
|
|
pillow==10.2.0 \
|
2023-12-11 13:30:43 +00:00
|
|
|
psycopg2==2.9.9 \
|
|
|
|
watchfiles==0.19.0; \
|
2023-01-11 15:55:30 +00:00
|
|
|
fi
|
2020-03-09 16:04:06 +00:00
|
|
|
|
2023-12-10 12:12:24 +00:00
|
|
|
FROM alpine:3.19 as production
|
2020-03-09 16:04:06 +00:00
|
|
|
|
2023-01-11 15:21:16 +00:00
|
|
|
ENV PYTHONDONTWRITEBYTECODE=1
|
2023-01-11 15:24:51 +00:00
|
|
|
ENV PYTHONUNBUFFERED=1
|
2023-01-11 15:43:32 +00:00
|
|
|
ARG PIP_NO_CACHE_DIR=1
|
2023-01-11 15:21:16 +00:00
|
|
|
|
2023-01-11 16:10:30 +00:00
|
|
|
RUN set -eux; \
|
|
|
|
apk add --no-cache \
|
|
|
|
bash \
|
|
|
|
ffmpeg \
|
|
|
|
gettext \
|
|
|
|
jpeg-dev \
|
|
|
|
libldap \
|
|
|
|
libmagic \
|
|
|
|
libpq \
|
|
|
|
libxml2 \
|
|
|
|
libxslt \
|
2023-12-11 13:30:43 +00:00
|
|
|
py3-cryptography=41.0.7-r0 \
|
2023-07-20 11:00:40 +00:00
|
|
|
py3-lxml=4.9.3-r1 \
|
2024-01-30 16:05:15 +00:00
|
|
|
py3-pillow=10.2.0-r0 \
|
2023-12-11 13:30:43 +00:00
|
|
|
py3-psycopg2=2.9.9-r0 \
|
|
|
|
py3-watchfiles=0.19.0-r1 \
|
2023-04-26 17:49:42 +00:00
|
|
|
python3 \
|
|
|
|
tzdata
|
2020-03-09 16:04:06 +00:00
|
|
|
|
2023-01-11 16:13:03 +00:00
|
|
|
COPY --from=builder /venv /venv
|
|
|
|
ENV PATH="/venv/bin:$PATH"
|
|
|
|
|
2021-09-12 11:33:52 +00:00
|
|
|
COPY . /app
|
|
|
|
WORKDIR /app
|
|
|
|
|
2023-07-20 12:09:17 +00:00
|
|
|
RUN --mount=type=cache,target=~/.cache/pip; \
|
2023-07-20 13:06:52 +00:00
|
|
|
set -eux; \
|
2023-01-11 15:45:20 +00:00
|
|
|
pip3 install --no-deps --editable .
|
|
|
|
|
2023-01-20 17:03:46 +00:00
|
|
|
ENV IS_DOCKER_SETUP=true
|
2022-07-16 18:16:13 +00:00
|
|
|
|
2022-12-23 14:44:45 +00:00
|
|
|
CMD ["./docker/server.sh"]
|