This repository has been archived by the owner on Nov 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Dockerfile
75 lines (53 loc) · 1.63 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
66
67
68
69
70
71
72
73
74
75
FROM python:3.12-alpine AS builder
ENV PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1 \
POETRY_VERSION=1.8.3 \
POETRY_HOME="/opt/poetry" \
POETRY_VIRTUALENVS_CREATE=false \
PATH="$PATH:/opt/poetry/bin"
RUN apk add --no-cache \
gcc \
musl-dev \
libffi-dev \
&& pip install --no-cache-dir "poetry==$POETRY_VERSION"
WORKDIR /app
COPY pyproject.toml poetry.lock ./
RUN poetry export -f requirements.txt --output requirements.txt --only main --without-hashes \
&& pip install --no-cache-dir -r requirements.txt
FROM python:3.12-alpine AS development
ENV PYTHONUNBUFFERED=1 \
POETRY_VERSION=1.8.3
RUN apk add --no-cache \
gcc \
musl-dev \
libffi-dev \
openssl \
openssh \
postgresql-client \
git \
&& pip install --no-cache-dir "poetry==$POETRY_VERSION"
WORKDIR /app
COPY --from=builder /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
COPY . .
RUN poetry config virtualenvs.create false \
&& poetry install --no-root --with dev
ARG GUNICORN_PORT=8080
ENV EXPOSE_PORT=${GUNICORN_PORT}
EXPOSE ${EXPOSE_PORT}
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
CMD ["/bin/sh"]
FROM python:3.12-alpine AS production
ENV PYTHONUNBUFFERED=1
RUN apk add --no-cache \
openssl \
postgresql-client
WORKDIR /app
COPY --from=builder /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
COPY . .
ARG GUNICORN_PORT=8080
ENV EXPOSE_PORT=${GUNICORN_PORT}
EXPOSE ${EXPOSE_PORT}
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]