Port CI to Forgejo Actions
All checks were successful
ci / web-checks (push) Successful in 49s
ci / web-build (push) Successful in 59s
ci / server-binary (push) Successful in 8m28s
ci / build-3 (push) Successful in 9m10s
ci / build-2 (push) Successful in 7m45s
ci / build (push) Successful in 10m6s
ci / host-agent-docker (push) Successful in 0s
ci / k8s-agent-docker (push) Successful in 0s
ci / build-1 (push) Successful in 3m34s
ci / frontend-docker (push) Successful in 0s
ci / backend-docker (push) Successful in 0s
ci / agent-binaries (push) Successful in 18m33s
ci / go-checks (push) Successful in 24m40s
ci / build-4 (push) Successful in 41s
ci / chart-k8s-agent (push) Successful in 0s
ci / build-5 (push) Successful in 44s
ci / chart (push) Successful in 0s
ci / upload-agent-releases (push) Successful in 1m12s
ci / sbom (push) Successful in 3m11s
ci / publish-release-manifest (push) Successful in 52s
ci / upload-sboms (push) Successful in 40s

Drop the GitLab Pages documentation jobs (not available on Forgejo).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
claude 2026-11-18 10:47:17 +01:00
commit 8f572b665d
4 changed files with 372 additions and 506 deletions

345
.forgejo/workflows/ci.yml Normal file
View file

