Files
cryptoHermes/Dockerfile
dela ea22d06dab deploy(compose): app healthcheck + 优雅停 + 日志策略 + README 部署章节
- Dockerfile:alpine 安装 wget;加 HEALTHCHECK(/v1/health 探测,
  interval 15s、start_period 20s、retries 3)
- docker-compose.yml app:
  · stop_grace_period 30s(配合 fiber ShutdownWithContext 10s
    + cron 任务收尾,避免 SIGKILL 截断在途请求)
  · restart unless-stopped
  · json-file logging:单文件 50MB、保留 5 个滚动文件
  · 业务日志卷 ./logs:/app/logs
- docker-compose.yml postgres:同样配 restart + logging
- logs/ 目录用 .gitkeep 保留;.gitignore 加 logs/* + !logs/.gitkeep
- README 新增'一键部署(docker compose)'整章:3 步上线、启动顺序图、
  healthcheck 说明、优雅停机、日志、回填历史、生产 checklist

所有 12 条守卫保持无输出;build / vet 干净。
2026-05-24 21:01:45 +08:00

23 lines
745 B
Docker
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
FROM golang:1.23-alpine AS builder
WORKDIR /src
COPY go.mod go.sum* ./
RUN go mod download || true
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -o /out/app ./cmd/app \
&& CGO_ENABLED=0 GOOS=linux go build -o /out/backfill ./cmd/backfill
FROM alpine:3.20
# wget 用于容器 healthcheckca-certificates 用于 TLStzdata 用于本地时区
RUN apk add --no-cache ca-certificates tzdata wget
WORKDIR /app
COPY --from=builder /out/app /app/app
COPY --from=builder /out/backfill /app/backfill
EXPOSE 8080
# 容器级 healthcheck拒绝把 unhealthy 容器纳入负载均衡
HEALTHCHECK --interval=15s --timeout=3s --start-period=20s --retries=3 \
CMD wget --spider -q http://127.0.0.1:8080/v1/health || exit 1
ENTRYPOINT ["/app/app"]