-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
51 lines (34 loc) · 1.2 KB
/
Dockerfile
File metadata and controls
51 lines (34 loc) · 1.2 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.25.1-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 2: Build frontend
FROM node:24.8.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 APP_VERSION
ENV VITE_APP_VERSION=$APP_VERSION
ENV CI=true
RUN pnpm run build
# Stage 3: Combine
FROM alpine:3.22 AS prod
WORKDIR /app
RUN apk add --no-cache libwebp ca-certificates tzdata
# Copy our executable and our built React application.
COPY --from=backend-builder /app/server .
COPY --from=backend-builder /app/migrate .
COPY --from=backend-builder /app/config/production.toml ./config/production.toml
COPY --from=frontend-builder /frontend/ui/dist ./public
ENV APP_ENV=production
EXPOSE 8000
ENTRYPOINT ["/bin/sh", "-c" , "./migrate && ./server"]