Add Docker build and Gitea Actions CI for deployment
Multi-stage Alpine Dockerfile producing a standalone Next.js image with the better-sqlite3 native addon included. Gitea workflow builds on push to main and on v* tags, pushing to the Gitea registry using the REGISTRY_URL variable and REGISTRY_TOKEN secret. Compose file mounts ./data so alerts.db and settings.json persist across restarts. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
name: Build and Push
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
tags: ["v*"]
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Derive image reference
|
||||
id: img
|
||||
run: |
|
||||
echo "name=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
|
||||
echo "sha_short=${GITHUB_SHA::7}" >> $GITHUB_OUTPUT
|
||||
|
||||
- uses: docker/setup-buildx-action@v3
|
||||
|
||||
- uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ vars.REGISTRY_URL }}
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.REGISTRY_TOKEN }}
|
||||
|
||||
- name: Compute tags
|
||||
id: tags
|
||||
run: |
|
||||
IMAGE="${{ vars.REGISTRY_URL }}/${{ steps.img.outputs.name }}"
|
||||
TAGS="${IMAGE}:${{ steps.img.outputs.sha_short }}"
|
||||
if [ "${{ github.ref }}" = "refs/heads/main" ]; then
|
||||
TAGS="${TAGS},${IMAGE}:latest"
|
||||
fi
|
||||
if [[ "${{ github.ref }}" == refs/tags/v* ]]; then
|
||||
TAGS="${TAGS},${IMAGE}:${GITHUB_REF_NAME}"
|
||||
fi
|
||||
echo "tags=${TAGS}" >> $GITHUB_OUTPUT
|
||||
|
||||
- uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
tags: ${{ steps.tags.outputs.tags }}
|
||||
cache-from: type=registry,ref=${{ vars.REGISTRY_URL }}/${{ steps.img.outputs.name }}:buildcache
|
||||
cache-to: type=registry,ref=${{ vars.REGISTRY_URL }}/${{ steps.img.outputs.name }}:buildcache,mode=max
|
||||
Reference in New Issue
Block a user