-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
37 lines (23 loc) · 803 Bytes
/
Copy pathDockerfile
File metadata and controls
37 lines (23 loc) · 803 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
FROM golang:1.22-alpine AS builder
WORKDIR /app
# Install build deps
RUN apk add --no-cache git ca-certificates
# Disable Go checksum verification to avoid go.sum mismatch issues
ENV GONOSUMDB=* GOFLAGS=-mod=mod GONOSUMCHECK=* GONOPROXY=* GOFLAGS=-mod=mod GONOSUMDB=*
# Copy go mod file
COPY go.mod ./
# Download dependencies with sum verification disabled
RUN GONOSUMDB=* GOFLAGS=-mod=mod GONOPROXY=* go mod download
# Copy all source code
COPY . .
# Build
RUN CGO_ENABLED=0 GOOS=linux GONOSUMDB=* GOFLAGS=-mod=mod go build -o xiantu-server ./cmd/server
# Production image
FROM alpine:3.19
RUN apk add --no-cache ca-certificates tzdata
WORKDIR /app
COPY --from=builder /app/xiantu-server .
COPY --from=builder /app/public ./public
ENV TZ=Asia/Shanghai
EXPOSE 8080
CMD ["./xiantu-server"]