Files
billai/webhook/Dockerfile
CHE LIANG ZHAO 05ab270677 feat: 添加 Gitea webhook 自动部署功能
- 新增独立的 webhook 服务 (Go, 端口 9000)
- HMAC-SHA256 签名验证
- 零停机热更新部署
- 自动清理旧镜像
- 完整配置文档 WEBHOOK_SETUP.md
- 精简 README 版本历史为表格形式
2026-01-13 14:37:01 +08:00

53 lines
1.2 KiB
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.
# Webhook 服务 Dockerfile
# 多阶段构建:编译阶段 + 运行阶段
# ===== 编译阶段 =====
FROM golang:1.21-alpine AS builder
WORKDIR /build
# 配置 Alpine 镜像源(国内)
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
# 配置 Go 代理(国内镜像)
ENV GOPROXY=https://goproxy.cn,direct
# 安装编译依赖
RUN apk add --no-cache git
# 复制代码
COPY . .
# 构建二进制
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o webhook .
# ===== 运行阶段 =====
FROM alpine:3.19
WORKDIR /app
# 配置 Alpine 镜像源(国内)
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
# 安装必要工具
RUN apk add --no-cache bash curl git docker-cli docker-compose ca-certificates tzdata
# 设置时区
ENV TZ=Asia/Shanghai
# 从编译阶段复制二进制
COPY --from=builder /build/webhook /usr/local/bin/webhook
# 注意deploy.sh 通过 volume 挂载,不在构建时复制
# 因为 deploy.sh 在仓库根目录,而 Dockerfile 在 webhook 目录
# 暴露端口
EXPOSE 9000
# 健康检查
HEALTHCHECK --interval=10s --timeout=5s --retries=3 \
CMD curl -f http://localhost:9000/health || exit 1
# 启动服务
CMD ["webhook"]