@ -0,0 +1,345 @@
name: ci
on:
push:
branches: ['**']
tags: ['**']
workflow_dispatch:
env:
GOPROXY: https://goproxy.jonasled.dev,direct
# The agent version is 1.0.<run number + OFFSET>. OFFSET is the last GitLab pipeline ID (128877),
# so versions keep growing across the migration. Keep it in sync with the offsets below.
VERSION_OFFSET: '128877'
jobs:
go-checks:
# `make check-go`: gofmt, vet and golangci-lint on Linux, Windows and macOS, the Go
# tests, and a check that the swagger docs are up to date. Run `make check` before
# every commit. It runs the same targets as this job.
runs-on: default
env:
CGO_ENABLED: '0'
steps:
- uses: https://code.forgejo.org/actions/checkout@v7
- uses: https://code.forgejo.org/actions/setup-go@v7
with:
go-version: '1.27'
- run: |
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.15.0
make check-go GOLANGCI_LINT=$(go env GOPATH)/bin/golangci-lint
web-checks:
# `make check-web`: the TypeScript check of the React UI. Run with `make check`.
runs-on: default
steps:
- uses: https://code.forgejo.org/actions/checkout@v7
- uses: https://code.forgejo.org/actions/setup-node@v7
with:
node-version: '26'
- run: |
npm install -g pnpm@12.14.0
make check-web
web-build:
# The web interface, embedded into the server binary by the server-binary job.
runs-on: default
steps:
- uses: https://code.forgejo.org/actions/checkout@v7
- uses: https://code.forgejo.org/actions/setup-node@v7
with:
node-version: '26'
- run: |
cd web
npm install -g pnpm@12.14.0
pnpm install --frozen-lockfile
pnpm build
- uses: https://code.forgejo.org/forgejo/upload-artifact@v4
with:
name: web-dist
path: web/dist/
retention-days: 1
agent-binaries:
# Cross-compile the agent binary for Linux amd64 and arm64, Windows amd64, and macOS amd64 and arm64.
runs-on: default
env:
CGO_ENABLED: '0'
steps:
- uses: https://code.forgejo.org/actions/checkout@v7
- uses: https://code.forgejo.org/actions/setup-go@v7
with:
go-version: '1.27'
- run: |
set -eu
export VERSION="1.0.$((GITHUB_RUN_NUMBER + VERSION_OFFSET))"
export MODULE="jonasled.dev/jonasled/vulnerability-operator"
export LDFLAGS="-s -w -X ${MODULE}/internal/version.Version=${VERSION}"
mkdir -p bin/dist
GOOS=linux GOARCH=amd64 go build -trimpath -ldflags "${LDFLAGS}" -o bin/dist/vop-agent-linux-amd64 ./cmd/agent
GOOS=linux GOARCH=arm64 go build -trimpath -ldflags "${LDFLAGS}" -o bin/dist/vop-agent-linux-arm64 ./cmd/agent
GOOS=windows GOARCH=amd64 go build -trimpath -ldflags "${LDFLAGS}" -o bin/dist/vop-agent-windows-amd64.exe ./cmd/agent
GOOS=darwin GOARCH=amd64 go build -trimpath -ldflags "${LDFLAGS}" -o bin/dist/vop-agent-darwin-amd64 ./cmd/agent
GOOS=darwin GOARCH=arm64 go build -trimpath -ldflags "${LDFLAGS}" -o bin/dist/vop-agent-darwin-arm64 ./cmd/agent
- uses: https://code.forgejo.org/forgejo/upload-artifact@v4
with:
name: agent-binaries
path: bin/dist/
retention-days: 1
server-binary:
# The server with the web interface embedded, for the SBOM.
needs: [web-build]
runs-on: default
env:
CGO_ENABLED: '0'
steps:
- uses: https://code.forgejo.org/actions/checkout@v7
- uses: https://code.forgejo.org/actions/setup-go@v7
with:
go-version: '1.27'
- uses: https://code.forgejo.org/forgejo/download-artifact@v4
with:
name: web-dist
path: web/dist
- run: |
set -eu
export MODULE="jonasled.dev/jonasled/vulnerability-operator"
export VERSION="1.0.$((GITHUB_RUN_NUMBER + VERSION_OFFSET))"
mkdir -p bin
go build -trimpath -ldflags "-s -w -X ${MODULE}/internal/version.Version=${VERSION}" -o bin/vop-server ./cmd/server
- uses: https://code.forgejo.org/forgejo/upload-artifact@v4
with:
name: server-binary
path: bin/vop-server
retention-days: 1
backend-docker:
# The backend Dockerfile sits in the repository root.
uses: infra/ci-snippets/.forgejo/workflows/docker-build.yml@master
with:
image-suffix: /backend
secrets: inherit
frontend-docker:
# The frontend Dockerfile and nginx.conf sit in web/.
uses: infra/ci-snippets/.forgejo/workflows/docker-build.yml@master
with:
image-suffix: /frontend
context-dir: web
secrets: inherit
k8s-agent-docker:
# The node agent image, built from Dockerfile.k8s-agent. The version it reports is the one of the agent binaries of this run.
uses: infra/ci-snippets/.forgejo/workflows/docker-build.yml@master
with:
image-suffix: /k8s-agent
additional-args: --opt filename=Dockerfile.k8s-agent --opt build-arg:VERSION=1.0.@RUN_NUMBER@
run-number-offset: '128877'
secrets: inherit
host-agent-docker:
# The linux agent image for the host DaemonSet of the Kubernetes chart, built from Dockerfile.agent.
uses: infra/ci-snippets/.forgejo/workflows/docker-build.yml@master
with:
image-suffix: /agent
additional-args: --opt filename=Dockerfile.agent --opt build-arg:VERSION=1.0.@RUN_NUMBER@
run-number-offset: '128877'
secrets: inherit
upload-agent-releases:
# Upload the built agent binaries directly to S3 for public download.
# Requires S3_ENDPOINT, S3_ACCESS_KEY, S3_SECRET_KEY, S3_BUCKET.
if: github.ref_name == github.event.repository.default_branch && github.ref_type == 'branch'
needs: [agent-binaries]
runs-on: default
env:
AWS_DEFAULT_REGION: us-east-1
S3_ENDPOINT: ${{ secrets.S3_ENDPOINT }}
S3_BUCKET: ${{ secrets.S3_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.S3_ACCESS_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_SECRET_KEY }}
AWS_REQUEST_CHECKSUM_CALCULATION: when_required
AWS_RESPONSE_CHECKSUM_VALIDATION: when_required
steps:
- uses: https://code.forgejo.org/forgejo/download-artifact@v4
with:
name: agent-binaries
path: bin/dist
- run: |
set -eu
pip install --quiet --user awscli || pip install --quiet --break-system-packages awscli
export PATH="$HOME/.local/bin:$PATH"
VERSION="1.0.$((GITHUB_RUN_NUMBER + VERSION_OFFSET))"
# Path-style addressing: the bucket is in the path, not the host name.
aws configure set default.s3.addressing_style path
for file in vop-agent-linux-amd64 vop-agent-linux-arm64 vop-agent-windows-amd64.exe vop-agent-darwin-amd64 vop-agent-darwin-arm64; do
echo "Uploading ${file}..."
aws s3 cp "bin/dist/${file}" "s3://${S3_BUCKET}/agent-releases/${VERSION}/${file}" --endpoint-url "https://${S3_ENDPOINT}" --region us-east-1
done
publish-release-manifest:
# Writes releases.json next to the binaries, which the server reads to list the
# published agent versions. It runs only after the upload succeeded: a manifest
# must not point at binaries that are not in the bucket.
if: github.ref_name == github.event.repository.default_branch && github.ref_type == 'branch'
needs: [agent-binaries, upload-agent-releases]
runs-on: default
env:
BIN_DIR: bin/dist
AWS_DEFAULT_REGION: us-east-1
S3_ENDPOINT: ${{ secrets.S3_ENDPOINT }}
S3_BUCKET: ${{ secrets.S3_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.S3_ACCESS_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_SECRET_KEY }}
AWS_REQUEST_CHECKSUM_CALCULATION: when_required
AWS_RESPONSE_CHECKSUM_VALIDATION: when_required
steps:
- uses: https://code.forgejo.org/actions/checkout@v7
- uses: https://code.forgejo.org/forgejo/download-artifact@v4
with:
name: agent-binaries
path: bin/dist
- run: |
set -eu
pip install --quiet --user awscli || pip install --quiet --break-system-packages awscli
export PATH="$HOME/.local/bin:$PATH"
export VERSION="1.0.$((GITHUB_RUN_NUMBER + VERSION_OFFSET))"
aws configure set default.s3.addressing_style path
python3 scripts/publish-release-manifest.py
sbom:
# CycloneDX SBOMs of every binary of this run, and of the images the build jobs made.
# syft is pinned to the version of go.mod, the one the server scans with.
if: github.ref_name == github.event.repository.default_branch && github.ref_type == 'branch'
needs: [agent-binaries, server-binary, backend-docker, frontend-docker, k8s-agent-docker, host-agent-docker]
runs-on: default
env:
CGO_ENABLED: '0'
steps:
- uses: https://code.forgejo.org/actions/setup-go@v7
with:
go-version: '1.27'
- uses: https://code.forgejo.org/forgejo/download-artifact@v4
with:
name: agent-binaries
path: bin/dist
- uses: https://code.forgejo.org/forgejo/download-artifact@v4
with:
name: server-binary
path: bin
- uses: https://code.forgejo.org/forgejo/download-artifact@v4
with:
pattern: build-reports-*
path: reports
- run: |
set -eu
go install github.com/anchore/syft/cmd/syft@v1.55.0
mkdir -p sbom
for f in bin/dist/* bin/vop-server; do
"$(go env GOPATH)/bin/syft" scan "file:${f}" -o "cyclonedx-json=sbom/$(basename "${f}").cdx.json"
done
for n in backend:backend frontend:frontend k8s-agent:k8s-agent agent:agent; do
src="$(find "reports/build-reports-${n%%:*}" -name image-scan-report.bom.json | head -n1)"
[ -n "$src" ] || { echo "no SBOM of image ${n%%:*}"; exit 1; }
mv "$src" "sbom/image-${n##*:}.cdx.json"
done
# A file that is not CycloneDX must not be published as one.
for f in sbom/*.json; do
grep -q '"bomFormat": *"CycloneDX"' "${f}" || { echo "${f} is not a CycloneDX document"; exit 1; }
done
- uses: https://code.forgejo.org/forgejo/upload-artifact@v4
with:
name: sbom
path: sbom/
retention-days: 7
upload-sboms:
# Upload the SBOMs next to the agent releases, under the same version. They are public
# like the agent binaries, so the bucket must allow reading the sboms/ prefix.
if: github.ref_name == github.event.repository.default_branch && github.ref_type == 'branch'
needs: [sbom]
runs-on: default
env:
AWS_DEFAULT_REGION: us-east-1
S3_ENDPOINT: ${{ secrets.S3_ENDPOINT }}
S3_BUCKET: ${{ secrets.S3_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.S3_ACCESS_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_SECRET_KEY }}
AWS_REQUEST_CHECKSUM_CALCULATION: when_required
AWS_RESPONSE_CHECKSUM_VALIDATION: when_required
steps:
- uses: https://code.forgejo.org/forgejo/download-artifact@v4
with:
name: sbom
path: sbom
- run: |
set -eu
pip install --quiet --user awscli || pip install --quiet --break-system-packages awscli
export PATH="$HOME/.local/bin:$PATH"
VERSION="1.0.$((GITHUB_RUN_NUMBER + VERSION_OFFSET))"
aws configure set default.s3.addressing_style path
for f in sbom/*.json; do
name=$(basename "${f}")
echo "Uploading ${name} to s3://${S3_BUCKET}/sboms/${VERSION}/..."
aws s3 cp "${f}" "s3://${S3_BUCKET}/sboms/${VERSION}/${name}" --endpoint-url "https://${S3_ENDPOINT}" --region us-east-1 --content-type application/json
done
chart-k8s-agent:
# Packages the Kubernetes agent chart: the node agent and the host agent of a cluster.
# Pushed to the same OCI chart repository as the backend chart.
needs: [k8s-agent-docker, host-agent-docker]
if: github.ref_type == 'tag' || github.ref_name == github.event.repository.default_branch
uses: infra/ci-snippets/.forgejo/workflows/helm-build.yml@master
with:
chart-path: deploy/helm/vop-k8s-agent
push: true
lint-args: --strict
# Flux picks the highest version: patch is run number plus the last GitLab pipeline ID (128877).
version-from-run-number: true
version-offset: '128877'
pre-package: |
set -eu
CHART_DIR=deploy/helm/vop-k8s-agent
sed -i "s|__GIT_COMMIT_SHA__|$GITHUB_SHA|g; s|__CI_REGISTRY_IMAGE__|$REGISTRY/$(echo "$GITHUB_REPOSITORY" | tr 'A-Z' 'a-z')|g" "$CHART_DIR/values.yaml"
if grep -q "__GIT_COMMIT_SHA__\|__CI_REGISTRY_IMAGE__" "$CHART_DIR/values.yaml"; then echo "placeholder left in values.yaml"; exit 1; fi
extra-checks: |
set -eu
CHART_DIR=deploy/helm/vop-k8s-agent
# Render the configuration the chart is installed with, so template failures show up here.
helm template ci "$CHART_DIR" --set server.url=https://vop.example.com --set cluster.name=ci --set cluster.registrationToken=vopk_ci > /dev/null
# An existing secret instead of the inline token.
helm template ci "$CHART_DIR" --set server.url=https://vop.example.com --set cluster.name=ci --set cluster.existingSecret=cluster-token > /dev/null
secrets: inherit
chart:
# Renders the chart, packages it and pushes it to the project's OCI registry:
# helm install vop oci://forgejo.jonasled.dev/jonasled/vulnerability-operator/charts/vulnerability-operator --version <version>
# The job needs both image builds, so it runs only if they succeeded. The chart's image
# repositories and tags are set to this project's registry path and this commit's SHA.
needs: [backend-docker, frontend-docker]
if: github.ref_type == 'tag' || github.ref_name == github.event.repository.default_branch
uses: infra/ci-snippets/.forgejo/workflows/helm-build.yml@master
with:
chart-path: deploy/helm/vulnerability-operator
push: true
lint-args: --strict
# Flux picks the highest version: patch is run number plus the last GitLab pipeline ID (128877).
version-from-run-number: true
version-offset: '128877'
pre-package: |
set -eu
CHART_DIR=deploy/helm/vulnerability-operator
sed -i "s|__GIT_COMMIT_SHA__|$GITHUB_SHA|g; s|__CI_REGISTRY_IMAGE__|$REGISTRY/$(echo "$GITHUB_REPOSITORY" | tr 'A-Z' 'a-z')|g" "$CHART_DIR/values.yaml"
if grep -q "__GIT_COMMIT_SHA__\|__CI_REGISTRY_IMAGE__" "$CHART_DIR/values.yaml"; then echo "placeholder left in values.yaml"; exit 1; fi
extra-checks: |
set -eu
CHART_DIR=deploy/helm/vulnerability-operator
# Render the common configurations so template failures show up in CI.
# sqlite with inline secrets, the default setup.
helm template ci "$CHART_DIR" --set secrets.inline.adminPassword=ci --set secrets.inline.s3AccessKey=ci --set secrets.inline.s3SecretKey=ci > /dev/null
# postgres with two replicas, the ingress and the inline secrets.
helm template ci "$CHART_DIR" --set config.database.driver=postgres --set config.database.host=db --set config.database.port=5432 --set config.database.user=vop --set secrets.inline.dbPassword=ci --set secrets.inline.s3AccessKey=ci --set secrets.inline.s3SecretKey=ci --set backend.replicaCount=2 --set ingress.enabled=true --set 'ingress.hosts={vop.example.com}' > /dev/null
# An existing secret instead of inline values.
helm template ci "$CHART_DIR" --set secrets.existingSecret=vop-secrets > /dev/null
secrets: inherit

View file

@ -1,471 +0,0 @@
stages:
- test
- build
- docs
- release
- bundle
- deploy
# Modules come from the project's Go proxy. Direct download is the fallback.
variables:
GOPROXY: https://goproxy.jonasled.dev,direct
# The documentation jobs run for merge requests and for the default branch, so
# every change that is merged shows up in the published manual.
.docs-rules:
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
WebBuild:
# The web interface, embedded into the server binary by the ServerBinary job.
# Built here so that the documentation screenshots show the same UI as the server.
extends: .docs-rules
image: node:26.13-alpine@sha256:c6ad9e9c1d80f6eb607c26b4b0a132ff7a2344fad1c78ea3baa2a7d4c8de6d94
stage: test
needs: []
script:
- cd web
- npm install -g pnpm@12.14.0
- pnpm install --frozen-lockfile
- pnpm build
artifacts:
paths:
- web/dist/
expire_in: 1 day
GoChecks:
# `make check-go`: gofmt, vet and golangci-lint on Linux, Windows and macOS, the Go
# tests, and a check that the swagger docs are up to date. Run `make check` before
# every commit. It runs the same targets as this job.
image: golang:1.27.3-alpine
stage: test
needs: []
variables:
CGO_ENABLED: "0"
before_script:
- apk add --no-cache git make
script:
- go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.15.0
- make check-go GOLANGCI_LINT=$(go env GOPATH)/bin/golangci-lint
WebChecks:
# `make check-web`: the TypeScript check of the React UI. Run with `make check`.
image: node:26.13-alpine@sha256:c6ad9e9c1d80f6eb607c26b4b0a132ff7a2344fad1c78ea3baa2a7d4c8de6d94
stage: test
needs: []
before_script:
- apk add --no-cache make
script:
- npm install -g pnpm@12.14.0
- make check-web
BuildAgentBinaries:
# Cross-compile the agent binary for Linux amd64 and arm64, Windows amd64, and macOS amd64 and arm64.
image: golang:1.27.3-alpine
stage: build
needs: []
variables:
CGO_ENABLED: "0"
before_script:
- apk add --no-cache git
script:
- export VERSION="1.0.${CI_PIPELINE_ID}"
- export MODULE="jonasled.dev/jonasled/vulnerability-operator"
- export LDFLAGS="-s -w -X ${MODULE}/internal/version.Version=${VERSION}"
- mkdir -p bin/dist
- GOOS=linux GOARCH=amd64 go build -trimpath -ldflags "${LDFLAGS}" -o bin/dist/vop-agent-linux-amd64 ./cmd/agent
- GOOS=linux GOARCH=arm64 go build -trimpath -ldflags "${LDFLAGS}" -o bin/dist/vop-agent-linux-arm64 ./cmd/agent
- GOOS=windows GOARCH=amd64 go build -trimpath -ldflags "${LDFLAGS}" -o bin/dist/vop-agent-windows-amd64.exe ./cmd/agent
- GOOS=darwin GOARCH=amd64 go build -trimpath -ldflags "${LDFLAGS}" -o bin/dist/vop-agent-darwin-amd64 ./cmd/agent
- GOOS=darwin GOARCH=arm64 go build -trimpath -ldflags "${LDFLAGS}" -o bin/dist/vop-agent-darwin-arm64 ./cmd/agent
artifacts:
paths:
- bin/dist/
expire_in: 1 day
ServerBinary:
# The server with the web interface embedded, for the screenshots of the documentation.
extends: .docs-rules
image: golang:1.27.3-alpine
stage: build
needs:
- WebBuild
variables:
CGO_ENABLED: "0"
before_script:
- apk add --no-cache git
script:
- export MODULE="jonasled.dev/jonasled/vulnerability-operator"
- export VERSION="1.0.${CI_PIPELINE_ID}"
- mkdir -p bin
- go build -trimpath -ldflags "-s -w -X ${MODULE}/internal/version.Version=${VERSION}" -o bin/vop-server ./cmd/server
artifacts:
paths:
- bin/vop-server
expire_in: 1 day
BackendDocker:
# The backend Dockerfile sits in the repository root.
image: jonasled.dev/infra/docker-build:master@sha256:af92638195740083c2de64db6b9807da647e0b01dfec335a72618c5d00e96cce
stage: build
needs: []
script:
- export IMAGE_NAME=$CI_REGISTRY_IMAGE/backend
- build-image
- mv image-hash.txt image-hash-backend.txt
- mv image-scan-report.bom.json backend.bom.json
artifacts:
paths:
- image-hash-backend.txt
- backend.bom.json
FrontendDocker:
# The frontend Dockerfile and nginx.conf sit in web/.
image: jonasled.dev/infra/docker-build:master@sha256:af92638195740083c2de64db6b9807da647e0b01dfec335a72618c5d00e96cce
stage: build
needs: []
script:
- export IMAGE_NAME=$CI_REGISTRY_IMAGE/frontend
- cd web
- build-image
- mv image-hash.txt ../image-hash-frontend.txt
- mv image-scan-report.bom.json ../frontend.bom.json
artifacts:
paths:
- image-hash-frontend.txt
- frontend.bom.json
K8sAgentDocker:
# The node agent image, built from Dockerfile.k8s-agent.
image: jonasled.dev/infra/docker-build:master@sha256:af92638195740083c2de64db6b9807da647e0b01dfec335a72618c5d00e96cce
stage: build
needs: []
script:
# The version the agent reports: the one of the agent binaries of this pipeline.
- export BUILDKIT_ADDITIONAL_ARGS="--opt filename=Dockerfile.k8s-agent --opt build-arg:VERSION=1.0.${CI_PIPELINE_ID}"
- export IMAGE_NAME=$CI_REGISTRY_IMAGE/k8s-agent
- build-image
- mv image-hash.txt image-hash-k8s-agent.txt
- mv image-scan-report.bom.json k8s-agent.bom.json
artifacts:
paths:
- image-hash-k8s-agent.txt
- k8s-agent.bom.json
HostAgentDocker:
# The linux agent image for the host DaemonSet of the Kubernetes chart, built from Dockerfile.agent.
image: jonasled.dev/infra/docker-build:master@sha256:af92638195740083c2de64db6b9807da647e0b01dfec335a72618c5d00e96cce
stage: build
needs: []
script:
# The version the agent reports: the one of the agent binaries of this pipeline.
- export BUILDKIT_ADDITIONAL_ARGS="--opt filename=Dockerfile.agent --opt build-arg:VERSION=1.0.${CI_PIPELINE_ID}"
- export IMAGE_NAME=$CI_REGISTRY_IMAGE/agent
- build-image
- mv image-hash.txt image-hash-agent.txt
- mv image-scan-report.bom.json agent-image.bom.json
artifacts:
paths:
- image-hash-agent.txt
- agent-image.bom.json
UploadAgentReleases:
# Upload the built agent binaries directly to S3 for public download.
# Requires S3_ENDPOINT, S3_ACCESS_KEY, S3_SECRET_KEY, S3_BUCKET to be set.
image: amazon/aws-cli:latest
stage: release
needs:
- BuildAgentBinaries
variables:
BIN_DIR: bin/dist
AWS_DEFAULT_REGION: us-east-1
# Only the binaries from the artifacts are used, so the repository is not cloned.
GIT_STRATEGY: none
script:
- export VERSION="1.0.${CI_PIPELINE_ID}"
- export S3_ENDPOINT="${S3_ENDPOINT:-localhost:9000}"
- export S3_BUCKET="${S3_BUCKET:-vulnerability-operator}"
- |
# Configure AWS CLI for S3-compatible endpoint (MinIO, etc.)
aws configure set aws_access_key_id "${S3_ACCESS_KEY}"
aws configure set aws_secret_access_key "${S3_SECRET_KEY}"
# Path-style addressing: the bucket is in the path, not the host name.
aws configure set default.s3.addressing_style path
- |
upload_binary() {
local file=$1
local s3_key="agent-releases/${VERSION}/${file}"
echo "Uploading ${file} to s3://${S3_BUCKET}/${s3_key}..."
aws s3 cp "${BIN_DIR}/${file}" "s3://${S3_BUCKET}/${s3_key}" \
--endpoint-url "https://${S3_ENDPOINT}" \
--region us-east-1 \
|| exit 1
echo "✓ ${file} uploaded to ${s3_key}"
}
- upload_binary vop-agent-linux-amd64
- upload_binary vop-agent-linux-arm64
- upload_binary vop-agent-windows-amd64.exe
- upload_binary vop-agent-darwin-amd64
- upload_binary vop-agent-darwin-arm64
only:
- master
PublishReleaseManifest:
# Writes releases.json next to the binaries, which the server reads to list the
# published agent versions. It runs only after the upload succeeded: a manifest
# must not point at binaries that are not in the bucket.
image: python:3.15-alpine
stage: release
needs:
- BuildAgentBinaries
- UploadAgentReleases
variables:
BIN_DIR: bin/dist
AWS_DEFAULT_REGION: us-east-1
script:
- export VERSION="1.0.${CI_PIPELINE_ID}"
- export S3_ENDPOINT="${S3_ENDPOINT:-localhost:9000}"
- export S3_BUCKET="${S3_BUCKET:-vulnerability-operator}"
- pip install --quiet awscli
- aws configure set aws_access_key_id "${S3_ACCESS_KEY}"
- aws configure set aws_secret_access_key "${S3_SECRET_KEY}"
- aws configure set default.s3.addressing_style path
- python3 scripts/publish-release-manifest.py
only:
- master
SBOM:
# CycloneDX SBOMs of every binary of this pipeline, and of the images the build jobs made.
# syft is pinned to the version of go.mod, the one the server scans with.
image: golang:1.27.3-alpine
stage: release
needs:
- BuildAgentBinaries
- ServerBinary
- BackendDocker
- FrontendDocker
- K8sAgentDocker
- HostAgentDocker
variables:
CGO_ENABLED: "0"
before_script:
- apk add --no-cache git
script:
- go install github.com/anchore/syft/cmd/syft@v1.55.0
- mkdir -p sbom
- |
for f in bin/dist/* bin/vop-server; do
"$(go env GOPATH)/bin/syft" scan "file:${f}" -o "cyclonedx-json=sbom/$(basename "${f}").cdx.json"
done
- mv backend.bom.json sbom/image-backend.cdx.json
- mv frontend.bom.json sbom/image-frontend.cdx.json
- mv k8s-agent.bom.json sbom/image-k8s-agent.cdx.json
- mv agent-image.bom.json sbom/image-agent.cdx.json
# A file that is not CycloneDX must not be published as one.
- |
for f in sbom/*.json; do
grep -q '"bomFormat": *"CycloneDX"' "${f}" || { echo "${f} is not a CycloneDX document"; exit 1; }
done
only:
- master
artifacts:
paths:
- sbom/
expire_in: 1 week
UploadSBOMs:
# Upload the SBOMs next to the agent releases, under the same version. They are public
# like the agent binaries, so the bucket must allow reading the sboms/ prefix.
image: amazon/aws-cli:latest
stage: release
needs:
- SBOM
variables:
AWS_DEFAULT_REGION: us-east-1
# Only the SBOMs from the artifacts are used, so the repository is not cloned.
GIT_STRATEGY: none
script:
- export VERSION="1.0.${CI_PIPELINE_ID}"
- export S3_ENDPOINT="${S3_ENDPOINT:-localhost:9000}"
- export S3_BUCKET="${S3_BUCKET:-vulnerability-operator}"
- aws configure set aws_access_key_id "${S3_ACCESS_KEY}"
- aws configure set aws_secret_access_key "${S3_SECRET_KEY}"
- aws configure set default.s3.addressing_style path
- |
for f in sbom/*.json; do
name=$(basename "${f}")
echo "Uploading ${name} to s3://${S3_BUCKET}/sboms/${VERSION}/..."
aws s3 cp "${f}" "s3://${S3_BUCKET}/sboms/${VERSION}/${name}" \
--endpoint-url "https://${S3_ENDPOINT}" \
--region us-east-1 \
--content-type application/json \
|| exit 1
done
only:
- master
HelmChartK8sAgent:
# Packages the Kubernetes agent chart: the node agent and the host agent of a
# cluster. Pushed to the same OCI chart repository as the backend chart.
image:
name: alpine/helm:4.3.1
entrypoint: [""]
stage: bundle
needs:
- K8sAgentDocker
- HostAgentDocker
variables:
CHART_DIR: deploy/helm/vop-k8s-agent
CHART_REPO: oci://$CI_REGISTRY/$CI_PROJECT_PATH/charts
script:
- sed -i "s|__GIT_COMMIT_SHA__|$CI_COMMIT_SHA|g; s|__CI_REGISTRY_IMAGE__|$CI_REGISTRY_IMAGE|g" "$CHART_DIR/values.yaml"
- if grep -q "__GIT_COMMIT_SHA__\|__CI_REGISTRY_IMAGE__" "$CHART_DIR/values.yaml"; then echo "placeholder left in values.yaml"; exit 1; fi
- helm lint "$CHART_DIR" --strict
# Render the configuration the chart is installed with, so template failures show up here.
- helm template ci "$CHART_DIR" --set server.url=https://vop.example.com --set cluster.name=ci --set cluster.registrationToken=vopk_ci > /dev/null
# An existing secret instead of the inline token.
- helm template ci "$CHART_DIR" --set server.url=https://vop.example.com --set cluster.name=ci --set cluster.existingSecret=cluster-token > /dev/null
- |
# Same versioning as the backend chart: major.minor from Chart.yaml, patch from the global pipeline ID.
BASE_VERSION=$(sed -n 's/^version: *//p' "$CHART_DIR/Chart.yaml" | cut -d. -f1,2)
CHART_VERSION="${BASE_VERSION}.${CI_PIPELINE_ID}"
helm package "$CHART_DIR" --version "$CHART_VERSION" --app-version "$CI_COMMIT_SHA" --destination dist
- helm registry login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"
- helm push dist/vop-k8s-agent-*.tgz "$CHART_REPO"
rules:
- if: $CI_COMMIT_TAG
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
artifacts:
paths:
- dist/
HelmChart:
# Renders the chart, packages it and pushes it to the project's OCI registry:
# helm install vop oci://$CI_REGISTRY/$CI_PROJECT_PATH/charts/vulnerability-operator --version <version>
# The job needs both image builds, so it runs only if they succeeded. The chart's image
# repositories and tags are set to this project's registry path and this commit's SHA.
image:
name: alpine/helm:4.3.1
entrypoint: [""]
stage: bundle
needs:
- BackendDocker
- FrontendDocker
variables:
CHART_DIR: deploy/helm/vulnerability-operator
CHART_REPO: oci://$CI_REGISTRY/$CI_PROJECT_PATH/charts
script:
- sed -i "s|__GIT_COMMIT_SHA__|$CI_COMMIT_SHA|g; s|__CI_REGISTRY_IMAGE__|$CI_REGISTRY_IMAGE|g" "$CHART_DIR/values.yaml"
- if grep -q "__GIT_COMMIT_SHA__\|__CI_REGISTRY_IMAGE__" "$CHART_DIR/values.yaml"; then echo "placeholder left in values.yaml"; exit 1; fi
- helm lint "$CHART_DIR" --strict
# Render the common configurations so template failures show up in CI.
# sqlite with inline secrets, the default setup.
- helm template ci "$CHART_DIR" --set secrets.inline.adminPassword=ci --set secrets.inline.s3AccessKey=ci --set secrets.inline.s3SecretKey=ci > /dev/null
# postgres with two replicas, the ingress and the inline secrets.
- helm template ci "$CHART_DIR" --set config.database.driver=postgres --set config.database.host=db --set config.database.port=5432 --set config.database.user=vop --set secrets.inline.dbPassword=ci --set secrets.inline.s3AccessKey=ci --set secrets.inline.s3SecretKey=ci --set backend.replicaCount=2 --set ingress.enabled=true --set 'ingress.hosts={vop.example.com}' > /dev/null
# An existing secret instead of inline values.
- helm template ci "$CHART_DIR" --set secrets.existingSecret=vop-secrets > /dev/null
- |
# Flux picks the highest version, so versions must only grow. The patch number is the global pipeline ID,
# which increases with every pipeline of the project. The major.minor part comes from Chart.yaml.
BASE_VERSION=$(sed -n 's/^version: *//p' "$CHART_DIR/Chart.yaml" | cut -d. -f1,2)
CHART_VERSION="${BASE_VERSION}.${CI_PIPELINE_ID}"
helm package "$CHART_DIR" --version "$CHART_VERSION" --app-version "$CI_COMMIT_SHA" --destination dist
- helm registry login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"
- helm push dist/vulnerability-operator-*.tgz "$CHART_REPO"
rules:
- if: $CI_COMMIT_TAG
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
artifacts:
paths:
- dist/
DocsScreenshots:
# Starts the server against Redis with local storage, fills it with demo data, captures the
# screenshots in a real browser, and builds the manual with them. Any missing image
# fails the build (DOCS_STRICT). The build is published by the pages job.
extends: .docs-rules
image: mcr.microsoft.com/playwright:v1.64.1-noble
stage: docs
needs:
- ServerBinary
timeout: 1h
# The Grype database (about 3 GB) is kept between pipelines. The server downloads a
# newer one only when upstream has one, so an unchanged database costs no download.
cache:
key: grype-db
paths:
- data/grype/
policy: pull-push
services:
- name: redis:8-alpine
alias: redis
variables:
# The address the manual is published under, so that its links and images resolve.
DOCS_URL: $CI_PAGES_URL
DOCS_STRICT: "1"
VERSION: "1.0.${CI_PIPELINE_ID}"
VOP_URL: http://localhost:8080
VOP_ADMIN_EMAIL: admin@localhost
STORAGE_BACKEND: local
REDIS_ADDR: redis:6379
script:
- npm install -g pnpm@12.14.0
- cd site && pnpm install --frozen-lockfile && cd ..
- |
# A new administrator password for every run. The server reads it only when its database is new.
export VOP_ADMIN_PASSWORD="$(head -c 24 /dev/urandom | base64 | tr -dc 'A-Za-z0-9')"
- |
# Wait for Redis. It is checked on its port.
for i in $(seq 1 60); do
bash -c 'exec 3<>/dev/tcp/redis/6379' 2> /dev/null && break
sleep 2
done
- |
# Start the server with a fresh database and wait until it is ready.
export GRYPE_DB_DIR="${CI_PROJECT_DIR}/data/grype"
mkdir -p "${GRYPE_DB_DIR}"
export INITIAL_ADMIN_PASSWORD="${VOP_ADMIN_PASSWORD}" HTTP_ADDR=:8080 DB_DRIVER=sqlite DB_NAME="${CI_PROJECT_DIR}/data/docs.db" STORAGE_DIR="${CI_PROJECT_DIR}/data/storage" LOG_LEVEL=INFO
nohup bin/vop-server > server.log 2>&1 &
for i in $(seq 1 60); do
curl -fsS http://localhost:8080/readyz > /dev/null 2>&1 && break
sleep 2
done
curl -fsS http://localhost:8080/readyz || { tail -n 50 server.log; exit 1; }
- cd site
- VOP_STATE="${CI_PROJECT_DIR}/data/state.json" node screenshots/seed.mjs
- VOP_STATE="${CI_PROJECT_DIR}/data/state.json" node screenshots/capture.mjs
- pnpm build
after_script:
- pkill -x vop-server || true
artifacts:
when: always
paths:
- site/build/
- site/static/img/screenshots/
- server.log
expire_in: 1 week
pages:
# GitLab Pages publishes the public/ folder at the project's pages address. Only the
# default branch is published; merge requests build the manual without publishing it.
stage: deploy
image: alpine:3.24
needs:
- DocsScreenshots
variables:
# The manual comes from the artifacts of DocsScreenshots, so the repository is not cloned.
GIT_STRATEGY: none
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
script:
- rm -rf public
- mv site/build public
artifacts:
paths:
- public
expire_in: 1 week

