-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathDockerfile
More file actions
44 lines (30 loc) · 919 Bytes
/
Copy pathDockerfile
File metadata and controls
44 lines (30 loc) · 919 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
35
36
37
38
39
40
41
42
43
44
# Build stage - Backend
FROM golang:1.22-alpine AS backend-builder
WORKDIR /build
RUN apk add --no-cache gcc musl-dev
COPY server/go.mod server/go.sum ./
RUN go mod download
COPY server/ .
RUN CGO_ENABLED=1 go build -ldflags="-s -w" -o admin-server .
# Build stage - Frontend
FROM node:20-alpine AS frontend-builder
WORKDIR /build
COPY web/package*.json ./
RUN npm ci --production=false
COPY web/ .
RUN npm run build
# Production stage
FROM alpine:3.19
RUN apk add --no-cache ca-certificates tzdata && \
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
echo "Asia/Shanghai" > /etc/timezone
WORKDIR /app
# Copy backend binary
COPY --from=backend-builder /build/admin-server .
COPY --from=backend-builder /build/config.yaml .
# Copy frontend dist
COPY --from=frontend-builder /build/dist ./web/dist
# Create necessary directories
RUN mkdir -p logs uploads
EXPOSE 8080
CMD ["./admin-server"]