-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
51 lines (33 loc) · 1.11 KB
/
Dockerfile
File metadata and controls
51 lines (33 loc) · 1.11 KB
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
# Stage 1: Build backend
FROM golang:1.26.0-alpine3.22 AS backend-builder
WORKDIR /app
RUN apk add --no-cache gcc musl-dev libwebp-dev
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=1 GOOS=linux go build -ldflags="-s -w" -o server ./cmd/api/main.go
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o migrate migrate.go
# Stage 3: Build frontend
FROM node:22.16.0-alpine3.22 AS frontend-builder
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
WORKDIR /frontend/ui
COPY ./ui/package.json ./ui/pnpm-lock.yaml ./
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
COPY ./ui/ .
ARG BUILD_TIME
ENV VITE_BUILD_TIME=$BUILD_TIME
ENV CI=true
RUN pnpm run build
# Stage 3: Combine
FROM alpine:3.22 AS prod
WORKDIR /app
RUN apk add --no-cache libwebp-dev ca-certificates tzdata
COPY --from=backend-builder /app/server .
COPY --from=backend-builder /app/migrate .
COPY --from=backend-builder /app/docs ./docs
COPY --from=frontend-builder /frontend/ui/dist ./public
ENV APP_ENV=PRODUCTION
EXPOSE 4000
ENTRYPOINT ["sh", "-c", "./migrate && ./server"]