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
+11 -22
View File
@@ -10,49 +10,39 @@ on:
jobs: jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
container:
image: catthehacker/ubuntu:act-latest
steps: steps:
- uses: actions/checkout@v4 - name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js - name: Setup Node.js
uses: actions/setup-node@v4 uses: actions/setup-node@v4
with: with:
node-version: '20' node-version: '20'
- name: Install frontend dependencies
working-directory: ./web
run: npm install
- name: Build frontend - name: Build frontend
working-directory: ./web 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 uses: docker/setup-buildx-action@v3
- name: Login to Gitea Registry - name: Login to Registry
uses: docker/login-action@v3 uses: docker/login-action@v3
with: with:
registry: git.viaeon.com registry: git.viaeon.com
username: ${{ gitea.actor }} username: ${{ github.actor }}
password: ${{ secrets.TOKEN }} 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 - name: Build and push
uses: docker/build-push-action@v5 uses: docker/build-push-action@v5
with: with:
context: . context: .
push: true push: true
tags: ${{ steps.meta.outputs.tags }} tags: git.viaeon.com/admin/anticaptcha:latest
labels: ${{ steps.meta.outputs.labels }}
deploy: deploy:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@@ -69,4 +59,3 @@ jobs:
cd /opt/anticaptcha cd /opt/anticaptcha
docker-compose pull docker-compose pull
docker-compose up -d docker-compose up -d
docker image prune -f
+5 -24
View File
@@ -1,38 +1,19 @@
# 构建阶段 # 构建阶段
FROM golang:1.22-bookworm AS builder FROM golang:1.22-alpine AS builder
# 安装构建依赖
RUN apt-get update && apt-get install -y \
git \
gcc \
g++ \
make \
libopencv-dev \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app WORKDIR /app
# 复制 Go 模块文件
COPY go.mod ./
# 复制源代码 # 复制源代码
COPY . . COPY . .
# 下载依赖 # 构建
RUN go mod download || true RUN go mod download || true
# 构建(纯 Go 版本,暂不启用 CGO)
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o anticaptcha ./cmd/server RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o anticaptcha ./cmd/server
# 运行阶段 # 运行阶段
FROM debian:bookworm-slim FROM alpine:3.20
# 安装运行时依赖 RUN apk add --no-cache ca-certificates tzdata
RUN apt-get update && apt-get install -y \
ca-certificates \
tzdata \
libgomp1 \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app WORKDIR /app
@@ -40,7 +21,7 @@ WORKDIR /app
COPY --from=builder /app/anticaptcha . COPY --from=builder /app/anticaptcha .
COPY --from=builder /app/web/dist ./web/dist COPY --from=builder /app/web/dist ./web/dist
# 创建数据目录 # 创建目录
RUN mkdir -p /app/data /app/models RUN mkdir -p /app/data /app/models
ENV GIN_MODE=release ENV GIN_MODE=release