ci: workflow Gitea de build et publication de l'image Docker
Build de l'image unique depuis backend.Dockerfile et push vers le registre (secrets REGISTRY_*). Déclenché sur main, tags v* et manuel. Tags d'image : latest/main sur la branche par défaut, semver (X.Y.Z / X.Y / X) sur les tags. Pas de tag par SHA (économie d'espace registre). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
82
.gitea/workflows/docker-publish.yml
Normal file
82
.gitea/workflows/docker-publish.yml
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
name: Build and Publish Docker Image
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
tags:
|
||||||
|
- "v*"
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
env:
|
||||||
|
REGISTRY: ${{ secrets.REGISTRY_URL }}
|
||||||
|
NAMESPACE: ${{ secrets.REGISTRY_NAMESPACE }}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: Build App Image
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Log in to Docker Registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ${{ env.REGISTRY }}
|
||||||
|
username: ${{ secrets.REGISTRY_USERNAME }}
|
||||||
|
password: ${{ secrets.REGISTRY_PASSWORD }}
|
||||||
|
|
||||||
|
- name: Extract metadata
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v5
|
||||||
|
with:
|
||||||
|
images: ${{ env.REGISTRY }}/${{ env.NAMESPACE }}/plesna-gerance
|
||||||
|
tags: |
|
||||||
|
type=ref,event=branch
|
||||||
|
type=semver,pattern={{version}}
|
||||||
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
|
type=semver,pattern={{major}}
|
||||||
|
type=raw,value=latest,enable={{is_default_branch}}
|
||||||
|
labels: |
|
||||||
|
org.opencontainers.image.title=Plesna Gerance
|
||||||
|
org.opencontainers.image.description=Extracteur de comptes rendus de gerance Oralia/ICS (API + interface web)
|
||||||
|
org.opencontainers.image.source=${{ gitea.server_url }}/${{ gitea.repository }}
|
||||||
|
org.opencontainers.image.version=${{ gitea.ref_name }}
|
||||||
|
|
||||||
|
- name: Build and push image
|
||||||
|
id: build
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
# Conteneur unique : l'image builde le frontend Vue puis le fait
|
||||||
|
# servir par le backend FastAPI (cf. backend.Dockerfile).
|
||||||
|
context: .
|
||||||
|
file: ./backend.Dockerfile
|
||||||
|
push: true
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
platforms: linux/amd64
|
||||||
|
|
||||||
|
- name: Image digest
|
||||||
|
run: |
|
||||||
|
echo "Image pushed with digest: ${{ steps.build.outputs.digest }}"
|
||||||
|
echo "Tags: ${{ steps.meta.outputs.tags }}"
|
||||||
|
|
||||||
|
summary:
|
||||||
|
name: Build Summary
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: [build]
|
||||||
|
if: always()
|
||||||
|
steps:
|
||||||
|
- name: Build summary
|
||||||
|
run: |
|
||||||
|
echo "## 🐳 Docker Image Built Successfully"
|
||||||
|
echo ""
|
||||||
|
echo "- Registry: ${{ env.REGISTRY }}/${{ env.NAMESPACE }}/plesna-gerance"
|
||||||
|
echo "- Tags: latest, ${{ gitea.ref_name }}"
|
||||||
|
echo ""
|
||||||
|
echo "### 🚀 Deployment"
|
||||||
|
echo "docker compose up -d"
|
||||||
Reference in New Issue
Block a user