Files
api-golang/.gitea/workflows/docker.yml
Flavio Fois 6c8b400a4a add docker configuration and gitea workflow for automated image builds
Introduce a multi-stage Dockerfile, docker-compose setup, and a Gitea Actions workflow to automate building and pushing images to the registry. The configuration includes an entrypoint script for persistent logging and a .dockerignore to optimize the build context.
2026-03-23 11:09:25 +01:00

56 lines
1.5 KiB
YAML

name: Build & Publish Docker Image
on:
push:
branches:
- main
tags:
- "v*"
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
# Strip "https://" from the server URL to get the registry hostname
- name: Resolve registry host
id: reg
run: |
host=$(echo "${{ gitea.server_url }}" | sed 's|https://||;s|http://||;s|/||g')
echo "host=$host" >> $GITHUB_OUTPUT
echo "image=$host/${{ gitea.repository }}" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Gitea registry
uses: docker/login-action@v3
with:
registry: ${{ steps.reg.outputs.host }}
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ steps.reg.outputs.image }}
tags: |
type=raw,value=latest,enable=${{ gitea.ref == 'refs/heads/main' }}
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha,prefix=sha-,format=short
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max