-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
executable file
·98 lines (71 loc) · 2.61 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
ARG git_branch="<none>"
ARG git_commit="<none>"
# Backend targets:
# - backend: Includes only the backend part. Can be used for development, does not support hot-reloading.
# - backend-hotreload: Support hot-reloading, used only for local deployment. Excludes frontend
#
# Frontend targets:
# - frontend-base: Common base for both deployment and development containers
# - frontend-dev: Target only for local development, supports hot-reload
# - frontend-build: Builds the frontend files that will be included with the backend for final production-ready container.
#
# The `combined` stage extends the `backend` target with files built in the `frontend-build` step. Includes everything, production-ready
FROM eu.gcr.io/vseth-public/base:echo AS backend
LABEL maintainer='cat@vis.ethz.ch'
WORKDIR /app
RUN mkdir intermediate_pdf_storage && chown app-user:app-user intermediate_pdf_storage
COPY ./backend/requirements.txt ./requirements.txt
RUN apt-get install -y --no-install-recommends \
python3 python3-pip \
python3-setuptools python3-cryptography \
smbclient poppler-utils \
pgbouncer
RUN pip3 install -r requirements.txt
RUN rm -rf /var/lib/apt/lists/*
COPY ./backend/ ./
COPY ./frontend/public/exam10.pdf ./exam10.pdf
COPY ./frontend/public/static ./static
# prevent guincorn from buffering prints from python workers
ENV PYTHONUNBUFFERED True
COPY ./pgbouncer ./pgbouncer
COPY cinit.yml /etc/cinit.d/community-solutions.yml
FROM node:20-alpine AS frontend-base
WORKDIR /usr/src/app
COPY ./frontend/package.json \
./frontend/yarn.lock \
./frontend/index.html .
RUN yarn --ignore-engines
FROM frontend-base AS frontend-build
ARG git_branch
ARG git_commit
COPY ./frontend/tsconfig.json \
./frontend/postcss.config.cjs \
./frontend/vite.config.ts \
./frontend/.eslintrc.json \
./frontend/.env.production \
./frontend/.prettierrc.json .
COPY ./frontend/public ./public
COPY ./frontend/src ./src
ENV VITE_GIT_BRANCH=${git_branch}
ENV VITE_GIT_COMMIT=${git_commit}
RUN yarn run build
FROM backend AS combined
COPY --from=frontend-build /usr/src/app/build/manifest.json \
/usr/src/app/build/favicon.ico .
COPY --from=frontend-build /usr/src/app/build/index.html ./templates/index.html
COPY --from=frontend-build /usr/src/app/build/static ./static
EXPOSE 80
# Development-only stages
# Backend
FROM backend AS backend-hotreload
ENV IS_DEBUG true
CMD python3 manage.py migrate \
&& python3 manage.py runserver 0:8081
# Frontend
FROM frontend-base AS frontend-dev
RUN yarn install --ignore-optional
COPY frontend ./
EXPOSE 3000
CMD ["yarn", "start-docker"]
# Production build as final result
FROM combined