-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
96 lines (78 loc) · 2.27 KB
/
Dockerfile
File metadata and controls
96 lines (78 loc) · 2.27 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
FROM alpine:3.21 AS builder
RUN apk add --no-cache \
curl \
gcc \
musl-dev \
postgresql-dev \
python3-dev \
py3-pip
ENV POETRY_HOME="/opt/poetry"
ENV POETRY_VIRTUALENVS_CREATE="false"
RUN curl -sSL "https://install.python-poetry.org" | \
python3 - --yes \
\
&& ln -s "${POETRY_HOME}/bin/poetry" /usr/local/bin/poetry \
\
&& rm -rf /root/.cache \
/root/.local
WORKDIR "/etc/happy"
COPY pyproject.toml ./
COPY poetry.lock ./
RUN poetry install --no-ansi \
--no-cache \
--no-root \
--with prod \
\
&& rm -rf /root/.cache
FROM alpine:3.21 AS runner
ARG LANGUAGE="C.UTF-8"
ENV LANG="${LANGUAGE}"
ENV LANGUAGE="${LANGUAGE}"
ENV LC_ALL="${LANGUAGE}"
ARG TIMEZONE="Etc/UTC"
ENV TZ="${TIMEZONE}"
RUN apk add --no-cache \
bash \
postgresql-client \
python3 \
su-exec \
tzdata \
\
&& ln -s /usr/bin/python3 /usr/local/bin/python3
RUN adduser -h /var/www \
-s /bin/bash \
-u 82 \
-G www-data \
-D \
\
www-data
COPY --from=builder /usr/lib/python3.12/site-packages /usr/lib/python3.12/site-packages
COPY --from=builder /usr/bin/uvicorn /usr/local/bin/uvicorn
WORKDIR "/opt/happy"
COPY src/ ./
RUN python -m compileall .
ENV DATA_VOLUME="/var/lib/happy"
ENV DEBUG=""
ENV SECRET_KEY=""
ENV PGHOST="host.docker.internal"
ENV PGPORT="5432"
ENV PGUSER="happy"
ENV PGPASSWORD=""
ENV PGDATABASE="happy"
ENTRYPOINT ["./entrypoint.sh"]
CMD ["uvicorn"]
EXPOSE 8000
VOLUME ["${DATA_VOLUME}"]
ARG VERSION
ARG COMMIT_SHA
ARG CREATE_DATE
LABEL org.opencontainers.image.title="Happy"
LABEL org.opencontainers.image.description="A template of a ready-to-use dockerized Django application."
LABEL org.opencontainers.image.licenses="Apache-2.0"
LABEL org.opencontainers.image.version="${VERSION}"
LABEL org.opencontainers.image.revision="${COMMIT_SHA}"
LABEL org.opencontainers.image.source="https://github.com/Byloth/django-docker-template"
LABEL org.opencontainers.image.url="https://github.com/Byloth/django-docker-template"
LABEL org.opencontainers.image.authors="Matteo Bilotta <me@byloth.dev>"
LABEL org.opencontainers.image.vendor="Bylothink"
LABEL org.opencontainers.image.created="${CREATE_DATE}"