ci(oidc): build isolated imported Login image and reuse real browser acceptance
This commit is contained in:
1 parent
c93468fb60
commit
fcfa59e826
7 files changed
+214
-4
No files matched your search
@@ -0,0 +1,8 @@
|
||||
# tests/ci/login_image/ manifest
|
||||
|
||||
| File | Purpose | Phase |
|
||||
| --- | --- | --- |
|
||||
| [README.md](README.md) | Scope/ownership/privacy and manual CI usage | P05-OIDC-06 |
|
||||
| [MINIFEST.md](MINIFEST.md) | Exact direct file register | P05-OIDC-06 |
|
||||
| [build.sh](build.sh) | Disposable frozen imported build + local image packaging | P05-OIDC-06 |
|
||||
| [cleanup.sh](cleanup.sh) | Always-run exact-labeled builder/image/temp context teardown | P05-OIDC-06 |
|
||||
@@ -0,0 +1,9 @@
|
||||
# CI-only imported Login image acceptance helpers
|
||||
|
||||
This directory is used solely by the manual Gitea P05-OIDC-06 workflow. It builds the original imported Login V2 workspace **inside a run-labeled disposable Node 22 Debian builder** and packages only its generated Next standalone output with the **unchanged upstream Login Dockerfile** into a local Docker image.
|
||||
|
||||
- `build.sh`: refuse preexisting state, run frozen pinned pnpm/Nx build, create local run-tagged image. No registry push, no production data, no host ports.
|
||||
- `cleanup.sh`: used by the workflow `always()` step, **after** the existing OIDC cleanup; verify labels and remove only this run's builder/image/temp build context.
|
||||
- The existing real browser acceptance harness remains the security authority; custom-image mode is explicit opt-in and uses separate Compose overlay.
|
||||
|
||||
Update these helpers only in a separately approved source scope; maintain MINIFEST.md and never copy upstream source edits, credentials or CI output to Git.
|
||||
@@ -0,0 +1,58 @@
|
||||
#!/bin/sh
|
||||
# Imported source is compiled entirely inside a run-owned Docker builder.
|
||||
# Only .next/standalone and the untouched upstream Dockerfile enter the
|
||||
# temporary local image build context. No source tree write or registry push.
|
||||
set -eu
|
||||
: "${GITHUB_RUN_ID:?Missing numeric disposable Gitea run ID}"
|
||||
case "$GITHUB_RUN_ID" in *[!0-9]*|'') echo LOGIN_CI_INVALID_RUN_ID >&2; exit 1;; esac
|
||||
builder="zitplane-login-$GITHUB_RUN_ID-builder"
|
||||
image="zitplane-login-ci:$GITHUB_RUN_ID"
|
||||
context="/tmp/zitplane-login-build-$GITHUB_RUN_ID"
|
||||
label="zitplane.login.run=$GITHUB_RUN_ID"
|
||||
docker info --format '{{.Driver}}' >/dev/null
|
||||
if docker container inspect "$builder" >/dev/null 2>&1 ||
|
||||
docker image inspect "$image" >/dev/null 2>&1 ||
|
||||
[ -e "$context" ] ||
|
||||
[ -e auth/ui/v2/apps/login/.env ] ||
|
||||
[ -e auth/ui/v2/apps/login/.env.prod ]; then
|
||||
echo ZITPLANE_CUSTOM_LOGIN_PREEXISTING_STATE_REFUSED >&2
|
||||
exit 1
|
||||
fi
|
||||
test -r auth/ui/v2/apps/login/Dockerfile
|
||||
test -r auth/ui/v2/pnpm-lock.yaml
|
||||
test -r tests/ci/oidc_e2e/cleanup.sh
|
||||
echo ZITPLANE_CUSTOM_LOGIN_ISOLATED_BUILD_PREFLIGHT_PASS
|
||||
docker create --name "$builder" --label "$label" node:22-bookworm sleep 3600 >/dev/null
|
||||
docker start "$builder" >/dev/null
|
||||
docker exec "$builder" mkdir -p /work
|
||||
docker cp auth/ui/v2 "$builder:/work/v2"
|
||||
docker exec -w /work/v2 "$builder" sh -ec '
|
||||
corepack enable
|
||||
corepack prepare pnpm@10.30.3 --activate
|
||||
pnpm install --frozen-lockfile
|
||||
echo ZITPLANE_CUSTOM_LOGIN_FROZEN_INSTALL_PASS
|
||||
: > apps/login/.env
|
||||
export NEXT_PUBLIC_BASE_PATH=/ui/v2/login
|
||||
export NX_NO_CLOUD=true NX_DAEMON=false CI=true
|
||||
pnpm exec nx run @zitadel/login:build --skip-nx-cache
|
||||
rm -f apps/login/.env
|
||||
test -f apps/login/.next/standalone/apps/login/server.js
|
||||
test -f apps/login/.next/standalone/entrypoint.sh
|
||||
test -f apps/login/.next/standalone/healthcheck.mjs
|
||||
echo ZITPLANE_CUSTOM_LOGIN_STANDALONE_BUILD_PASS
|
||||
'
|
||||
mkdir -m 700 -p "$context/.next"
|
||||
touch "$context/.zitplane-owned-$GITHUB_RUN_ID"
|
||||
docker cp "$builder:/work/v2/apps/login/.next/standalone" "$context/.next/standalone"
|
||||
cp auth/ui/v2/apps/login/Dockerfile "$context/Dockerfile"
|
||||
docker build --pull --label "$label" -t "$image" -f "$context/Dockerfile" "$context"
|
||||
actual_label="$(docker image inspect --format '{{ index .Config.Labels "zitplane.login.run" }}' "$image")"
|
||||
image_id="$(docker image inspect --format '{{.Id}}' "$image")"
|
||||
if [ "$actual_label" != "$GITHUB_RUN_ID" ]; then
|
||||
echo ZITPLANE_CUSTOM_LOGIN_IMAGE_OWNERSHIP_MISMATCH >&2
|
||||
exit 1
|
||||
fi
|
||||
case "$image_id" in sha256:*) ;; *) echo ZITPLANE_CUSTOM_LOGIN_IMAGE_ID_MISSING >&2; exit 1;; esac
|
||||
echo ZITPLANE_CUSTOM_LOGIN_LOCAL_IMAGE_BUILT_PASS
|
||||
# Record only a digest/ID and sanitized ownership metadata (never credentials).
|
||||
echo "ZITPLANE_CUSTOM_LOGIN_IMAGE_ID=$image_id"
|
||||
@@ -0,0 +1,49 @@
|
||||
#!/bin/sh
|
||||
# Idempotent always() teardown for ONLY this workflow's builder/image/context.
|
||||
# The previous OIDC owned cleanup MUST run before removing the image.
|
||||
set -eu
|
||||
: "${GITHUB_RUN_ID:?Missing run ID}"
|
||||
case "$GITHUB_RUN_ID" in *[!0-9]*|'') echo LOGIN_CI_CLEANUP_INVALID_RUN_ID >&2; exit 1;; esac
|
||||
builder="zitplane-login-$GITHUB_RUN_ID-builder"
|
||||
image="zitplane-login-ci:$GITHUB_RUN_ID"
|
||||
context="/tmp/zitplane-login-build-$GITHUB_RUN_ID"
|
||||
rc=0
|
||||
if docker container inspect "$builder" >/dev/null 2>&1; then
|
||||
label="$(docker inspect -f '{{ index .Config.Labels "zitplane.login.run" }}' "$builder" 2>/dev/null || true)"
|
||||
if [ "$label" != "$GITHUB_RUN_ID" ]; then
|
||||
echo ZITPLANE_CUSTOM_LOGIN_UNOWNED_BUILDER_REFUSED >&2
|
||||
rc=1
|
||||
elif ! docker rm -f "$builder" >/dev/null; then
|
||||
echo ZITPLANE_CUSTOM_LOGIN_BUILDER_CLEANUP_FAILED >&2
|
||||
rc=1
|
||||
fi
|
||||
fi
|
||||
if docker image inspect "$image" >/dev/null 2>&1; then
|
||||
label="$(docker image inspect --format '{{ index .Config.Labels "zitplane.login.run" }}' "$image" 2>/dev/null || true)"
|
||||
if [ "$label" != "$GITHUB_RUN_ID" ]; then
|
||||
echo ZITPLANE_CUSTOM_LOGIN_UNOWNED_IMAGE_REFUSED >&2
|
||||
rc=1
|
||||
elif ! docker image rm "$image" >/dev/null; then
|
||||
echo ZITPLANE_CUSTOM_LOGIN_LOCAL_IMAGE_CLEANUP_FAILED >&2
|
||||
rc=1
|
||||
fi
|
||||
fi
|
||||
if [ -e "$context" ]; then
|
||||
if [ -f "$context/.zitplane-owned-$GITHUB_RUN_ID" ]; then
|
||||
rm -rf "$context"
|
||||
else
|
||||
echo ZITPLANE_CUSTOM_LOGIN_UNOWNED_CONTEXT_REFUSED >&2
|
||||
rc=1
|
||||
fi
|
||||
fi
|
||||
if docker container inspect "$builder" >/dev/null 2>&1 ||
|
||||
docker image inspect "$image" >/dev/null 2>&1 ||
|
||||
[ -e "$context" ]; then
|
||||
echo ZITPLANE_CUSTOM_LOGIN_RESOURCES_LEFTOVER >&2
|
||||
rc=1
|
||||
fi
|
||||
if [ "$rc" -ne 0 ]; then
|
||||
echo ZITPLANE_CUSTOM_LOGIN_CLEANUP_FAILED >&2
|
||||
exit 1
|
||||
fi
|
||||
echo ZITPLANE_CUSTOM_LOGIN_ALL_BUILD_RESOURCES_CLEANED_PASS
|
||||
Reference in new issue
Block a user