file-system/Dockerfile
向宁 5e20a6d7fc fix: upgrade Dockerfile to Go 1.25, use Docker Hub base images
go.mod requires Go 1.25 (gin-contrib/cors v1.7.7 dependency).
Switch from private registry to Docker Hub for base images since
they're public and the registry only has Go 1.24.
2026-05-17 22:14:17 +08:00

38 lines
715 B
Docker

# Build Stage - 使用预装 Go 的基础镜像
FROM golang:1.25-alpine AS builder
WORKDIR /app
ENV GOPROXY=https://goproxy.cn,direct
ENV GOSUMDB=sum.golang.google.cn
# 复制依赖文件
COPY go.mod go.sum ./
RUN go mod download
# 复制源代码
COPY . .
# 编译 Go 应用
RUN go build -v -o server ./cmd/server
# Run Stage
FROM alpine:latest
WORKDIR /app
RUN apk add --no-cache wget file
COPY --from=builder /app/server .
RUN chmod +x server
COPY --from=builder /app/web ./web
COPY --from=builder /app/docs ./docs
EXPOSE 8080
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:8080/web || exit 1
CMD ["./server"]