ci: keep tests in CI and move image pushes to a local release script
The Gitea registry rejects kaniko pushes from job containers with 401 reqPackageAccess even though the same credentials work from a normal machine, so the image job could never go green. Drop the image job; CI now only runs unit tests, the smoke test and the Helm chart lint. Add scripts/release.sh, which builds and pushes the image from a trusted machine and can optionally apply the users secret and run helm upgrade.
This commit is contained in:
1 parent
9eed647df0
commit
60e8dadce6
3 files changed
+93
-55
No files matched your search
@@ -10,8 +10,6 @@ on:
|
||||
pull_request:
|
||||
|
||||
env:
|
||||
REGISTRY: gitea.tap-tap.win
|
||||
IMAGE_NAME: taptap/audiomanager
|
||||
# Built by scripts/build-ci-image.sh from ci/Dockerfile. Bump the tag when
|
||||
# ci/Dockerfile changes.
|
||||
CI_IMAGE: gitea.tap-tap.win/taptap/audiomanager-ci:2
|
||||
@@ -38,48 +36,3 @@ jobs:
|
||||
run: |
|
||||
helm lint charts/musicmanager
|
||||
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
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Log in to the registry
|
||||
run: |
|
||||
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 builds without a Docker daemon. docker login wrote the
|
||||
# credentials to the default Docker config location.
|
||||
mkdir -p /kaniko/.docker
|
||||
cp "$HOME/.docker/config.json" /kaniko/.docker/config.json
|
||||
|
||||
kaniko-executor \
|
||||
--context="dir://$PWD" \
|
||||
--dockerfile="$PWD/Dockerfile" \
|
||||
--snapshot-mode=redo \
|
||||
"${destinations[@]}"
|
||||
@@ -179,7 +179,7 @@ Build a lightweight, self-hosted **OpenSubsonic-compatible music server** in **K
|
||||
- **Transcoding:** `ffmpeg` binary in the runtime image (libmp3lame), invoked as a subprocess
|
||||
- **Logging:** `logback-classic` + `kotlin-logging-jvm`
|
||||
- **Config:** YAML (`library.yaml`, `users.yaml`) with env-var overrides for paths and secrets
|
||||
- **Deployment:** multi-stage Dockerfile, Helm chart for k3s, Gitea Actions for image builds
|
||||
- **Deployment:** multi-stage Dockerfile, Helm chart for k3s, Gitea Actions for tests, local release script for image pushes
|
||||
|
||||
---
|
||||
|
||||
@@ -630,18 +630,22 @@ Cover extraction order: embedded APIC frame -> `cover.jpg`/`folder.jpg`/`front.j
|
||||
- Runtime flags: `-XX:+UseSerialGC -Xmx256m` (adjustable via Helm).
|
||||
- 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).
|
||||
- Gitea Actions builds and pushes on tags; `imagePullSecret` is provided by the cluster.
|
||||
- Images are built and pushed from a trusted machine, not from Gitea Actions; `imagePullSecret` is provided by the cluster.
|
||||
|
||||
Build the image locally:
|
||||
Build and push the image:
|
||||
|
||||
```bash
|
||||
docker build -t gitea.tap-tap.win/taptap/audiomanager:dev .
|
||||
docker login gitea.tap-tap.win
|
||||
scripts/release.sh # tag = git short SHA, pushes :<sha> and :latest
|
||||
scripts/release.sh --tag v1.0.0 # explicit tag
|
||||
scripts/release.sh --deploy # also apply the users secret and helm upgrade
|
||||
```
|
||||
|
||||
`.gitea/workflows/ci.yaml` runs tests and the smoke script, then builds and pushes
|
||||
`:latest` for `main` and the tag name for `v*` tags. Set `REGISTRY_USERNAME` /
|
||||
`REGISTRY_PASSWORD` repository secrets if the automatically provided token cannot
|
||||
push to the registry.
|
||||
`.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
|
||||
|
||||
|
||||
Executable
+81
@@ -0,0 +1,81 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Builds and pushes the application image from the local machine, and can
|
||||
# optionally deploy the Helm chart to the current kube context.
|
||||
#
|
||||
# Image pushes intentionally do not run in Gitea Actions: kaniko inside the job
|
||||
# container was rejected by the registry with 401 reqPackageAccess, while the
|
||||
# same credentials work from here.
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
IMAGE="${IMAGE:-gitea.tap-tap.win/taptap/audiomanager}"
|
||||
NAMESPACE="${NAMESPACE:-musicmanager}"
|
||||
RELEASE="${RELEASE:-musicmanager}"
|
||||
USERS_SECRET="${USERS_SECRET:-musicmanager-users}"
|
||||
USERS_FILE="${USERS_FILE:-$ROOT/config/users.yaml}"
|
||||
|
||||
TAG=""
|
||||
DEPLOY=0
|
||||
PUSH=1
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage: scripts/release.sh [options]
|
||||
|
||||
Options:
|
||||
--tag TAG Image tag (default: git short SHA)
|
||||
--deploy Run helm upgrade --install after pushing
|
||||
--no-push Build only, do not push
|
||||
-h, --help Show this help
|
||||
|
||||
Environment:
|
||||
IMAGE Image repository (default: gitea.tap-tap.win/taptap/audiomanager)
|
||||
NAMESPACE Kubernetes namespace (default: musicmanager)
|
||||
RELEASE Helm release name (default: musicmanager)
|
||||
USERS_SECRET Secret holding users.yaml (default: musicmanager-users)
|
||||
USERS_FILE Path to users.yaml for --deploy (default: config/users.yaml)
|
||||
EOF
|
||||
}
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--tag) TAG="${2:?--tag requires a value}"; shift 2 ;;
|
||||
--deploy) DEPLOY=1; shift ;;
|
||||
--no-push) PUSH=0; shift ;;
|
||||
-h|--help) usage; exit 0 ;;
|
||||
*) echo "Unknown argument: $1" >&2; usage >&2; exit 2 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
TAG="${TAG:-$(git -C "$ROOT" rev-parse --short HEAD)}"
|
||||
|
||||
echo "Building $IMAGE:$TAG"
|
||||
docker build -t "$IMAGE:$TAG" -t "$IMAGE:latest" "$ROOT"
|
||||
|
||||
if [[ $PUSH -eq 1 ]]; then
|
||||
echo "Pushing $IMAGE:$TAG and $IMAGE:latest"
|
||||
if ! docker push "$IMAGE:$TAG"; then
|
||||
echo "Push failed. Run 'docker login gitea.tap-tap.win' and retry." >&2
|
||||
exit 1
|
||||
fi
|
||||
docker push "$IMAGE:latest"
|
||||
fi
|
||||
|
||||
if [[ $DEPLOY -eq 1 ]]; then
|
||||
echo "Deploying $RELEASE to namespace $NAMESPACE with image tag $TAG"
|
||||
|
||||
if [[ -f "$USERS_FILE" ]]; then
|
||||
kubectl create namespace "$NAMESPACE" --dry-run=client -o yaml | kubectl apply -f -
|
||||
kubectl -n "$NAMESPACE" create secret generic "$USERS_SECRET" \
|
||||
--from-file=users.yaml="$USERS_FILE" \
|
||||
--dry-run=client -o yaml | kubectl apply -f -
|
||||
else
|
||||
echo "No users file at $USERS_FILE; assuming secret $USERS_SECRET already exists."
|
||||
fi
|
||||
|
||||
helm upgrade --install "$RELEASE" "$ROOT/charts/musicmanager" \
|
||||
--namespace "$NAMESPACE" \
|
||||
--set image.tag="$TAG" \
|
||||
--set users.existingSecret="$USERS_SECRET"
|
||||
fi
|
||||
Reference in new issue
Block a user