ci: use a prebuilt image with every pipeline dependency
Add ci/Dockerfile (JDK 21, Gradle 8.14.3, ffmpeg, sqlite3, node, docker CLI and Helm) and build it as taptap/audiomanager-ci. Workflows now start from that image instead of downloading a JDK and installing packages on every run. The registry namespace is the lowercased package owner `taptap`, not `tap-tap`; update the chart, workflow and documentation accordingly. The image build uses plain docker build/push, since the job container starts with no buildx plugin.
This commit is contained in:
1 parent
d812e7644f
commit
4c6f1c8fe8
6 files changed
+103
-38
No files matched your search
+34
-33
@@ -10,29 +10,29 @@ on:
|
|||||||
|
|
||||||
env:
|
env:
|
||||||
REGISTRY: gitea.tap-tap.win
|
REGISTRY: gitea.tap-tap.win
|
||||||
IMAGE_NAME: tap-tap/audiomanager
|
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:1
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: gitea.tap-tap.win/taptap/audiomanager-ci:1
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: actions/setup-java@v4
|
|
||||||
with:
|
|
||||||
distribution: temurin
|
|
||||||
java-version: "21"
|
|
||||||
- name: Install ffmpeg and sqlite
|
|
||||||
run: sudo apt-get update && sudo apt-get install -y ffmpeg sqlite3
|
|
||||||
- name: Test
|
- name: Test
|
||||||
run: ./gradlew test --console=plain
|
run: gradle test --console=plain
|
||||||
- name: Smoke test
|
- name: Smoke test
|
||||||
run: ./scripts/smoke.sh
|
run: GRADLE=gradle ./scripts/smoke.sh
|
||||||
|
|
||||||
chart:
|
chart:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: gitea.tap-tap.win/taptap/audiomanager-ci:1
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: azure/setup-helm@v4
|
|
||||||
- name: Lint and render the chart
|
- name: Lint and render the chart
|
||||||
run: |
|
run: |
|
||||||
helm lint charts/musicmanager
|
helm lint charts/musicmanager
|
||||||
@@ -47,34 +47,35 @@ jobs:
|
|||||||
# The runner executes jobs in containers; expose its Docker daemon so the
|
# The runner executes jobs in containers; expose its Docker daemon so the
|
||||||
# image build works without a separate DinD service.
|
# image build works without a separate DinD service.
|
||||||
container:
|
container:
|
||||||
image: catthehacker/ubuntu:act-latest
|
image: gitea.tap-tap.win/taptap/audiomanager-ci:1
|
||||||
options: --volume /var/run/docker.sock:/var/run/docker.sock
|
options: --volume /var/run/docker.sock:/var/run/docker.sock
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
packages: write
|
packages: write
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: docker/setup-buildx-action@v3
|
|
||||||
- name: Log in to the registry
|
- name: Log in to the registry
|
||||||
uses: docker/login-action@v3
|
run: |
|
||||||
with:
|
echo "${{ secrets.REGISTRY_PASSWORD || secrets.GITEA_TOKEN }}" \
|
||||||
registry: ${{ env.REGISTRY }}
|
| docker login "$REGISTRY" \
|
||||||
username: ${{ secrets.REGISTRY_USERNAME || gitea.actor }}
|
--username "${{ secrets.REGISTRY_USERNAME || gitea.actor }}" \
|
||||||
password: ${{ secrets.REGISTRY_PASSWORD || secrets.GITEA_TOKEN }}
|
--password-stdin
|
||||||
- name: Image metadata
|
|
||||||
id: meta
|
|
||||||
uses: docker/metadata-action@v5
|
|
||||||
with:
|
|
||||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
|
||||||
tags: |
|
|
||||||
type=ref,event=branch
|
|
||||||
type=ref,event=tag
|
|
||||||
type=sha
|
|
||||||
type=raw,value=latest,enable={{is_default_branch}}
|
|
||||||
- name: Build and push
|
- name: Build and push
|
||||||
uses: docker/build-push-action@v6
|
run: |
|
||||||
with:
|
set -euo pipefail
|
||||||
context: .
|
tags=("$REGISTRY/$IMAGE_NAME:sha-${GITHUB_SHA::7}")
|
||||||
push: true
|
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags+=("$REGISTRY/$IMAGE_NAME:${GITHUB_REF_NAME}")
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
else
|
||||||
|
tags+=("$REGISTRY/$IMAGE_NAME:latest")
|
||||||
|
fi
|
||||||
|
|
||||||
|
build_args=()
|
||||||
|
for tag in "${tags[@]}"; do
|
||||||
|
build_args+=(-t "$tag")
|
||||||
|
done
|
||||||
|
|
||||||
|
docker build "${build_args[@]}" .
|
||||||
|
for tag in "${tags[@]}"; do
|
||||||
|
docker push "$tag"
|
||||||
|
done
|
||||||
@@ -629,13 +629,13 @@ Cover extraction order: embedded APIC frame -> `cover.jpg`/`folder.jpg`/`front.j
|
|||||||
- Multi-stage Dockerfile: Gradle build -> glibc-based `eclipse-temurin:21-jre-jammy` with `ffmpeg` installed (Alpine/musl is unsupported by sqlite-jdbc's bundled native library).
|
- Multi-stage Dockerfile: Gradle build -> glibc-based `eclipse-temurin:21-jre-jammy` with `ffmpeg` installed (Alpine/musl is unsupported by sqlite-jdbc's bundled native library).
|
||||||
- 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/tap-tap/audiomanager:<tag>` (registry paths must be lowercase).
|
- 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.
|
- Gitea Actions builds and pushes on tags; `imagePullSecret` is provided by the cluster.
|
||||||
|
|
||||||
Build the image locally:
|
Build the image locally:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker build -t gitea.tap-tap.win/tap-tap/audiomanager:dev .
|
docker build -t gitea.tap-tap.win/taptap/audiomanager:dev .
|
||||||
```
|
```
|
||||||
|
|
||||||
`.gitea/workflows/ci.yaml` runs tests and the smoke script, then builds and pushes
|
`.gitea/workflows/ci.yaml` runs tests and the smoke script, then builds and pushes
|
||||||
@@ -731,7 +731,7 @@ Verify each step with `./gradlew test` and/or `curl`:
|
|||||||
|
|
||||||
## 12. Open Items / Assumptions
|
## 12. Open Items / Assumptions
|
||||||
|
|
||||||
1. **Gitea registry path:** image assumed to be `gitea.tap-tap.win/tap-tap/audiomanager` (lowercased repo `TapTap/AudioManager`).
|
1. **Gitea registry path:** image is `gitea.tap-tap.win/taptap/audiomanager` (lowercased package owner `taptap`).
|
||||||
2. **Vault layout:** the chart expects a secret with a `users.yaml` key. Exact Vault path/agent template is deployment-side and not part of the app.
|
2. **Vault layout:** the chart expects a secret with a `users.yaml` key. Exact Vault path/agent template is deployment-side and not part of the app.
|
||||||
3. **Per-user music roots:** Vault/config must contain one folder entry per user root (e.g. `/mnt/media/music/<user>`); there is no implicit path convention.
|
3. **Per-user music roots:** Vault/config must contain one folder entry per user root (e.g. `/mnt/media/music/<user>`); there is no implicit path convention.
|
||||||
4. **hostPath without pinning:** requires `/mnt/media/music` and `/mnt/media/longform` to exist on every node that can schedule the pod. Add a `nodeSelector` later if that changes.
|
4. **hostPath without pinning:** requires `/mnt/media/music` and `/mnt/media/longform` to exist on every node that can schedule the pod. Add a `nodeSelector` later if that changes.
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
replicaCount: 1
|
replicaCount: 1
|
||||||
|
|
||||||
image:
|
image:
|
||||||
repository: gitea.tap-tap.win/tap-tap/audiomanager
|
repository: gitea.tap-tap.win/taptap/audiomanager
|
||||||
tag: "" # defaults to appVersion
|
tag: "" # defaults to appVersion
|
||||||
pullPolicy: IfNotPresent
|
pullPolicy: IfNotPresent
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
# Image for Gitea Actions jobs. It contains every tool the pipeline needs so
|
||||||
|
# workflows do not download a JDK or install packages on every run.
|
||||||
|
#
|
||||||
|
# Build and push it with scripts/build-ci-image.sh.
|
||||||
|
FROM gradle:8.14.3-jdk21
|
||||||
|
|
||||||
|
ARG NODE_VERSION=22.14.0
|
||||||
|
ARG DOCKER_VERSION=27.3.1
|
||||||
|
ARG HELM_VERSION=3.16.4
|
||||||
|
|
||||||
|
RUN apt-get update \
|
||||||
|
&& apt-get install -y --no-install-recommends \
|
||||||
|
ca-certificates \
|
||||||
|
curl \
|
||||||
|
git \
|
||||||
|
ffmpeg \
|
||||||
|
sqlite3 \
|
||||||
|
xz-utils \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Node is required by actions/checkout and other JavaScript actions executed
|
||||||
|
# inside the job container.
|
||||||
|
RUN curl -fsSL "https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64.tar.xz" \
|
||||||
|
-o /tmp/node.tar.xz \
|
||||||
|
&& tar -xJf /tmp/node.tar.xz -C /usr/local --strip-components=1 \
|
||||||
|
&& rm /tmp/node.tar.xz \
|
||||||
|
&& node --version \
|
||||||
|
&& npm --version
|
||||||
|
|
||||||
|
# Docker CLI only (the runner mounts its daemon socket into the job).
|
||||||
|
RUN curl -fsSL "https://download.docker.com/linux/static/stable/x86_64/docker-${DOCKER_VERSION}.tgz" \
|
||||||
|
-o /tmp/docker.tgz \
|
||||||
|
&& tar -xzf /tmp/docker.tgz -C /tmp \
|
||||||
|
&& install -m 0755 /tmp/docker/docker /usr/local/bin/docker \
|
||||||
|
&& rm -rf /tmp/docker /tmp/docker.tgz \
|
||||||
|
&& docker --version
|
||||||
|
|
||||||
|
RUN curl -fsSL "https://get.helm.sh/helm-v${HELM_VERSION}-linux-amd64.tar.gz" \
|
||||||
|
-o /tmp/helm.tgz \
|
||||||
|
&& tar -xzf /tmp/helm.tgz -C /tmp \
|
||||||
|
&& install -m 0755 /tmp/linux-amd64/helm /usr/local/bin/helm \
|
||||||
|
&& rm -rf /tmp/helm.tgz /tmp/linux-amd64 \
|
||||||
|
&& helm version --short
|
||||||
|
|
||||||
|
ENV GRADLE_USER_HOME=/root/.gradle \
|
||||||
|
JAVA_HOME=/opt/java/openjdk
|
||||||
|
|
||||||
|
WORKDIR /workspace
|
||||||
|
|
||||||
|
CMD ["sleep", "infinity"]
|
||||||
Executable
+13
@@ -0,0 +1,13 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# Builds and pushes the CI job image used by .gitea/workflows/ci.yaml.
|
||||||
|
# Run this once after changing ci/Dockerfile, or when dependency versions change.
|
||||||
|
#
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||||
|
IMAGE="${CI_IMAGE:-gitea.tap-tap.win/taptap/audiomanager-ci}"
|
||||||
|
TAG="${1:-1}"
|
||||||
|
|
||||||
|
docker build -f "$ROOT/ci/Dockerfile" -t "$IMAGE:$TAG" "$ROOT"
|
||||||
|
docker push "$IMAGE:$TAG"
|
||||||
+2
-1
@@ -9,6 +9,7 @@
|
|||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||||
|
GRADLE="${GRADLE:-./gradlew}"
|
||||||
WORK="${1:-$(mktemp -d "${TMPDIR:-/tmp}/musicmanager-smoke.XXXXXX")}"
|
WORK="${1:-$(mktemp -d "${TMPDIR:-/tmp}/musicmanager-smoke.XXXXXX")}"
|
||||||
PORT="${SMOKE_PORT:-18099}"
|
PORT="${SMOKE_PORT:-18099}"
|
||||||
USER="smoke"
|
USER="smoke"
|
||||||
@@ -65,7 +66,7 @@ users:
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
log "Building fat JAR..."
|
log "Building fat JAR..."
|
||||||
(cd "$ROOT" && ./gradlew -q shadowJar)
|
(cd "$ROOT" && "$GRADLE" -q shadowJar)
|
||||||
|
|
||||||
JAR="$(find "$ROOT/build/libs" -name 'musicmanager-*-all.jar' | head -1)"
|
JAR="$(find "$ROOT/build/libs" -name 'musicmanager-*-all.jar' | head -1)"
|
||||||
if [[ -z "$JAR" ]]; then
|
if [[ -z "$JAR" ]]; then
|
||||||
|
|||||||
Reference in new issue
Block a user