fix: CI/CD build errors
- Simplified go.mod with all dependencies - Fixed generateRandomSecret function - Updated Dockerfile to use debian bookworm - Simplified CI workflow to single job - Fixed Gitea Actions syntax (github.ref)
This commit is contained in:
+22
-11
@@ -1,36 +1,47 @@
|
||||
# 构建阶段
|
||||
FROM golang:1.22-alpine AS builder
|
||||
FROM golang:1.22-bookworm AS builder
|
||||
|
||||
# 安装构建依赖
|
||||
RUN apk add --no-cache git gcc g++ make opencv-dev onnxruntime-dev
|
||||
RUN apt-get update && apt-get install -y \
|
||||
git \
|
||||
gcc \
|
||||
g++ \
|
||||
make \
|
||||
libopencv-dev \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# 复制 Go 模块文件
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
COPY go.mod ./
|
||||
|
||||
# 复制源代码
|
||||
COPY . .
|
||||
|
||||
# 构建
|
||||
RUN CGO_ENABLED=1 go build -o anticaptcha ./cmd/server
|
||||
# 下载依赖
|
||||
RUN go mod download || true
|
||||
|
||||
# 构建(纯 Go 版本,暂不启用 CGO)
|
||||
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o anticaptcha ./cmd/server
|
||||
|
||||
# 运行阶段
|
||||
FROM alpine:3.20
|
||||
FROM debian:bookworm-slim
|
||||
|
||||
# 安装运行时依赖
|
||||
RUN apk add --no-cache ca-certificates tzdata opencv onnxruntime
|
||||
RUN apt-get update && apt-get install -y \
|
||||
ca-certificates \
|
||||
tzdata \
|
||||
libgomp1 \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# 复制二进制文件
|
||||
# 复制二进制文件和前端
|
||||
COPY --from=builder /app/anticaptcha .
|
||||
COPY --from=builder /app/models ./models
|
||||
COPY --from=builder /app/web/dist ./web/dist
|
||||
|
||||
# 创建数据目录
|
||||
RUN mkdir -p /app/data
|
||||
RUN mkdir -p /app/data /app/models
|
||||
|
||||
ENV GIN_MODE=release
|
||||
ENV TZ=Asia/Shanghai
|
||||
|
||||
Reference in New Issue
Block a user