From fd8a377664ff3372b41952fda2e5d0de789db1b0 Mon Sep 17 00:00:00 2001 From: Kappeh Date: Mon, 22 Jun 2026 19:14:16 +0100 Subject: [PATCH] Add navidrome container --- .gitea/workflows/ci_cd.yml | 33 +++++++++++++++++++++++++++ compose.yml | 46 ++++++++++++++++++++++++++++++++++++++ init.sh | 17 ++++++++++++++ 3 files changed, 96 insertions(+) create mode 100644 .gitea/workflows/ci_cd.yml create mode 100644 compose.yml create mode 100755 init.sh diff --git a/.gitea/workflows/ci_cd.yml b/.gitea/workflows/ci_cd.yml new file mode 100644 index 0000000..e8e587e --- /dev/null +++ b/.gitea/workflows/ci_cd.yml @@ -0,0 +1,33 @@ +name: Deploy + +on: + push: + branches: + - main + +jobs: + deploy: + name: Deploy + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v5 + + - name: Setup ssh-agent + uses: webfactory/ssh-agent@v0.9.0 + with: + ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} + + - name: Deploy to remote + env: + REMOTE_USER: ${{ vars.REMOTE_USER }} + REMOTE_HOST: ${{ vars.REMOTE_HOST }} + REMOTE_PATH: ${{ vars.REMOTE_PATH }} + run: | + ssh -o StrictHostKeyChecking=no "$REMOTE_USER"@"$REMOTE_HOST" "mkdir -p \"$REMOTE_PATH\"" + scp -r ./* "$REMOTE_USER"@"$REMOTE_HOST":"$REMOTE_PATH" + ssh "$REMOTE_USER"@"$REMOTE_HOST" "docker compose -f $REMOTE_PATH/compose.yml down" + ssh "$REMOTE_USER"@"$REMOTE_HOST" "docker compose -f $REMOTE_PATH/compose.yml pull" + ssh "$REMOTE_USER"@"$REMOTE_HOST" "docker compose -f $REMOTE_PATH/compose.yml up -d --force-recreate" + diff --git a/compose.yml b/compose.yml new file mode 100644 index 0000000..3e3b041 --- /dev/null +++ b/compose.yml @@ -0,0 +1,46 @@ +services: + navidrome: + image: deluan/navidrome:0.62.0 + restart: unless-stopped + depends_on: + init: + condition: service_completed_successfully + restart: true + user: 2012:2012 # navidrome:navidrome + networks: + - navidrome_network + ports: + - 4534:4533 + environment: + ND_BASEURL: "https://navidrome.kappeh.org" + ND_ENABLEINSIGHTSCOLLECTOR: false + volumes: + - data:/data:rw + - /mnt/media_library_1/data/music:/music:ro + labels: + diun.enable: true + diun.watch_repo: true + diun.include_tags: latest + + init: + image: busybox:1.38.0 + user: root:root + command: /init.sh + restart: no + network_mode: none + volumes: + - ./init.sh:/init.sh:ro + - /etc/passwd:/etc/passwd:ro + - /etc/group:/etc/group:ro + - data:/data:rw + labels: + diun.enable: true + diun.watch_repo: true + diun.include_tags: latest + +volumes: + data: + +networks: + navidrome_network: + diff --git a/init.sh b/init.sh new file mode 100755 index 0000000..6830add --- /dev/null +++ b/init.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env sh + +# Define a helper function that runs a command +# If the command fails, the script prints an error message +# and exits immediately. +run() { + # "$@" expands to all arguments passed to this function + # and preserves proper word splitting and quoting. + "$@" || { + echo "Error: command failed: $*" >&2 + exit 1 + } +} + +# Make sure volumes have correct permissions +run chown navidrome:navidrome /data +