ci: restore image publishing with a persistent Docker config
CI / test (push) Successful in 1m38s
CI / chart (push) Successful in 2s
CI / image (push) Failing after 3m29s

A multi-stage kaniko build replaces / with the last stage's root filesystem,
which deletes $HOME/.docker/config.json. Kaniko then resolves credentials at
push time without them, asks the registry for an anonymous token and Gitea
rejects the upload with 401 reqPackageAccess.

Keep the Docker credential store in /kaniko/.docker for the whole image job via
DOCKER_CONFIG and let docker login write there directly. Restore the image job
and document that CI publishes images again.
This commit is contained in:
TapTap committed 2026-11-13 15:51:01 +00:00
1 parent 60e8dadce6
commit a6cc46b747
3 files changed
+61 -11

No files matched your search

+50
View File
@@ -10,6 +10,8 @@ on:
pull_request: pull_request:
env: env:
REGISTRY: gitea.tap-tap.win
IMAGE_NAME: taptap/audiomanager
# Built by scripts/build-ci-image.sh from ci/Dockerfile. Bump the tag when # Built by scripts/build-ci-image.sh from ci/Dockerfile. Bump the tag when
# ci/Dockerfile changes. # ci/Dockerfile changes.
CI_IMAGE: gitea.tap-tap.win/taptap/audiomanager-ci:2 CI_IMAGE: gitea.tap-tap.win/taptap/audiomanager-ci:2
@@ -36,3 +38,51 @@ jobs:
run: | run: |
helm lint charts/musicmanager helm lint charts/musicmanager
helm template musicmanager charts/musicmanager --set users.existingSecret=test > /dev/null helm template musicmanager charts/musicmanager --set users.existingSecret=test > /dev/null
image:
needs:
- test
- chart
if: github.event_name == 'push'
runs-on: ubuntu-latest
container:
image: gitea.tap-tap.win/taptap/audiomanager-ci:2
permissions:
contents: read
packages: write
env:
# A multi-stage build replaces / with the last stage's root filesystem,
# which deletes $HOME/.docker/config.json. Kaniko then has no credentials
# left for the push and gets an anonymous registry token (Gitea reports
# this as "401 reqPackageAccess"). /kaniko is preserved by kaniko, so
# keep the Docker credential store there for the whole job.
DOCKER_CONFIG: /kaniko/.docker
steps:
- uses: actions/checkout@v4
- name: Log in to the registry
run: |
mkdir -p "$DOCKER_CONFIG"
echo "${{ secrets.AUDIOMANAGER_REGISTRY_TOKEN }}" \
| docker login "$REGISTRY" \
--username "${{ gitea.actor }}" \
--password-stdin
- name: Build and push
run: |
set -euo pipefail
tags=("$REGISTRY/$IMAGE_NAME:sha-${GITHUB_SHA::7}")
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
tags+=("$REGISTRY/$IMAGE_NAME:${GITHUB_REF_NAME}")
else
tags+=("$REGISTRY/$IMAGE_NAME:latest")
fi
destinations=()
for tag in "${tags[@]}"; do
destinations+=(--destination "$tag")
done
kaniko-executor \
--context="dir://$PWD" \
--dockerfile="$PWD/Dockerfile" \
--snapshot-mode=redo \
"${destinations[@]}"
+8 -8
View File
@@ -630,9 +630,15 @@ Cover extraction order: embedded APIC frame -> `cover.jpg`/`folder.jpg`/`front.j
- Runtime flags: `-XX:+UseSerialGC -Xmx256m` (adjustable via Helm). - Runtime flags: `-XX:+UseSerialGC -Xmx256m` (adjustable via Helm).
- Non-root user (UID 10001), read-only root filesystem, `/tmp` as `emptyDir`, `/data` as PVC. - Non-root user (UID 10001), read-only root filesystem, `/tmp` as `emptyDir`, `/data` as PVC.
- Image: `gitea.tap-tap.win/taptap/audiomanager:<tag>` (registry paths must be lowercase). - Image: `gitea.tap-tap.win/taptap/audiomanager:<tag>` (registry paths must be lowercase).
- Images are built and pushed from a trusted machine, not from Gitea Actions; `imagePullSecret` is provided by the cluster. - Gitea Actions builds and pushes `:sha-<commit>` and `:latest` on `main`, and the tag name for `v*` tags; `imagePullSecret` is provided by the cluster.
Build and push the image: The CI image job uses kaniko and keeps `DOCKER_CONFIG=/kaniko/.docker` for the
whole job. A multi-stage build replaces `/` with the last stage's root
filesystem, which deletes `$HOME/.docker/config.json`; without this setting
kaniko would push anonymously and Gitea would reject it with
`401 reqPackageAccess`.
To build and push manually (or to deploy from a workstation):
```bash ```bash
docker login gitea.tap-tap.win docker login gitea.tap-tap.win
@@ -641,12 +647,6 @@ scripts/release.sh --tag v1.0.0 # explicit tag
scripts/release.sh --deploy # also apply the users secret and helm upgrade scripts/release.sh --deploy # also apply the users secret and helm upgrade
``` ```
`.gitea/workflows/ci.yaml` only runs the test suite, the smoke script and the Helm
chart lint. Image builds do not run in CI because the Gitea registry rejects
pushes from job containers (`401 Unauthorized: reqPackageAccess`), while the same
credentials work from a normal machine. Releases therefore stay a deliberate local
step; `scripts/release.sh --deploy` covers build, push and `helm upgrade`.
### 9.2 Helm chart ### 9.2 Helm chart
`charts/musicmanager` renders: `charts/musicmanager` renders:
+3 -3
View File
@@ -3,9 +3,9 @@
# Builds and pushes the application image from the local machine, and can # Builds and pushes the application image from the local machine, and can
# optionally deploy the Helm chart to the current kube context. # optionally deploy the Helm chart to the current kube context.
# #
# Image pushes intentionally do not run in Gitea Actions: kaniko inside the job # CI also builds and pushes the image (see .gitea/workflows/ci.yaml). This
# container was rejected by the registry with 401 reqPackageAccess, while the # script is the local alternative, mainly for releases that also deploy with
# same credentials work from here. # --deploy.
set -euo pipefail set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"