From d96fc4d36b09c76ae379792044a1703637f57c5a Mon Sep 17 00:00:00 2001 From: codex Date: Sun, 18 Oct 2026 08:37:44 +0300 Subject: [PATCH] ci: set container action entrypoints --- .gitea/actions/caddy-validate/action.yml | 1 + .gitea/actions/kaniko-build/action.yml | 1 + docs/operations/CI_RUNNER.md | 23 +++++++++-------- docs/operations/CURRENT_STATE.md | 17 +++++++------ infra/runner/test-ci-container-builds.sh | 32 +++++++++++++++++------- 5 files changed, 48 insertions(+), 26 deletions(-) diff --git a/.gitea/actions/caddy-validate/action.yml b/.gitea/actions/caddy-validate/action.yml index af58b79..107661f 100644 --- a/.gitea/actions/caddy-validate/action.yml +++ b/.gitea/actions/caddy-validate/action.yml @@ -3,6 +3,7 @@ description: Run the pinned Caddy validator against the checked-out Caddyfile runs: using: docker image: Dockerfile + entrypoint: /usr/bin/caddy args: - validate - --config diff --git a/.gitea/actions/kaniko-build/action.yml b/.gitea/actions/kaniko-build/action.yml index b85a09a..c79057e 100644 --- a/.gitea/actions/kaniko-build/action.yml +++ b/.gitea/actions/kaniko-build/action.yml @@ -10,6 +10,7 @@ inputs: runs: using: docker image: Dockerfile + entrypoint: /kaniko/executor args: - --context=dir:///github/workspace - --dockerfile=/github/workspace/${{ inputs.dockerfile }} diff --git a/docs/operations/CI_RUNNER.md b/docs/operations/CI_RUNNER.md index 75923b2..1f8747c 100644 --- a/docs/operations/CI_RUNNER.md +++ b/docs/operations/CI_RUNNER.md @@ -45,9 +45,10 @@ metrics ports are needed. Runner cache is disabled. The CI workflow and `runner-smoke.yaml` target the repository runner label `akyldash-ci`. CI keeps the backend, Telegram, backup/restore, deployment, bootstrap, runner, Compose, and Caddy checks. Caddy validation runs in a pinned -container action. Both production Dockerfiles are built in a separate pinned -Kaniko container action using the runner's rootless container engine; the job -container receives no Docker socket. Kaniko uses `--no-push` and +container action with explicit `/usr/bin/caddy` entrypoint. Both production +Dockerfiles are built in a separate pinned Kaniko container action with explicit +`/kaniko/executor` entrypoint using the runner's rootless container engine; the +job container receives no Docker socket. Kaniko uses `--no-push` and `--no-push-cache`, so CI validates the full backend and OpenSearch builds but does not publish images or export build output. The two builds run sequentially within one job; peak memory and disk use still require a runner canary. No registry credentials, @@ -192,10 +193,12 @@ while the smoke workflow used `akyldash-ci`; the label difference is a plausible explanation for the pending status, but the runner inventory API returned 403 and the scheduler's reason was not independently confirmed. -On head `3a89dc21`, Gitea reported CI run 63 failed at `Check host audit root -guard` and smoke run 64 succeeded. The job had not reached Caddy or Kaniko, so -their execution and resource fit remain unverified. This PR changes the root -guard tests to use `setpriv` for their negative path when a job starts as UID 0. -A separate test evaluates the extracted host-audit guard with simulated UID 0 -and UID 65534; the real audit, config setup, and runner installer are never -executed as root by those tests. No VPS changes are part of this PR. +On head `3a89dc21`, CI run 63 failed at the host audit root guard and smoke run +64 succeeded. On head `436806a8`, CI run 65 failed in the Caddy container action +with `exec: "validate": executable file not found`; Kaniko was skipped and smoke +run 66 succeeded. This PR sets explicit Caddy and Kaniko entrypoints. Successful +execution and resource fit still require a new runner canary. Root-guard tests +use `setpriv` for negative cases when jobs start as UID 0 and separately test +the host-audit guard with simulated UID 0 and UID 65534; the real host audit, +production config setup, and runner installer are never executed as root by +those tests. No VPS changes are part of this PR. diff --git a/docs/operations/CURRENT_STATE.md b/docs/operations/CURRENT_STATE.md index f2aed84..4e2b2c5 100644 --- a/docs/operations/CURRENT_STATE.md +++ b/docs/operations/CURRENT_STATE.md @@ -95,9 +95,11 @@ UFW rule details, and protected file metadata remain unverified. pending on PR head `69c62466`. The workflow/label difference may explain that pending status, but the scheduler reason was not independently verified. On head `3a89dc21`, CI run 63 failed at the host audit root guard and smoke run 64 - succeeded; Caddy and Kaniko steps were skipped. No VPS changes are made by - this PR. The new actions and fit within the configured 3 GiB / 2 CPU per-job - limits remain unverified. + succeeded. On head `436806a8`, CI run 65 failed in the Caddy container action + with `exec: "validate": executable file not found`; Kaniko was skipped and + smoke run 66 succeeded. This PR pins explicit action entrypoints. No VPS + changes are made; successful image builds and fit within the configured 3 GiB + / 2 CPU per-job limits remain unverified. - An isolated local Compose smoke test built backend/OpenSearch images, reached healthy status for OpenSearch, backend, and Caddy, and returned HTTP 200 for `/review` through Caddy. Its containers, networks, and volumes were @@ -148,7 +150,8 @@ UFW rule details, and protected file metadata remain unverified. The branch targets `akyldash-ci` and uses digest-pinned isolated actions for Caddy validation and the two production Dockerfile builds. Kaniko image publishing and cache publishing are disabled. This repository change does not -modify the VPS or grant workflow containers a Docker socket. Gitea CI run 63 failed at the host audit root-guard test before reaching -Caddy or Kaniko actions. The smoke run succeeded. This PR updates the root-guard -tests; a later successful run must verify the container actions and resource -fit before they are considered validated runner behavior. +modify the VPS or grant workflow containers a Docker socket. CI run 65 failed +in the Caddy action because the runner tried to execute `validate` directly; +Kaniko was skipped. This PR sets explicit action entrypoints. A successful run +must verify Caddy, both image builds, and resource fit before these actions are +considered validated runner behavior. diff --git a/infra/runner/test-ci-container-builds.sh b/infra/runner/test-ci-container-builds.sh index 1ed053e..e388c87 100644 --- a/infra/runner/test-ci-container-builds.sh +++ b/infra/runner/test-ci-container-builds.sh @@ -10,25 +10,39 @@ grep -Fq 'uses: ./.gitea/actions/caddy-validate' "$workflow" grep -Fq 'dockerfile: deploy/production/Dockerfile.backend' "$workflow" grep -Fq 'dockerfile: deploy/production/Dockerfile.opensearch' "$workflow" grep -Fq 'docker compose --env-file deploy/production/.env.example -f deploy/production/compose.yaml config --quiet' "$workflow" -grep -Fq ' - validate' .gitea/actions/caddy-validate/action.yml -grep -Fq '/github/workspace/deploy/production/Caddyfile' .gitea/actions/caddy-validate/action.yml -grep -Fq ' - caddyfile' .gitea/actions/caddy-validate/action.yml +caddy_action=.gitea/actions/caddy-validate/action.yml +grep -Fxq ' entrypoint: /usr/bin/caddy' "$caddy_action" +grep -Fxq ' - validate' "$caddy_action" +grep -Fxq ' - --config' "$caddy_action" +grep -Fxq ' - /github/workspace/deploy/production/Caddyfile' "$caddy_action" +grep -Fxq ' - --adapter' "$caddy_action" +grep -Fxq ' - caddyfile' "$caddy_action" if grep -Eq 'docker (build|run)([[:space:]]|$)' "$workflow"; then echo 'workflow must not invoke docker build/run in a job container' >&2 exit 1 fi -check_kaniko_publish_flags() { - grep -Fxq -- ' - --no-push' "$1" && +check_kaniko_action() { + grep -Fxq ' entrypoint: /kaniko/executor' "$1" && + grep -Fxq ' - --context=dir:///github/workspace' "$1" && + grep -Fxq ' - --dockerfile=/github/workspace/${{ inputs.dockerfile }}' "$1" && + grep -Fxq ' - --destination=${{ inputs.destination }}' "$1" && + grep -Fxq -- ' - --no-push' "$1" && grep -Fxq -- ' - --no-push-cache' "$1" } -if ! check_kaniko_publish_flags "$kaniko_action"; then - echo 'Kaniko must disable image and cache publishing with separate arguments.' >&2 +if ! check_kaniko_action "$kaniko_action"; then + echo 'Kaniko action must define its entrypoint, build arguments, and no-push flags.' >&2 exit 1 fi +without_entrypoint=$(mktemp) without_no_push=$(mktemp) -trap 'rm -f "$without_no_push"' EXIT +trap 'rm -f "$without_entrypoint" "$without_no_push"' EXIT +sed '/^ entrypoint: \/kaniko\/executor$/d' "$kaniko_action" >"$without_entrypoint" +if check_kaniko_action "$without_entrypoint"; then + echo 'CI isolation test accepted a Kaniko action without its executor entrypoint.' >&2 + exit 1 +fi sed '/^ - --no-push$/d' "$kaniko_action" >"$without_no_push" -if check_kaniko_publish_flags "$without_no_push"; then +if check_kaniko_action "$without_no_push"; then echo 'CI isolation test accepted --no-push-cache without standalone --no-push.' >&2 exit 1 fi