-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
36 lines (33 loc) · 970 Bytes
/
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
# install and cache dependencies
FROM node:20-slim AS node_cache
WORKDIR /cache/
COPY frontend/package*.json ./
RUN npm install --prefer-offline --no-audit --progress=true --loglevel verbose --omit=dev
FROM python:3.12-slim AS python_cache
ENV VIRTUAL_ENV=/venv
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
WORKDIR /cache/
COPY backend/requirements.txt .
RUN python -m venv /venv
RUN pip install -r requirements.txt
# build with npm
FROM node:20-slim AS node_builder
ARG VITE_SUBPATH
ARG VITE_MSG_MAX_LEN
ENV VITE_SUBPATH ${VITE_SUBPATH}
ENV VITE_MSG_MAX_LEN ${VITE_MSG_MAX_LEN}
WORKDIR /frontend
COPY --from=node_cache /cache/ .
COPY frontend .
RUN npm run build
# serve frontend+backend
FROM python:3.12-slim AS runner
ENV PYTHONUNBUFFERED 1
WORKDIR /app
ENV VIRTUAL_ENV=/venv
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
COPY --from=python_cache /venv /venv
COPY --from=node_builder /frontend/dist /app/frontend/dist
COPY backend backend
WORKDIR /app/backend
CMD ["python3", "main.py"]