diff --git a/.gitea-registry-auth.example b/.gitea-registry-auth.example new file mode 100644 index 0000000..41de1d8 --- /dev/null +++ b/.gitea-registry-auth.example @@ -0,0 +1,20 @@ +{ + "auths": { + "git.sschuhmann.de": { + "auth": "BASE64_ENCODED_USERNAME_TOKEN" + } + } +} + +# To use this file: +# 1. Copy to ~/.docker/config.json +# 2. Replace BASE64_ENCODED_USERNAME_TOKEN with your actual base64 encoded credentials +# 3. Run: docker login git.sschuhmann.de + +# Generate base64 credentials: +# echo -n "username:token" | base64 + +# Example usage: +# cp .gitea-registry-auth.example ~/.docker/config.json +# # Edit the file with your credentials +# docker login git.sschuhmann.de \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..e954704 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,86 @@ +name: Container Release + +on: + push: + tags: + - 'v*' + - '0.*' + - '1.*' + +env: + REGISTRY: git.sschuhmann.de + REPOSITORY: sschuhmann/rehearsalhub + +jobs: + build-and-push: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Gitea Container Registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ secrets.GITEA_USER }} + password: ${{ secrets.GITEA_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.REPOSITORY }} + tags: | + type=ref,event=tag + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + + - name: Build and push API container + uses: docker/build-push-action@v5 + with: + context: ./api + file: ./api/Dockerfile + push: true + tags: ${{ env.REGISTRY }}/${{ env.REPOSITORY }}/api:${{ github.ref_name }} + labels: ${{ steps.meta.outputs.labels }} + + - name: Build and push Web container + uses: docker/build-push-action@v5 + with: + context: ./web + file: ./web/Dockerfile + push: true + tags: ${{ env.REGISTRY }}/${{ env.REPOSITORY }}/web:${{ github.ref_name }} + labels: ${{ steps.meta.outputs.labels }} + + - name: Build and push Worker container + uses: docker/build-push-action@v5 + with: + context: ./worker + file: ./worker/Dockerfile + push: true + tags: ${{ env.REGISTRY }}/${{ env.REPOSITORY }}/worker:${{ github.ref_name }} + labels: ${{ steps.meta.outputs.labels }} + + - name: Build and push Watcher container + uses: docker/build-push-action@v5 + with: + context: ./watcher + file: ./watcher/Dockerfile + push: true + tags: ${{ env.REGISTRY }}/${{ env.REPOSITORY }}/watcher:${{ github.ref_name }} + labels: ${{ steps.meta.outputs.labels }} + + - name: Summary + run: | + echo "✅ Container release complete!" + echo "" + echo "Pushed images:" + echo " - ${{ env.REGISTRY }}/${{ env.REPOSITORY }}/api:${{ github.ref_name }}" + echo " - ${{ env.REGISTRY }}/${{ env.REPOSITORY }}/web:${{ github.ref_name }}" + echo " - ${{ env.REGISTRY }}/${{ env.REPOSITORY }}/worker:${{ github.ref_name }}" + echo " - ${{ env.REGISTRY }}/${{ env.REPOSITORY }}/watcher:${{ github.ref_name }}" \ No newline at end of file diff --git a/Taskfile.yml b/Taskfile.yml index e2ca31b..21b35ba 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -251,3 +251,20 @@ tasks: interactive: true cmds: - "{{.COMPOSE}} exec redis redis-cli" + +# ── Container Build & Release ────────────────────────────────────────────── + + build:containers: + desc: Build all container images with current git tag + cmds: + - bash scripts/build-containers.sh + + push:containers: + desc: Push all container images to Gitea registry + cmds: + - bash scripts/upload-containers-simple.sh + + release: + desc: Build and push all containers for release (uses current git tag) + cmds: + - bash scripts/release.sh diff --git a/scripts/build-containers.sh b/scripts/build-containers.sh new file mode 100755 index 0000000..4b1eba7 --- /dev/null +++ b/scripts/build-containers.sh @@ -0,0 +1,22 @@ +#!/bin/bash +set -euo pipefail + +# Get current git tag, fall back to "latest" if no tags exist +TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "latest") + +echo "Building container images with tag: $TAG" + +# Build all services using docker compose +docker compose build --no-cache + +echo "Tagging images for Gitea registry..." + +# Tag all images with the current git tag +# Format: git.sschuhmann.de/owner/rehearsalhub/service:tag +docker tag rehearsalhub/api:latest git.sschuhmann.de/sschuhmann/rehearshalhub/api:$TAG +docker tag rehearsalhub/web:latest git.sschuhmann.de/sschuhmann/rehearshalhub/web:$TAG +docker tag rehearsalhub/audio-worker:latest git.sschuhmann.de/sschuhmann/rehearshalhub/worker:$TAG +docker tag rehearsalhub/nc-watcher:latest git.sschuhmann.de/sschuhmann/rehearshalhub/watcher:$TAG + +echo "Build complete! Images tagged as: $TAG" +echo "Ready for upload to git.sschuhmann.de/sschuhmann/rehearsalhub" diff --git a/scripts/release.sh b/scripts/release.sh new file mode 100755 index 0000000..df03622 --- /dev/null +++ b/scripts/release.sh @@ -0,0 +1,29 @@ +#!/bin/bash +set -euo pipefail + +echo "=== RehearsalHub Container Release ===" +echo + +# Get current git tag +TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "latest") +echo "Releasing version: $TAG" +echo + +# Build containers +echo "Step 1/2: Building containers..." +bash scripts/build-containers.sh +echo + +# Upload containers +echo "Step 2/2: Uploading containers to Gitea..." +bash scripts/upload-containers-simple.sh +echo + +echo "✅ Release complete!" +echo "All containers available at: git.sschuhmann.de/sschuhmann/rehearsalhub:$TAG" +echo +echo "Services:" +echo " - api: git.sschuhmann.de/sschuhmann/rehearsalhub/api:$TAG" +echo " - web: git.sschuhmann.de/sschuhmann/rehearsalhub/web:$TAG" +echo " - worker: git.sschuhmann.de/sschuhmann/rehearsalhub/worker:$TAG" +echo " - watcher: git.sschuhmann.de/sschuhmann/rehearsalhub/watcher:$TAG" \ No newline at end of file diff --git a/scripts/test-auth.sh b/scripts/test-auth.sh new file mode 100755 index 0000000..1b8a0c0 --- /dev/null +++ b/scripts/test-auth.sh @@ -0,0 +1,47 @@ +#!/bin/bash +set -euo pipefail + +echo "Testing Docker authentication with git.sschuhmann.de..." + +# Test 1: Check if Docker is running +echo "1. Checking Docker daemon..." +if docker info >/dev/null 2>&1; then + echo " ✅ Docker daemon is running" +else + echo " ❌ Docker daemon is not running" + exit 1 +fi + +# Test 2: Check if we're logged in to any registry +echo "2. Checking Docker login status..." +if docker system df >/dev/null 2>&1; then + echo " ✅ Docker commands work" +else + echo " ❌ Docker commands failed" + exit 1 +fi + +# Test 3: Try to access the Gitea registry +echo "3. Testing Gitea registry access..." +echo " Trying to pull a test image (this may fail if image doesn't exist)..." + +# Use a simple curl test instead of docker manifest +echo "4. Testing registry with curl..." +REGISTRY_URL="https://git.sschuhmann.de" + +if command -v curl >/dev/null 2>&1; then + if curl -s -o /dev/null -w "%{http_code}" "$REGISTRY_URL" | grep -q "^[23]"; then + echo " ✅ Registry is accessible" + else + echo " ⚠️ Registry accessible but may require authentication" + fi +else + echo " ⚠️ curl not available, skipping HTTP test" +fi + +echo "" +echo "Authentication test complete!" +echo "If you're still having issues, try:" +echo " 1. docker logout git.sschuhmann.de" +echo " 2. docker login git.sschuhmann.de" +echo " 3. cat ~/.docker/config.json (check credentials)" \ No newline at end of file diff --git a/scripts/upload-containers-simple.sh b/scripts/upload-containers-simple.sh new file mode 100755 index 0000000..a66ca2e --- /dev/null +++ b/scripts/upload-containers-simple.sh @@ -0,0 +1,39 @@ +#!/bin/bash +set -euo pipefail + +# Get current git tag, fall back to "latest" if no tags exist +TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "latest") + +echo "Uploading container images to Gitea registry with tag: $TAG" + +# Simple check - just try to push and let Docker handle authentication +echo "Attempting to push images to git.sschuhmann.de..." + +# Push all images to Gitea registry +echo "Pushing api image..." +docker push git.sschuhmann.de/sschuhmann/rehearsalhub/api:$TAG || { + echo "Failed to push api image. Check your authentication:" + echo " 1. Run: docker login git.sschuhmann.de" + echo " 2. Check: cat ~/.docker/config.json" + exit 1 +} + +echo "Pushing web image..." +docker push git.sschuhmann.de/sschuhmann/rehearsalhub/web:$TAG || { + echo "Failed to push web image" + exit 1 +} + +echo "Pushing worker image..." +docker push git.sschuhmann.de/sschuhmann/rehearsalhub/worker:$TAG || { + echo "Failed to push worker image" + exit 1 +} + +echo "Pushing watcher image..." +docker push git.sschuhmann.de/sschuhmann/rehearsalhub/watcher:$TAG || { + echo "Failed to push watcher image" + exit 1 +} + +echo "✅ Upload complete! All images pushed to git.sschuhmann.de/sschuhmann/rehearsalhub:$TAG" \ No newline at end of file diff --git a/scripts/upload-containers.sh b/scripts/upload-containers.sh new file mode 100755 index 0000000..c63c97d --- /dev/null +++ b/scripts/upload-containers.sh @@ -0,0 +1,42 @@ +#!/bin/bash +set -euo pipefail + +# Get current git tag, fall back to "latest" if no tags exist +TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "latest") + +echo "Uploading container images to Gitea registry with tag: $TAG" + +# Simple authentication test - try to get registry info +if ! docker info >/dev/null 2>&1; then + echo "Error: Docker daemon is not running" + exit 1 +fi + +# Test authentication by trying to list repositories (this will fail if not authenticated) +echo "Testing Gitea registry authentication..." +if ! timeout 10s docker manifest inspect git.sschuhmann.de/sschuhmann/rehearsalhub/api:$TAG >/dev/null 2>&1; then + # Check if the error is specifically authentication related + TEST_OUTPUT=$(docker manifest inspect git.sschuhmann.de/sschuhmann/rehearsalhub/api:$TAG 2>&1 || true) + if echo "$TEST_OUTPUT" | grep -qi "401\|unauthorized\|authentication required"; then + echo "Error: Not authenticated with git.sschuhmann.de registry" + echo "Please run: docker login git.sschuhmann.de" + exit 1 + fi + # If it's not an auth error, it's probably just that the image doesn't exist yet + echo "Registry accessible (image doesn't exist yet, will be created)" +fi + +# Push all images to Gitea registry +echo "Pushing api image..." +docker push git.sschuhmann.de/sschuhmann/rehearsalhub/api:$TAG + +echo "Pushing web image..." +docker push git.sschuhmann.de/sschuhmann/rehearsalhub/web:$TAG + +echo "Pushing worker image..." +docker push git.sschuhmann.de/sschuhmann/rehearsalhub/worker:$TAG + +echo "Pushing watcher image..." +docker push git.sschuhmann.de/sschuhmann/rehearsalhub/watcher:$TAG + +echo "Upload complete! All images pushed to git.sschuhmann.de/sschuhmann/rehearsalhub:$TAG" \ No newline at end of file