From 21d82c5413463ae585d2849399bfac4d6429fa42 Mon Sep 17 00:00:00 2001 From: 20ichrish Date: Sun, 18 Jan 2026 16:39:19 -0800 Subject: [PATCH] Add CI workflow for Docker builds - Gitea Actions workflow to build and push to container registry - Deployment compose file for pulling from registry Co-Authored-By: Claude Opus 4.5 --- .gitea/workflows/build-push.yml | 48 +++++++++++++++++++++++++++++++++ docker-compose.deploy.yml | 38 ++++++++++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 .gitea/workflows/build-push.yml create mode 100644 docker-compose.deploy.yml diff --git a/.gitea/workflows/build-push.yml b/.gitea/workflows/build-push.yml new file mode 100644 index 0000000..8894538 --- /dev/null +++ b/.gitea/workflows/build-push.yml @@ -0,0 +1,48 @@ +name: Build and Push Docker Image + +on: + push: + branches: + - main + workflow_dispatch: # Manual trigger + +env: + REGISTRY: ${{ vars.REGISTRY_HOST }} # Set in Gitea repo settings, e.g., gitea.local + IMAGE_NAME: ${{ gitea.repository }} # e.g., username/ghbot + +jobs: + build-and-push: + runs-on: ubuntu-latest # Or your self-hosted runner label + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to Gitea Container Registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ gitea.actor }} + password: ${{ secrets.REGISTRY_TOKEN }} + + - name: Extract metadata (tags, labels) + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=raw,value=latest,enable={{is_default_branch}} + type=sha,prefix= + type=ref,event=branch + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/docker-compose.deploy.yml b/docker-compose.deploy.yml new file mode 100644 index 0000000..68d4e4c --- /dev/null +++ b/docker-compose.deploy.yml @@ -0,0 +1,38 @@ +version: '3.8' + +# Deployment compose file - pulls from Gitea registry instead of building locally +# Usage: docker compose -f docker-compose.deploy.yml up -d + +services: + discord-bot: + # Pull from Gitea registry (update with your actual registry URL) + image: ${REGISTRY_HOST:-gitea.local}/${REGISTRY_USER:-username}/ghbot:${IMAGE_TAG:-latest} + container_name: discord-bot + restart: unless-stopped + volumes: + # Seed file for initial database population (read-only) + - ./seed.json:/app/seed.json:ro + - ./conf:/app/conf:ro + + # Sound effects directory (read-only) + - ./sfx:/app/sfx:ro + + # Database persistence + - ./data:/app/data + + environment: + - NODE_ENV=production + + deploy: + resources: + limits: + memory: 512M + reservations: + memory: 256M + + healthcheck: + test: ["CMD", "node", "-e", "process.exit(0)"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s