-
Notifications
You must be signed in to change notification settings - Fork 10
/
Dockerfile
61 lines (40 loc) · 1.55 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
FROM python:3.10-slim AS base
ENV DJANGO_SETTINGS_MODULE=alexandria.settings.django \
PYTHONFAULTHANDLER=1 \
PYTHONHASHSEED=random \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=off \
PIP_DISABLE_PIP_VERSION_CHECK=on \
PIP_DEFAULT_TIMEOUT=100
RUN \
--mount=type=cache,target=/var/cache/apt \
apt-get update && apt-get install -y --no-install-recommends \
build-essential libpq-dev wait-for-it \
# Default dependencies for preview-generator
ghostscript imagemagick libfile-mimeinfo-perl libimage-exiftool-perl \
libjpeg-dev libmagic1 libsecret-1-0 poppler-utils webp zlib1g-dev \
# Extra dependencies for preview-generator to support office, vector and video files
ffmpeg inkscape libreoffice \
&& rm -rf /var/lib/apt/lists/* \
&& useradd -m -r -u 1001 alexandria
EXPOSE 8000
FROM base AS build
WORKDIR /app
COPY . ./
ENV POETRY_NO_INTERACTION=1
RUN pip install -U poetry
FROM build AS wheel
WORKDIR /app
RUN poetry build -f wheel && mv ./dist/*.whl /tmp/
FROM build AS dev
RUN poetry config virtualenvs.create false \
&& poetry install
USER 1001
CMD ["sh", "-c", "wait-for-it db:5432 -- ./manage.py migrate && ./manage.py runserver_plus --nostatic 0.0.0.0:8000"]
FROM base AS prod
WORKDIR /app
COPY manage.py /usr/local/bin
COPY --from=wheel /tmp/*.whl /tmp/
RUN pip install /tmp/*.whl && rm /tmp/*.whl
USER 1001
CMD ["sh", "-c", "wait-for-it $DATABASE_HOST:${DATABASE_PORT:-5432} -- ./manage.py migrate && gunicorn --workers 10 --access-logfile - --limit-request-line 16384 --bind :8000 alexandria.wsgi"]