-
Notifications
You must be signed in to change notification settings - Fork 271
Expand file tree
/
Copy pathDockerfile
More file actions
34 lines (28 loc) · 946 Bytes
/
Dockerfile
File metadata and controls
34 lines (28 loc) · 946 Bytes
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
# Stage 1: Build frontend
FROM node:20-alpine AS frontend-builder
WORKDIR /app/frontend
COPY frontend/package.json frontend/package-lock.json ./
RUN --mount=type=cache,target=/root/.npm \
npm ci
COPY frontend/ ./
RUN npm run build
# Stage 2: Build backend
FROM golang:1.25-alpine AS backend-builder
WORKDIR /app/backend
COPY backend/go.mod backend/go.sum ./
RUN --mount=type=cache,target=/go/pkg/mod \
go mod download
COPY backend/ ./
ARG VERSION=dev
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
CGO_ENABLED=0 go build -ldflags="-s -w -X main.version=${VERSION}" -o /cqa-server .
# Stage 3: Production image
FROM alpine:3.21
RUN apk add --no-cache ca-certificates tzdata
WORKDIR /app
COPY --from=backend-builder /cqa-server /app/cqa-server
COPY --from=frontend-builder /app/frontend/dist /app/static
RUN mkdir -p /var/lib/cqa/files
EXPOSE 8080
ENTRYPOINT ["/app/cqa-server"]