fix: simplify CI/CD and Dockerfile
Build and Deploy / build (push) Failing after 52s
Build and Deploy / deploy (push) Has been skipped

- Use github.actor instead of gitea.actor
- Add act-latest container for Gitea Actions
- Simplify Dockerfile to use alpine
- Remove CGO dependencies
- Fix frontend build path
This commit is contained in:
2026-07-16 10:33:23 +00:00
parent a79e8fb853
commit 8258160f95
2 changed files with 17 additions and 47 deletions
+12 -23
View File
@@ -10,49 +10,39 @@ on:
jobs:
build:
runs-on: ubuntu-latest
container:
image: catthehacker/ubuntu:act-latest
steps:
- uses: actions/checkout@v4
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install frontend dependencies
working-directory: ./web
run: npm install
- name: Build frontend
working-directory: ./web
run: npm run build
run: |
npm install
npm run build
- name: Set up Docker Buildx
- name: Setup Docker
uses: docker/setup-buildx-action@v3
- name: Login to Gitea Registry
- name: Login to Registry
uses: docker/login-action@v3
with:
registry: git.viaeon.com
username: ${{ gitea.actor }}
username: ${{ github.actor }}
password: ${{ secrets.TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: git.viaeon.com/admin/anticaptcha
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=sha
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
tags: git.viaeon.com/admin/anticaptcha:latest
deploy:
runs-on: ubuntu-latest
@@ -68,5 +58,4 @@ jobs:
script: |
cd /opt/anticaptcha
docker-compose pull
docker-compose up -d
docker image prune -f
docker-compose up -d
+5 -24
View File
@@ -1,38 +1,19 @@
# 构建阶段
FROM golang:1.22-bookworm AS builder
# 安装构建依赖
RUN apt-get update && apt-get install -y \
git \
gcc \
g++ \
make \
libopencv-dev \
&& rm -rf /var/lib/apt/lists/*
FROM golang:1.22-alpine AS builder
WORKDIR /app
# 复制 Go 模块文件
COPY go.mod ./
# 复制源代码
COPY . .
# 下载依赖
# 构建
RUN go mod download || true
# 构建(纯 Go 版本,暂不启用 CGO)
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o anticaptcha ./cmd/server
# 运行阶段
FROM debian:bookworm-slim
FROM alpine:3.20
# 安装运行时依赖
RUN apt-get update && apt-get install -y \
ca-certificates \
tzdata \
libgomp1 \
&& rm -rf /var/lib/apt/lists/*
RUN apk add --no-cache ca-certificates tzdata
WORKDIR /app
@@ -40,7 +21,7 @@ WORKDIR /app
COPY --from=builder /app/anticaptcha .
COPY --from=builder /app/web/dist ./web/dist
# 创建数据目录
# 创建目录
RUN mkdir -p /app/data /app/models
ENV GIN_MODE=release