-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
83 lines (62 loc) · 1.9 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
76
77
78
79
80
81
FROM python:3.12-alpine as base
ENV PYTHONUNBUFFERED 1
ENV PYTHONDONTWRITEBYTECODE 1
RUN apk add --update --virtual .build-deps \
build-base \
postgresql-dev \
python3-dev \
libpq \
libpq-dev \
libffi-dev
WORKDIR /app
COPY ./pyproject.toml /app/pyproject.toml
RUN pip install --upgrade pip && \
pip install .
#---------------------------Dev Build------------------------#
FROM python:3.12-alpine as dev
ARG USERNAME=appuser
ARG USER_UID=1000
ARG USER_GID=$USER_UID
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
ENV USERNAME=$USERNAME
ENV USER_UID=$USER_UID
ENV USER_GID=$USER_GID
RUN apk add libpq git openssh-client ca-certificates
COPY --from=base /usr/local/lib/python3.12/site-packages/ /usr/local/lib/python3.12/site-packages/
COPY --from=base /usr/local/bin/ /usr/local/bin/
WORKDIR /app
COPY ./pyproject.toml /app/pyproject.toml
RUN pip install '.[dev]'
RUN addgroup -g $USER_GID $USERNAME \
&& adduser -S $USERNAME -G $USERNAME -D -s /bin/sh
RUN chown $USERNAME:$USERNAME /app
COPY --chown=$USERNAME:$USERNAME ./ /app
USER $USERNAME
RUN pre-commit install --install-hooks
RUN pre-commit install --hook-type commit-msg
USER $USERNAME
WORKDIR /app/backend
EXPOSE 8000
ENTRYPOINT ["ash", "docker-entrypoint.sh"]
#---------------------------Prod Build------------------------#
FROM python:3.12-alpine
ARG USERNAME=appuser
ARG USER_UID=1000
ARG USER_GID=$USER_UID
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
ENV USERNAME=$USERNAME
ENV USER_UID=$USER_UID
ENV USER_GID=$USER_GID
RUN apk add libpq
COPY --from=base /usr/local/lib/python3.12/site-packages/ /usr/local/lib/python3.12/site-packages/
COPY --from=base /usr/local/bin/ /usr/local/bin/
RUN addgroup -g $USER_GID $USERNAME \
&& adduser -S $USERNAME -G $USERNAME -D -s /bin/sh
USER $USERNAME
WORKDIR /app
COPY --chown=appuser:appuser ./backend /app
WORKDIR /app
EXPOSE 8000
ENTRYPOINT ["ash", "docker-entrypoint.sh"]