Add CI workflow for Docker builds
Some checks failed
Build and Push Docker Image / build-and-push (push) Failing after 3m25s
Some checks failed
Build and Push Docker Image / build-and-push (push) Failing after 3m25s
- Gitea Actions workflow to build and push to container registry - Deployment compose file for pulling from registry Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
48
.gitea/workflows/build-push.yml
Normal file
48
.gitea/workflows/build-push.yml
Normal file
@@ -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
|
||||
38
docker-compose.deploy.yml
Normal file
38
docker-compose.deploy.yml
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user