Jenkinsfile

This commit is contained in:
2026-06-09 21:44:37 +08:00
parent 0484e79978
commit fbf31183ae
2 changed files with 42 additions and 3 deletions
+3 -3
View File
@@ -1,7 +1,7 @@
# syntax=docker/dockerfile:1.7 # syntax=docker/dockerfile:1.7
# ─── Stage 1: web build ─── # ─── Stage 1: web build ───
FROM node:22-alpine AS web FROM registry.jerryyan.top/library/node:22-alpine AS web
WORKDIR /web WORKDIR /web
COPY web/package.json web/pnpm-lock.yaml* ./ COPY web/package.json web/pnpm-lock.yaml* ./
RUN corepack enable && (pnpm install --frozen-lockfile || pnpm install) RUN corepack enable && (pnpm install --frozen-lockfile || pnpm install)
@@ -9,7 +9,7 @@ COPY web .
RUN pnpm build RUN pnpm build
# ─── Stage 2: go build ─── # ─── Stage 2: go build ───
FROM golang:1.25-alpine AS go FROM registry.jerryyan.top/library/golang:1.25-alpine AS go
WORKDIR /src WORKDIR /src
RUN apk add --no-cache git RUN apk add --no-cache git
COPY go.mod go.sum ./ COPY go.mod go.sum ./
@@ -19,7 +19,7 @@ COPY --from=web /web/dist/. ./cmd/server/web/dist/
RUN CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags='-s -w' -o /out/server ./cmd/server RUN CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags='-s -w' -o /out/server ./cmd/server
# ─── Stage 3: runtime ─── # ─── Stage 3: runtime ───
FROM alpine:3.20 FROM registry.jerryyan.top/library/alpine:3.20
RUN apk add --no-cache ca-certificates tzdata && \ RUN apk add --no-cache ca-certificates tzdata && \
addgroup -S app && adduser -S app -G app addgroup -S app && adduser -S app -G app
WORKDIR /app WORKDIR /app
Vendored
+39
View File
@@ -0,0 +1,39 @@
pipeline {
agent any
environment {
REGISTRY = 'git.jerryyan.net'
IMAGE = "${REGISTRY}/q792602257/agent-coding-workflow"
TAG = sh(script: 'git rev-parse --short HEAD', returnStdout: true).trim()
}
stages {
stage('Build & Push') {
steps {
withCredentials([usernamePassword(
credentialsId: 'gitea-registry',
usernameVariable: 'REGISTRY_USER',
passwordVariable: 'REGISTRY_PASS'
)]) {
sh """
docker build -t ${IMAGE}:${TAG} -t ${IMAGE}:latest .
echo "\$REGISTRY_PASS" | docker login ${REGISTRY} -u "\$REGISTRY_USER" --password-stdin
docker push ${IMAGE}:${TAG}
docker push ${IMAGE}:latest
"""
}
}
post {
always {
sh 'docker logout ${REGISTRY} || true'
}
}
}
}
post {
failure {
echo "Build failed for commit ${env.TAG}"
}
}
}