file-system/Dockerfile
向宁 5f3d84a89b fix: remove web dir from Dockerfile, fix healthcheck path
web/ was deleted in previous refactoring. Healthcheck now uses /health
endpoint instead of /web.
2026-05-17 22:28:01 +08:00

37 lines
683 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/docs ./docs
EXPOSE 8080
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:8080/health || exit 1
CMD ["./server"]