-
Notifications
You must be signed in to change notification settings - Fork 5
/
Dockerfile
64 lines (46 loc) · 1.45 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
FROM python:3.10-alpine as develop
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
RUN apk update && apk upgrade
RUN apk add --no-cache \
curl \
npm \
build-base \
libffi-dev \
postgresql-dev \
libpq-dev \
python3-dev \
musl-dev \
openssl-dev
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
ENV PATH=$PATH:/root/.cargo/bin
# backend dependencies
WORKDIR /app
COPY requirements.txt .
# pip will put packages in here if it exists
RUN mkdir /root/.local
RUN pip install -r requirements.txt
# frontend dependencies
WORKDIR /app/frontend
COPY frontend/package.json .
COPY frontend/package-lock.json .
RUN npm ci
# copy and setup whole app
WORKDIR /app
COPY . .
WORKDIR /app/frontend
RUN npm run build
WORKDIR /app
# if the SECRET_KEY is not definied, django management commands will not run
ARG SECRET_KEY="any value"
RUN python manage.py collectstatic --no-input
ENTRYPOINT [ "sh", "entrypoint_dev.sh" ]
FROM python:3.10-alpine as production
RUN apk add --no-cache libpq
WORKDIR /app
# this copies previously installed and compiled python (pip) dependencies
COPY --from=develop /usr/local/lib/python3.10/lib-dynload /usr/local/lib/python3.10/lib-dynload
COPY --from=develop /usr/local/lib/python3.10/site-packages /usr/local/lib/python3.10/site-packages
# copy project source code, including static build artifacts, node_modules, etc.
COPY --from=develop /app .
ENTRYPOINT [ "sh", "entrypoint.sh" ]