-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
48 lines (36 loc) · 1.34 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
# Stage 1: Builder
FROM node:22.14.0-alpine@sha256:9bef0ef1e268f60627da9ba7d7605e8831d5b56ad07487d24d1aa386336d1944 AS builder
ENV GENERATE_SOURCEMAP=false
ENV NODE_OPTIONS=--max_old_space_size=4096
WORKDIR /build
# Just copy necessary data to build frontend
COPY app/frontend/package*.json ./
RUN npm ci --verbose
COPY app/frontend/ ./
RUN npm run build
# Stage 2: python build
FROM python:3.12-slim@sha256:34656cd90456349040784165b9decccbcee4de66f3ead0a1168ba893455afd1e AS python-builder
COPY --from=ghcr.io/astral-sh/uv:latest@sha256:0b6dc79013b689f3bc0cbf12807cb1c901beaafe80f2ee10a1d76aa3842afb92 /uv /bin/uv
WORKDIR /code
# copy uv version infos
COPY uv.lock .
COPY pyproject.toml .
# Install dependencies
RUN --mount=type=cache,target=/root/.cache/uv \
--mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
uv sync --frozen --no-install-project
# copy data from builder and backend srcs
COPY app/backend .
# add version information during build time and save it to an .env file
ARG COMMIT
ARG VERSION
ENV MUCGPT_VERSION=${VERSION}
ENV MUCGPT_COMMIT=${COMMIT}
# insert frontend build
COPY --from=builder /build/dist/ /code/static/
# sync the project
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen
EXPOSE 8000
CMD ["uv", "run", "gunicorn", "app:backend"]