feat: 添加 Dockerfile 和建木 DevOps 流水线配置
CI / Build, Lint, Test (push) Waiting to run Details

- 多阶段 Docker 构建(golang:1.26-alpine + alpine:3.20)
- 流水线:push 到 master 自动测试、构建、部署到 ECS

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
蒋天翔 2026-06-03 20:34:30 +08:00
parent 3a3b2a9f31
commit 028a2f1cab
2 changed files with 61 additions and 0 deletions

41
.devops/gitlink-cli.yml Normal file
View File

@ -0,0 +1,41 @@
version: 2
name: jtx_gitlink_cli
description: "gitlink-cli 项目:代码提交时自动测试、构建并部署到服务器"
trigger:
webhook: gitlink@1.0.0
event:
- ref: push
ruleset-operator: AND
global:
concurrent: 1
workflow:
- ref: start
name: 开始
task: start
- ref: git_clone_0
name: git clone
task: git_clone@1.2.9
input:
remote_url: '"https://gitlink.org.cn/jiangtx/gitlink-cli.git"'
ref: '"refs/heads/master"'
commit_id: '""'
depth: 1
needs:
- start
- ref: ssh_cmd_0
name: 测试并部署到服务器
task: ssh_cmd@1.1.1
input:
ssh_pass: ((jtx_gitlink_cli.jtx_gitlink_cli_ssh))
ssh_ip: '"121.41.212.97"'
ssh_port: '"22"'
ssh_user: '"root"'
ssh_cmd: >-
"cd /root && rm -rf gitlink-cli && git clone --depth=1 https://gitlink.org.cn/jiangtx/gitlink-cli.git && cd gitlink-cli && docker run --rm -v $(pwd):/build -w /build docker.1ms.run/library/golang:1.26-alpine go test -race ./... && docker build --no-cache -t gitlink-cli . && docker stop gitlink-cli || true && docker rm gitlink-cli || true && docker run -d --restart=always --name gitlink-cli gitlink-cli version"
needs:
- git_clone_0
- ref: end
name: 结束
task: end
needs:
- ssh_cmd_0

20
Dockerfile Normal file
View File

@ -0,0 +1,20 @@
FROM docker.1ms.run/library/golang:1.26-alpine AS builder
WORKDIR /build
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 go build -ldflags "-s -w" -o gitlink-cli .
FROM docker.1ms.run/library/alpine:3.20
RUN apk add --no-cache ca-certificates git
COPY --from=builder /build/gitlink-cli /usr/local/bin/gitlink-cli
RUN chmod +x /usr/local/bin/gitlink-cli
ENTRYPOINT ["gitlink-cli"]