Files
SiteProxy/Dockerfile
2025-12-15 01:22:39 +08:00

32 lines
599 B
Docker

# Dockerfile
FROM golang:1.25-alpine AS builder
WORKDIR /app
# 复制 go.mod 和源代码
COPY go.mod ./
COPY . .
# 编译
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o siteproxy .
# 运行阶段
FROM alpine:latest
RUN apk --no-cache add ca-certificates
WORKDIR /root/
# 从构建阶段复制二进制文件
COPY --from=builder /app/siteproxy .
# 暴露端口
EXPOSE 8080
# 健康检查
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:8080/health || exit 1
# 运行
CMD ["./siteproxy"]