-
Notifications
You must be signed in to change notification settings - Fork 36
/
Dockerfile
58 lines (55 loc) · 1.62 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
FROM python:3.11.8-bookworm AS builder
ENV PIP_NO_CACHE_DIR=1 \
PYTHONUNBUFFERED=1
RUN apt-get update --yes --quiet \
&& apt-get install --yes --quiet --no-install-recommends \
build-essential \
gettext \
git \
libpango1.0-0 \
libpq-dev \
libpq5 \
&& pip install --upgrade pip \
&& pip install pip-tools \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /opt
RUN python -m venv venv
ENV PATH="/opt/venv/bin:$PATH"
RUN pip install --upgrade pip
ARG requirements=requirements.txt
COPY ${requirements} .
RUN pip install -r $requirements
FROM python:3.11.8-slim-bookworm AS base
EXPOSE 8000
ENV PATH="/opt/venv/bin:$PATH" \
PIP_NO_CACHE_DIR=1 \
PYTHONUNBUFFERED=1
RUN useradd wagtail
RUN apt-get update --yes --quiet \
&& apt-get install --yes --quiet --no-install-recommends \
gettext \
libpango1.0-0 \
libpq5 \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
RUN chown wagtail:wagtail /app
FROM base AS dev
RUN apt-get update --yes --quiet \
&& apt-get install --yes --quiet --no-install-recommends \
tini \
&& rm -rf /var/lib/apt/lists/*
COPY --from=builder --chown=wagtail:wagtail /opt/venv /opt/venv
COPY --chown=wagtail:wagtail . .
USER wagtail
ENTRYPOINT ["tini", "--"]
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
FROM base AS prod
# PORT variable is used by Gunicorn. Should match "EXPOSE" command.
ENV PORT=8000
USER wagtail
COPY --from=builder --chown=wagtail:wagtail /opt/venv /opt/venv
RUN pip install "gunicorn==20.0.4"
COPY --chown=wagtail:wagtail . .
RUN python manage.py collectstatic --noinput --clear
RUN python manage.py compilemessages
CMD ["gunicorn", "iogt.wsgi:application"]