feat: add Docker image, Helm chart and Gitea CI
CI / test (push) Successful in 3m35s
CI / smoke (push) Successful in 3m11s
CI / chart (push) Successful in 14s
CI / image (push) Failing after 5s

- multi-stage Dockerfile with ffmpeg on Alpine JRE 21
- Helm chart for k3s: library ConfigMap, Vault users secret, data PVC,
  read-only hostPath media, ingress, probes and security context
- Gitea Actions runs tests, smoke test and chart lint, then builds and
  pushes the image on main and version tags
This commit is contained in:
TapTap committed 2026-11-13 12:56:30 +00:00
1 parent 18a1d7cd19
commit 25331ec0e1
12 files changed
+494 -11

No files matched your search

+15
View File
@@ -0,0 +1,15 @@
.git
.github
.gitea
.gradle
build
data
media
test-media
charts
config/library.yaml
config/users.yaml
*.db
*.db-shm
*.db-wal
*.log
+87
View File
@@ -0,0 +1,87 @@
name: CI
on:
push:
branches:
- main
tags:
- "v*"
pull_request:
env:
REGISTRY: gitea.tap-tap.win
IMAGE_NAME: tap-tap/audiomanager
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: "21"
- name: Install ffmpeg
run: sudo apt-get update && sudo apt-get install -y ffmpeg
- name: Test
run: ./gradlew test --console=plain
smoke:
runs-on: ubuntu-latest
steps:
- 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: Smoke test
run: ./scripts/smoke.sh
chart:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: azure/setup-helm@v4
- name: Lint and render the chart
run: |
helm lint charts/musicmanager
helm template musicmanager charts/musicmanager --set users.existingSecret=test > /dev/null
image:
needs:
- test
- smoke
- chart
if: github.event_name == 'push'
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- name: Log in to the registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.REGISTRY_USERNAME || gitea.actor }}
password: ${{ secrets.REGISTRY_PASSWORD || secrets.GITEA_TOKEN }}
- 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
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
+31
View File
@@ -0,0 +1,31 @@
# syntax=docker/dockerfile:1
FROM gradle:8.14.3-jdk21 AS build
WORKDIR /src
COPY gradle ./gradle
COPY gradlew settings.gradle.kts build.gradle.kts gradle.properties ./
RUN ./gradlew --no-daemon dependencies > /dev/null
COPY src ./src
RUN ./gradlew --no-daemon shadowJar
FROM eclipse-temurin:21-jre-alpine
RUN apk add --no-cache ffmpeg \
&& addgroup -g 10001 -S app \
&& adduser -u 10001 -S -G app app
WORKDIR /app
COPY --from=build /src/build/libs/*-all.jar /app/musicmanager.jar
ENV DATA_DIR=/data \
LIBRARY_CONFIG=/etc/musicmanager/library.yaml \
USERS_FILE=/etc/musicmanager/users.yaml \
FFMPEG_PATH=ffmpeg \
PORT=8080
USER 10001:10001
EXPOSE 8080
ENTRYPOINT ["java", "-XX:+UseSerialGC", "-Xmx256m", "-jar", "/app/musicmanager.jar"]
+39 -11
View File
@@ -632,21 +632,49 @@ Cover extraction order: embedded APIC frame -> `cover.jpg`/`folder.jpg`/`front.j
- Image: `gitea.tap-tap.win/tap-tap/audiomanager:<tag>` (registry paths must be lowercase). - Image: `gitea.tap-tap.win/tap-tap/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:
```bash
docker build -t gitea.tap-tap.win/tap-tap/audiomanager:dev .
```
`.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.
### 9.2 Helm chart ### 9.2 Helm chart
`charts/musicmanager` with values for: `charts/musicmanager` renders:
- image repository/tag, `imagePullSecrets` - image repository/tag and `imagePullSecrets`
- `library` config (folders) rendered into a ConfigMap - `library.folders` into a ConfigMap (`/etc/musicmanager/library.yaml`)
- `users.existingSecret` + key (Vault-managed; never put passwords in values) - `users.existingSecret` + key (Vault-managed; never put passwords in values)
- ingress host `subsonic.tap-tap.win`, ingress class, TLS via cluster issuer - ingress host `subsonic.tap-tap.win`, ingress class and TLS secret
- `/data` PVC (size, storage class) - `/data` PVC (size, storage class)
- `hostPath` mounts: `/mnt/media/music` and `/mnt/media/longform`, read-only - `hostPath` mounts for music and long-form roots, both read-only
- no node pinning: every schedulable node must expose the same mounts (documented) - resource requests/limits, non-root security context, probes on `/health`
- resource requests/limits, security context, liveness/readiness probes (`/health`) - optional `nodeSelector`, `tolerations` and `affinity`
- optional `nodeSelector`/`tolerations` for future use
The server fails its readiness probe if a configured root path is missing or unreadable. The secret is not created by the chart. Create it from the Vault-managed file:
```bash
kubectl create namespace musicmanager
kubectl -n musicmanager create secret generic musicmanager-users \
--from-file=users.yaml=config/users.yaml
helm upgrade --install musicmanager charts/musicmanager \
--namespace musicmanager \
--set image.tag=dev \
--set users.existingSecret=musicmanager-users
```
Adjust `library.folders`, `media.music.hostPath` and `media.longform.hostPath` for
the cluster. Every schedulable node must expose the same host paths; the chart
deliberately does not pin the pod to a node.
The server exits at startup if a configured root path is missing or unreadable, so
the pod will not pass its readiness probe in that case.
### 9.3 Operations ### 9.3 Operations
@@ -696,8 +724,8 @@ Verify each step with `./gradlew test` and/or `curl`:
- [x] 4. **Browsing & media:** system, browsing, genre and media routes (`stream`, `download`, `getCoverArt`). - [x] 4. **Browsing & media:** system, browsing, genre and media routes (`stream`, `download`, `getCoverArt`).
- [x] 5. **Transcoding:** `FfmpegTranscoder.kt`, `maxBitRate`/`format`/`timeOffset`, extension declaration. - [x] 5. **Transcoding:** `FfmpegTranscoder.kt`, `maxBitRate`/`format`/`timeOffset`, extension declaration.
- [x] 6. **Interaction & playlists:** `getAlbumList2`, `getRandomSongs`, `getStarred2`, `search3`, `scrobble`, `star`/`unstar`, `setRating`, bookmarks, playlists. - [x] 6. **Interaction & playlists:** `getAlbumList2`, `getRandomSongs`, `getStarred2`, `search3`, `scrobble`, `star`/`unstar`, `setRating`, bookmarks, playlists.
- [ ] 7. **Packaging:** multi-stage Dockerfile (with ffmpeg), Helm chart, Gitea Actions workflow. - [x] 7. **Packaging:** multi-stage Dockerfile (with ffmpeg), Helm chart, Gitea Actions workflow.
- [ ] 8. **Tests:** integration suite as described above, plus a `curl` smoke script. - [x] 8. **Tests:** integration suite as described above, plus a `curl` smoke script.
--- ---
+6
View File
@@ -0,0 +1,6 @@
apiVersion: v2
name: musicmanager
description: Self-hosted OpenSubsonic music server
type: application
version: 0.1.0
appVersion: "0.1.0"
@@ -0,0 +1,33 @@
{{- define "musicmanager.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- define "musicmanager.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- define "musicmanager.labels" -}}
helm.sh/chart: {{ printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" }}
app.kubernetes.io/name: {{ include "musicmanager.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}
{{- define "musicmanager.selectorLabels" -}}
app.kubernetes.io/name: {{ include "musicmanager.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end -}}
{{- define "musicmanager.image" -}}
{{- printf "%s:%s" .Values.image.repository (default .Chart.AppVersion .Values.image.tag) -}}
{{- end -}}
@@ -0,0 +1,16 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "musicmanager.fullname" . }}-library
labels:
{{- include "musicmanager.labels" . | nindent 4 }}
data:
library.yaml: |
library:
folders:
{{- range .Values.library.folders }}
- id: {{ .id }}
name: {{ .name | quote }}
type: {{ .type }}
path: {{ .path | quote }}
{{- end }}
@@ -0,0 +1,118 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "musicmanager.fullname" . }}
labels:
{{- include "musicmanager.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
strategy:
type: Recreate
selector:
matchLabels:
{{- include "musicmanager.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "musicmanager.selectorLabels" . | nindent 8 }}
annotations:
checksum/library: {{ include (print $.Template.BasePath "/configmap-library.yaml") . | sha256sum }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: musicmanager
image: "{{ include "musicmanager.image" . }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
env:
- name: PORT
value: "8080"
- name: DATA_DIR
value: /data
- name: LIBRARY_CONFIG
value: /etc/musicmanager/library.yaml
- name: USERS_FILE
value: /etc/musicmanager/users.yaml
- name: FFMPEG_PATH
value: ffmpeg
{{- with .Values.env }}
{{- toYaml . | nindent 12 }}
{{- end }}
ports:
- name: http
containerPort: 8080
livenessProbe:
httpGet:
path: /health
port: http
initialDelaySeconds: 10
periodSeconds: 20
readinessProbe:
httpGet:
path: /health
port: http
initialDelaySeconds: 5
periodSeconds: 10
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:
- name: library
mountPath: /etc/musicmanager/library.yaml
subPath: library.yaml
readOnly: true
- name: users
mountPath: /etc/musicmanager/users.yaml
subPath: {{ .Values.users.key }}
readOnly: true
- name: data
mountPath: /data
- name: tmp
mountPath: /tmp
- name: music
mountPath: {{ .Values.media.music.mountPath }}
readOnly: true
- name: longform
mountPath: {{ .Values.media.longform.mountPath }}
readOnly: true
volumes:
- name: library
configMap:
name: {{ include "musicmanager.fullname" . }}-library
- name: users
secret:
secretName: {{ required "users.existingSecret is required" .Values.users.existingSecret }}
- name: data
{{- if .Values.data.persistence.enabled }}
persistentVolumeClaim:
claimName: {{ include "musicmanager.fullname" . }}-data
{{- else }}
emptyDir: {}
{{- end }}
- name: tmp
emptyDir: {}
- name: music
hostPath:
path: {{ .Values.media.music.hostPath }}
type: Directory
- name: longform
hostPath:
path: {{ .Values.media.longform.hostPath }}
type: Directory
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
@@ -0,0 +1,29 @@
{{- if .Values.ingress.enabled }}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ include "musicmanager.fullname" . }}
labels:
{{- include "musicmanager.labels" . | nindent 4 }}
spec:
{{- with .Values.ingress.className }}
ingressClassName: {{ . }}
{{- end }}
{{- if .Values.ingress.tls.enabled }}
tls:
- hosts:
- {{ .Values.ingress.host | quote }}
secretName: {{ .Values.ingress.tls.secretName }}
{{- end }}
rules:
- host: {{ .Values.ingress.host | quote }}
http:
paths:
- path: {{ .Values.ingress.path }}
pathType: {{ .Values.ingress.pathType }}
backend:
service:
name: {{ include "musicmanager.fullname" . }}
port:
name: http
{{- end }}
+17
View File
@@ -0,0 +1,17 @@
{{- if .Values.data.persistence.enabled }}
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ include "musicmanager.fullname" . }}-data
labels:
{{- include "musicmanager.labels" . | nindent 4 }}
spec:
accessModes:
{{- toYaml .Values.data.persistence.accessModes | nindent 4 }}
{{- with .Values.data.persistence.storageClass }}
storageClassName: {{ . | quote }}
{{- end }}
resources:
requests:
storage: {{ .Values.data.persistence.size }}
{{- end }}
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "musicmanager.fullname" . }}
labels:
{{- include "musicmanager.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
selector:
{{- include "musicmanager.selectorLabels" . | nindent 4 }}
ports:
- name: http
port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
+88
View File
@@ -0,0 +1,88 @@
replicaCount: 1
image:
repository: gitea.tap-tap.win/tap-tap/audiomanager
tag: "" # defaults to appVersion
pullPolicy: IfNotPresent
imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""
# Rendered into a ConfigMap as /etc/musicmanager/library.yaml.
# Keep folder IDs stable: they are part of song IDs.
library:
folders:
- id: 1
name: "Music"
type: music
path: /mnt/media/music
- id: 10
name: "Audiobooks & Podcasts"
type: longform
path: /mnt/media/longform
# Vault-managed users.yaml. The secret must already exist and contain the key below.
users:
existingSecret: musicmanager-users
key: users.yaml
data:
persistence:
enabled: true
size: 5Gi
storageClass: ""
accessModes:
- ReadWriteOnce
# hostPath mounts shared by every schedulable node. Read-only in the pod.
media:
music:
hostPath: /mnt/media/music
mountPath: /mnt/media/music
longform:
hostPath: /mnt/media/longform
mountPath: /mnt/media/longform
service:
type: ClusterIP
port: 8080
ingress:
enabled: true
className: traefik
host: subsonic.tap-tap.win
path: /
pathType: Prefix
tls:
enabled: true
secretName: subsonic-tap-tap-win-tls
resources:
requests:
cpu: 100m
memory: 256Mi
limits:
cpu: 1000m
memory: 512Mi
podSecurityContext:
fsGroup: 10001
securityContext:
runAsNonRoot: true
runAsUser: 10001
runAsGroup: 10001
readOnlyRootFilesystem: true
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
env:
- name: WEB_UI
value: "true"
nodeSelector: {}
tolerations: []
affinity: {}