-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDockerfile
More file actions
75 lines (57 loc) · 1.99 KB
/
Copy pathDockerfile
File metadata and controls
75 lines (57 loc) · 1.99 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# Build blog frontend
FROM node:22-alpine AS blog-builder
WORKDIR /src/web/blog
COPY web/blog/package.json web/blog/package-lock.json ./
RUN npm ci
COPY web/blog/ ./
RUN VITE_OUT_DIR=dist npm run build
# Build admin frontend
FROM node:22-alpine AS admin-builder
WORKDIR /src/web/admin
COPY web/admin/package.json web/admin/package-lock.json ./
RUN npm ci
COPY web/admin/ ./
RUN VITE_OUT_DIR=dist npm run build
# Shared Go source and dependency cache
FROM golang:1.26-alpine AS go-base
WORKDIR /app
# Install dependencies
COPY go.mod go.sum ./
RUN go mod download
# Copy source code
COPY . .
# Build the user service with only the blog SPA.
FROM go-base AS server-builder
RUN rm -rf internal/webassets/blog/dist
COPY --from=blog-builder /src/web/blog/dist ./internal/webassets/blog/dist
RUN CGO_ENABLED=0 GOOS=linux go build -o server ./cmd/server
# Build the admin service with only the admin SPA.
FROM go-base AS admin-go-builder
RUN rm -rf internal/webassets/admin/dist
COPY --from=admin-builder /src/web/admin/dist ./internal/webassets/admin/dist
RUN CGO_ENABLED=0 GOOS=linux go build -o admin ./cmd/admin
# Build scheduler without any frontend build dependency.
FROM go-base AS scheduler-builder
RUN CGO_ENABLED=0 GOOS=linux go build -o scheduler ./cmd/scheduler
# Shared runtime base
FROM alpine:latest AS runtime-base
WORKDIR /app
# Install ca-certificates for HTTPS
RUN apk --no-cache add ca-certificates
COPY --from=go-base /app/config ./config
# Create uploads directory
RUN mkdir -p uploads
# Admin runtime contains only the admin binary and admin SPA.
FROM runtime-base AS admin-runtime
COPY --from=admin-go-builder /app/admin ./admin
EXPOSE 8083
CMD ["./admin"]
# Scheduler runtime contains no frontend assets.
FROM runtime-base AS scheduler-runtime
COPY --from=scheduler-builder /app/scheduler ./scheduler
CMD ["./scheduler"]
# Server is the default target and contains only the blog SPA.
FROM runtime-base AS server-runtime
COPY --from=server-builder /app/server ./server
EXPOSE 8081
CMD ["./server"]