View file

@ -88,12 +88,13 @@ console is on http://localhost:9001.
## Documentation
The published docs are at [vulnerability-operator-8c2480.jonasled.dev](https://vulnerability-operator-8c2480.jonasled.dev).
The docs used to be published at vulnerability-operator-8c2480.jonasled.dev (GitLab Pages). Pages are not available on Forgejo yet, so build them locally.
The user guide, the administrator guide and the reference are in `site/`, built
with Docusaurus. The screenshots in them are not kept in the repository: each
pipeline captures them again from a server that holds demo data, and the pages
job publishes the result to GitLab Pages. See `site/README.md`.
pipeline used to capture them again from a server that holds demo data and publish
the result to GitLab Pages. Forgejo has no Pages, so that job is gone and the manual
is not published (tracked in jonasled/k8s-flux issue 5). See `site/README.md`.
```sh
make docs # build the site into site/build
@ -290,20 +291,21 @@ filesystem. Everything it writes goes to the `/data` volume.
## Continuous integration
`.gitlab-ci.yml` runs these stages:
`.forgejo/workflows/ci.yml` runs these jobs:
| Stage | Job | What it does |
|---|---|---|
| test | GoChecks | `make check-go`: gofmt, `go vet` and golangci-lint on Linux, Windows and macOS, `go test ./...`, and the swagger docs in sync |
| test | WebChecks | `make check-web`: the TypeScript check of the web interface |
| test | WebBuild | builds the web interface, for the server and the screenshots (merge requests and the default branch) |
| build | BackendDocker, FrontendDocker | builds and scans the images, tags them with the commit SHA |
| build | ServerBinary | builds `vop-server` with the web interface embedded (merge requests and the default branch) |
| docs | DocsScreenshots | runs the server against Redis with local storage, fills it with demo data, captures the screenshots and builds the documentation (merge requests and the default branch) |
| release | UploadAgentReleases, PublishReleaseManifest | publish the agent binaries (default branch only) |
| release | SBOM, UploadSBOMs | make CycloneDX SBOMs of the binaries and images, and upload them to `sboms/<version>/` in the bucket (default branch only) |
| bundle | HelmChart, HelmChartK8sAgent | renders the charts, packages them and pushes them to the project's OCI registry |
| deploy | pages | publishes the documentation to GitLab Pages (default branch only) |
| Job | What it does |
|---|---|
| go-checks | `make check-go`: gofmt, `go vet` and golangci-lint on Linux, Windows and macOS, `go test ./...`, and the swagger docs in sync |
| web-checks | `make check-web`: the TypeScript check of the web interface |
| web-build, server-binary | build the web interface and `vop-server` with it embedded (for the SBOM) |
| agent-binaries | cross-compiles the agent for Linux, Windows and macOS |
| backend-docker, frontend-docker, k8s-agent-docker, host-agent-docker | build and scan the images, tag them with the commit SHA |
| upload-agent-releases, publish-release-manifest | publish the agent binaries (default branch only) |
| sbom, upload-sboms | make CycloneDX SBOMs of the binaries and images, and upload them to `sboms/<version>/` in the bucket (default branch only) |
| chart, chart-k8s-agent | render the charts, package them and push them to the project's OCI registry |
The documentation build (screenshots and Docusaurus site) and its GitLab Pages
publishing are not ported: Forgejo has no Pages (jonasled/k8s-flux issue 5).
No job deploys the backend chart: Flux pulls it from the registry.

View file

@ -1,8 +1,9 @@
# Documentation site
The user guide, the administrator guide and the reference of Vulnerability Operator.
The site is built with [Docusaurus](https://docusaurus.io) and published to GitLab
Pages by the pipeline of the repository.
The site is built with [Docusaurus](https://docusaurus.io) and built locally. It
used to be published to GitLab Pages by the pipeline; Forgejo has no Pages, so
it is currently not published (jonasled/k8s-flux issue 5).
```text
site/
@ -62,19 +63,8 @@ each inside its theme div (`screenshot-light` or `screenshot-dark`), as in
## CI
The pipeline (see `.gitlab-ci.yml`) runs on merge requests and on the default branch:
1. `WebBuild` builds the web interface, and `ServerBinary` builds the server with it.
2. `DocsScreenshots` starts the server with Redis and MinIO as services, runs the seed and
the capture, and builds the site with `DOCS_STRICT=1`, which fails on a missing image.
`DOCS_URL` is the GitLab Pages address of the project. `VERSION` is the build version shown in the footer; CI sets it from the pipeline ID, local builds show `dev`.
3. `pages`, on the default branch only, publishes `site/build` to GitLab Pages.
Every change therefore produces new screenshots and a new manual, and a broken link or a
missing image stops the pipeline.
### Grype database cache
The vulnerability database is about 3 GB. `DocsScreenshots` keeps `data/grype/` in the
GitLab cache (key `grype-db`), so the server downloads only when upstream is newer.
The first pipeline, or a cache that has expired, downloads it in full.
The old GitLab pipeline built the web interface and the server, started the server with
Redis, ran the seed and the capture, built the site with `DOCS_STRICT=1` and published it
to GitLab Pages. The Forgejo workflow does not run these steps (no Pages on Forgejo,
jonasled/k8s-flux issue 5), so a broken link or a missing image is only found by a local
`make docs-screenshots`.