you2api / Dockerfile
bohesocool's picture
Update Dockerfile
d15fd9a verified
raw
history blame contribute delete
732 Bytes
# 使用最新的 Go 1.22 版本作为基础镜像
FROM golang:1.22-alpine
# 安装必要的系统依赖
RUN apk --no-cache add ca-certificates git curl
# 设置工作目录
WORKDIR /app
# 克隆项目代码
RUN git clone https://github.com/bohesocool/you2api.git .
# 下载依赖
RUN go mod download
# 构建应用
RUN CGO_ENABLED=0 GOOS=linux GODEBUG=http2debug=2 go build -o main .
# 设置环境变量
ENV PORT=8080
ENV ENABLE_PROXY=true
ENV PROXY_URL=""
ENV PROXY_TIMEOUT_MS=5000
# 暴露端口
EXPOSE 8080
# 添加健康检查
HEALTHCHECK --interval=30s --timeout=3s \
CMD curl -f 0.0.0.0:8080/ || exit 1
# 运行应用并输出更多日志
CMD ["sh", "-c", "echo '启动服务...' && GODEBUG=http2debug=2 ./main"]