-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
65 lines (47 loc) · 1.79 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
62
63
64
65
# ======================= BASE IMAGE ======================================================
FROM alpine:3.19 as builder
ENV PYTHONUNBUFFERED True
RUN apk add --no-cache \
python3 postgresql-libs icu-libs libpq \
py3-pip py3-wheel libffi \
gettext mailcap \
&& apk add --no-cache --virtual .build-deps \
build-base \
python3-dev \
postgresql-dev \
linux-headers libffi-dev
COPY poetry.lock pyproject.toml ./
RUN pip install --break-system-packages poetry poetry-plugin-export \
&& poetry export --without dev --without-hashes -o requirements.txt \
&& poetry export --only dev --without-hashes -o requirements-dev.txt
# ======================== APP IMAGE =======================================================
FROM alpine:3.19 as main
ENV PYTHONUNBUFFERED True
ENV APP_HOME /app
ENV USER web-user
RUN addgroup -S $USER -g 1000 && adduser -S $USER -G $USER -u 1000
WORKDIR $APP_HOME
COPY --from=builder --chown=$USER requirements.txt $APP_HOME/
RUN apk add --no-cache \
python3 \
postgresql-libs icu-libs libpq \
py3-pip \
py3-wheel \
gettext \
mailcap libffi \
&& apk add --no-cache --virtual .build-deps \
build-base \
python3-dev \
postgresql-dev \
linux-headers libffi-dev \
&& pip install --break-system-packages --no-cache-dir -r requirements.txt \
&& apk del .build-deps \
&& rm -rf /root/.cache/ \
&& chown -R $USER:$USER $APP_HOME
COPY --chown=$USER . $APP_HOME/
USER $USER
RUN python3 manage.py compilemessages -i venv \
&& python3 manage.py collectstatic --no-input
EXPOSE 8000
STOPSIGNAL SIGINT
CMD exec uwsgi --ini uwsgi.ini