Aggiornamento staging #1

Merged
Alessio merged 25 commits from main into staging 2026-01-24 17:31:13 +01:00
4 changed files with 446 additions and 0 deletions
Showing only changes of commit 4b27c6a11d - Show all commits
+219
View File
@@ -0,0 +1,219 @@
# Gitea Actions per Data-Coupler
## 📋 Panoramica
Questo repository utilizza **Gitea Actions** per automatizzare la build e la pubblicazione delle immagini Docker del progetto Data-Coupler.
## 🔧 Configurazione
### Prerequisiti
Per utilizzare Gitea Actions su questo repository, è necessario:
1. **Gitea Account**: Avere un account su Gitea (gitea.com o istanza self-hosted)
2. **Repository Settings**: Abilitare Gitea Actions nelle impostazioni del repository
3. **Container Registry**: Avere accesso al Gitea Container Registry
4. **Secret Configuration**: Configurare il secret `GITEA_TOKEN`
### Configurazione del Secret GITEA_TOKEN
Il workflow richiede un token di accesso per pubblicare le immagini Docker sul registry:
1. Vai su **Settings → Secrets** nel repository Gitea
2. Crea un nuovo secret chiamato `GITEA_TOKEN`
3. Il valore deve essere un Personal Access Token con i seguenti permessi:
- `write:packages` - Per pubblicare container images
- `read:packages` - Per leggere images esistenti
#### Come Creare un Personal Access Token su Gitea
1. Vai su **Settings → Applications** nel tuo profilo Gitea
2. Clicca su **Generate New Token**
3. Nome del token: `Data-Coupler Docker Build`
4. Seleziona i seguenti scopes:
- `write:packages`
- `read:packages`
5. Clicca su **Generate Token**
6. Copia il token generato (sarà mostrato solo una volta)
### Configurazione del Repository Path
Nel file `.gitea/workflows/docker-build.yml`, modifica la variabile `IMAGE_NAME`:
```yaml
env:
REGISTRY: gitea.com
IMAGE_NAME: tuo-username/data-coupler # Modifica con il tuo username/organization
```
**Importante**: Sostituisci `alessiodalsanto` con il tuo username o nome dell'organization su Gitea.
## 🚀 Workflow
### Docker Build Workflow
**File**: `.gitea/workflows/docker-build.yml`
#### Trigger Events
Il workflow si attiva automaticamente su:
- **Push** sui branch: `main`, `development`, `staging`
- **Manual dispatch** tramite interfaccia web
#### Jobs
Il workflow è composto da 3 job principali:
##### 1. `build-linux` - Build Immagine Linux
- **Runner**: `ubuntu-latest`
- **Dockerfile**: `./Dockerfile`
- **Platform**: `linux/amd64`
- **Tags generati**:
- `latest` (per branch `main` e `development`)
- `development-latest` (per branch `development`)
- `staging-latest` (per branch `staging`)
- `<branch>-<sha>` (per ogni commit)
- `<branch>-<timestamp>` (con data/ora)
##### 2. `build-windows` - Build Immagine Windows
- **Runner**: `windows-2022`
- **Dockerfile**: `./Dockerfile.windows`
- **Platform**: Windows Server 2022
- **Tags generati**: Come Linux ma con suffisso `-windows`
##### 3. `create-manifest` - Multi-Platform Manifest
- **Runner**: `ubuntu-latest`
- **Dipendenze**: `build-linux`, `build-windows`
- Crea manifest multi-piattaforma che combinano le immagini Linux e Windows
### Strategia di Tagging
#### Branch `main`
- `latest` - Tag condiviso per versione stabile
- `latest-windows` - Versione Windows
- `main-<sha>` - Tag specifico per commit
- `main-<timestamp>` - Tag con timestamp
#### Branch `development`
- `latest` - Tag condiviso per ultime funzionalità
- `development-latest` - Tag specifico per development
- `latest-windows` / `development-latest-windows` - Versioni Windows
- `development-<sha>` - Tag specifico per commit
- `development-<timestamp>` - Tag con timestamp
#### Branch `staging`
- `staging-latest` - Tag per ambiente di staging
- `staging-latest-windows` - Versione Windows
- `staging-<sha>` - Tag specifico per commit
- `staging-<timestamp>` - Tag con timestamp
## 📦 Utilizzo delle Immagini
### Pull delle Immagini
#### Da Gitea Container Registry
```bash
# Ultima versione stabile (main/development)
docker pull gitea.com/alessiodalsanto/data-coupler:latest
# Versione development specifica
docker pull gitea.com/alessiodalsanto/data-coupler:development-latest
# Versione staging
docker pull gitea.com/alessiodalsanto/data-coupler:staging-latest
# Versione Windows
docker pull gitea.com/alessiodalsanto/data-coupler:latest-windows
```
### Docker Compose
Modifica il `docker-compose.yml` per usare le immagini Gitea:
```yaml
services:
data-coupler:
image: gitea.com/alessiodalsanto/data-coupler:latest
# ... resto della configurazione
```
## 🔍 Monitoraggio
### Visualizzare lo Stato dei Workflow
1. Vai nella tab **Actions** del repository Gitea
2. Seleziona il workflow **Build and Push Docker Images**
3. Visualizza i dettagli di ogni esecuzione
### Log e Debug
- I log di ogni job sono disponibili nell'interfaccia Gitea Actions
- Per debug dettagliato, attiva il manual dispatch con opzione `force_build`
## 🔄 Differenze con GitHub Actions
### Principali Differenze
1. **Context Variables**:
- GitHub: `github.*` → Gitea: `gitea.*`
- Esempio: `github.actor``gitea.actor`
2. **Registry**:
- GitHub: `ghcr.io` → Gitea: `gitea.com`
3. **Secret Name**:
- GitHub: `GITHUB_TOKEN` (automatico) → Gitea: `GITEA_TOKEN` (configurato manualmente)
4. **Attestation**:
- Il job di attestation non è presente su Gitea (feature GitHub specifica)
### Compatibilità
Gitea Actions è compatibile con la maggior parte delle GitHub Actions disponibili su GitHub Marketplace, incluse:
- `actions/checkout@v4`
- `docker/setup-buildx-action@v3`
- `docker/login-action@v3`
- `docker/build-push-action@v5`
- `docker/metadata-action@v5`
## 🛠️ Troubleshooting
### Errore di Autenticazione
Se ottieni errori di autenticazione:
1. Verifica che il secret `GITEA_TOKEN` sia configurato correttamente
2. Assicurati che il token abbia i permessi `write:packages`
3. Controlla che il token non sia scaduto
### Build Fallita
Se la build fallisce:
1. Controlla i log del job specifico
2. Verifica che i Dockerfile siano presenti e corretti
3. Assicurati che le dipendenze NuGet siano accessibili
### Immagini Non Pubblicate
Se le immagini non vengono pubblicate:
1. Verifica che `IMAGE_NAME` sia corretto
2. Controlla che il registry sia accessibile
3. Verifica i permessi del token
## 📚 Risorse
- [Gitea Actions Documentation](https://docs.gitea.io/en-us/actions/)
- [GitHub Actions Compatibility](https://docs.gitea.io/en-us/usage/actions/comparison/)
- [Docker Build Push Action](https://github.com/docker/build-push-action)
## 📝 Note
- Le immagini sono private per default; configura le impostazioni del package per renderle pubbliche se necessario
- Il workflow supporta anche l'esecuzione manuale tramite `workflow_dispatch`
- I manifest multi-platform permettono di usare lo stesso tag per Linux e Windows
---
**Versione**: 1.0
**Ultimo Aggiornamento**: 24 Gennaio 2026
**Maintainer**: Alessio Dalsanto
+188
View File
@@ -0,0 +1,188 @@
name: Build and Push Docker Images
on:
push:
branches:
- main
- development
- staging
workflow_dispatch:
inputs:
force_build:
description: 'Force build even without code changes'
required: false
default: false
type: boolean
env:
# Gitea Container Registry
REGISTRY: gitea.com
# Repository path (format: owner/repo)
IMAGE_NAME: alessiodalsanto/data-coupler
jobs:
build-linux:
name: Build Linux Container
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
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.GITEA_TOKEN }}
- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
# Tag based on branch
type=raw,value=latest,enable=${{ gitea.ref == 'refs/heads/main' }}
type=raw,value=latest,enable=${{ gitea.ref == 'refs/heads/development' }}
type=raw,value=development-latest,enable=${{ gitea.ref == 'refs/heads/development' }}
type=raw,value=dev-latest,enable=${{ gitea.ref == 'refs/heads/dev' }}
type=raw,value=staging-latest,enable=${{ gitea.ref == 'refs/heads/staging' }}
# Tag with commit sha
type=sha,prefix={{branch}}-,format=short
# Tag with date
type=raw,value={{branch}}-{{date 'YYYYMMDD-HHmmss'}}
flavor: |
latest=false
- name: Build and push Linux Docker image
id: build
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64
build-windows:
name: Build Windows Container
runs-on: windows-2022
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to Gitea Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ gitea.actor }}
password: ${{ secrets.GITEA_TOKEN }}
- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
# Tag based on branch with windows suffix
type=raw,value=latest-windows,enable=${{ gitea.ref == 'refs/heads/main' }}
type=raw,value=latest-windows,enable=${{ gitea.ref == 'refs/heads/development' }}
type=raw,value=development-latest-windows,enable=${{ gitea.ref == 'refs/heads/development' }}
type=raw,value=dev-latest-windows,enable=${{ gitea.ref == 'refs/heads/dev' }}
type=raw,value=staging-latest-windows,enable=${{ gitea.ref == 'refs/heads/staging' }}
# Tag with commit sha
type=sha,prefix={{branch}}-windows-,format=short
# Tag with date
type=raw,value={{branch}}-windows-{{date 'YYYYMMDD-HHmmss'}}
flavor: |
latest=false
- name: Build and push Windows Docker image
run: |
# Convert repository name to lowercase
$imageName = "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}".ToLower()
# Build with temporary tag
docker build -t "${imageName}:temp-windows" -f Dockerfile.windows .
# Parse and push all tags
$tags = "${{ steps.meta.outputs.tags }}" -split "`n"
foreach ($tag in $tags) {
$tag = $tag.Trim()
if ($tag) {
# Ensure tag is lowercase
$tag = $tag.ToLower()
Write-Host "Tagging and pushing: $tag"
docker tag "${imageName}:temp-windows" $tag
docker push $tag
}
}
# Remove temporary tag
docker rmi "${imageName}:temp-windows"
shell: pwsh
create-manifest:
name: Create Multi-Platform Manifest
runs-on: ubuntu-latest
needs: [build-linux, build-windows]
permissions:
contents: read
packages: write
steps:
- name: Log in to Gitea Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ gitea.actor }}
password: ${{ secrets.GITEA_TOKEN }}
- name: Create and push manifest for main branch
if: gitea.ref == 'refs/heads/main'
run: |
IMAGE_LOWER=$(echo "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}" | tr '[:upper:]' '[:lower:]')
docker buildx imagetools create -t ${IMAGE_LOWER}:latest \
${IMAGE_LOWER}:latest \
${IMAGE_LOWER}:latest-windows
- name: Create and push manifest for development branch
if: gitea.ref == 'refs/heads/development'
run: |
IMAGE_LOWER=$(echo "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}" | tr '[:upper:]' '[:lower:]')
docker buildx imagetools create -t ${IMAGE_LOWER}:latest \
${IMAGE_LOWER}:latest \
${IMAGE_LOWER}:latest-windows
docker buildx imagetools create -t ${IMAGE_LOWER}:development-latest \
${IMAGE_LOWER}:development-latest \
${IMAGE_LOWER}:development-latest-windows
- name: Create and push manifest for dev branch
if: gitea.ref == 'refs/heads/dev'
run: |
IMAGE_LOWER=$(echo "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}" | tr '[:upper:]' '[:lower:]')
docker buildx imagetools create -t ${IMAGE_LOWER}:dev-latest \
${IMAGE_LOWER}:dev-latest \
${IMAGE_LOWER}:dev-latest-windows
- name: Create and push manifest for staging branch
if: gitea.ref == 'refs/heads/staging'
run: |
IMAGE_LOWER=$(echo "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}" | tr '[:upper:]' '[:lower:]')
docker buildx imagetools create -t ${IMAGE_LOWER}:staging-latest \
${IMAGE_LOWER}:staging-latest \
${IMAGE_LOWER}:staging-latest-windows
+12
View File
@@ -368,15 +368,26 @@
- `hotfix/*`: Fix urgenti - `hotfix/*`: Fix urgenti
### CI/CD Pipeline: ### CI/CD Pipeline:
#### GitHub Actions (`.github/workflows/docker-build.yml`)
- **Branch `main`**: Pubblica immagini Docker con tag `latest` - **Branch `main`**: Pubblica immagini Docker con tag `latest`
- **Branch `development`**: Pubblica immagini Docker con tag `latest` e `development-latest` - **Branch `development`**: Pubblica immagini Docker con tag `latest` e `development-latest`
- **Branch `staging`**: Pubblica immagini Docker con tag `staging-latest` - **Branch `staging`**: Pubblica immagini Docker con tag `staging-latest`
- **Ogni commit**: Crea tag con SHA e timestamp per tracciabilità - **Ogni commit**: Crea tag con SHA e timestamp per tracciabilità
- **Registry**: GitHub Container Registry (`ghcr.io`)
#### Gitea Actions (`.gitea/workflows/docker-build.yml`)
- **Stessa configurazione** di GitHub Actions
- **Registry**: Gitea Container Registry (`gitea.com`)
- **Supporto**: Istanze Gitea self-hosted
- **Setup**: Richiede secret `GITEA_TOKEN` con permessi `write:packages`
- **Documentazione**: `.gitea/workflows/README.md`
**Note sui Tag Docker**: **Note sui Tag Docker**:
- `latest`: Condiviso tra `main` e `development` per garantire accesso alle ultime funzionalità - `latest`: Condiviso tra `main` e `development` per garantire accesso alle ultime funzionalità
- `development-latest`: Specifico per il branch `development`, utile per distinguere le versioni in sviluppo - `development-latest`: Specifico per il branch `development`, utile per distinguere le versioni in sviluppo
- `staging-latest`: Dedicato al branch `staging` per test pre-produzione - `staging-latest`: Dedicato al branch `staging` per test pre-produzione
- Disponibile su **entrambi** i registry (GitHub e Gitea)
### Commit Messages: ### Commit Messages:
- Formato: `[Tipo] Descrizione breve` - Formato: `[Tipo] Descrizione breve`
@@ -399,6 +410,7 @@
- **DELETION_SYNC_IMPLEMENTATION.md**: Sincronizzazione eliminazioni - **DELETION_SYNC_IMPLEMENTATION.md**: Sincronizzazione eliminazioni
- **DOCKER_DEPLOYMENT.md**: Guida deployment Docker - **DOCKER_DEPLOYMENT.md**: Guida deployment Docker
- **WINDOWS_SERVICE_DEPLOYMENT.md**: Deploy come Windows Service - **WINDOWS_SERVICE_DEPLOYMENT.md**: Deploy come Windows Service
- **.gitea/workflows/README.md**: Configurazione Gitea Actions
## 🎓 Best Practices per AI Assistants ## 🎓 Best Practices per AI Assistants
+27
View File
@@ -167,6 +167,33 @@ docker build -t data-coupler:local-windows -f Dockerfile.windows .
📚 **Documentazione Docker Completa**: Vedi [DOCKER_DEPLOYMENT.md](DOCKER_DEPLOYMENT.md) e [GITHUB_ACTIONS_SETUP.md](GITHUB_ACTIONS_SETUP.md) 📚 **Documentazione Docker Completa**: Vedi [DOCKER_DEPLOYMENT.md](DOCKER_DEPLOYMENT.md) e [GITHUB_ACTIONS_SETUP.md](GITHUB_ACTIONS_SETUP.md)
### 🔄 CI/CD Pipeline
Il progetto supporta pipeline CI/CD automatiche su:
**GitHub Actions** (`.github/workflows/docker-build.yml`):
- Build automatica su push ai branch `main`, `development`, `staging`
- Pubblicazione su GitHub Container Registry (`ghcr.io`)
- Multi-platform manifest (Linux + Windows)
**Gitea Actions** (`.gitea/workflows/docker-build.yml`):
- Stessa configurazione di GitHub Actions
- Pubblicazione su Gitea Container Registry (`gitea.com`)
- Supporto per istanze Gitea self-hosted
- Configurazione: `.gitea/workflows/README.md`
**Immagini su Gitea**:
```bash
# Pull da Gitea Container Registry
docker pull gitea.com/alessiodalsanto/data-coupler:latest
# Versioni disponibili
docker pull gitea.com/alessiodalsanto/data-coupler:development-latest
docker pull gitea.com/alessiodalsanto/data-coupler:staging-latest
```
📚 **Setup Gitea**: Vedi [.gitea/workflows/README.md](.gitea/workflows/README.md)
## Caratteristiche di Sicurezza ## Caratteristiche di Sicurezza
- **Crittografia**: Le password vengono crittografate prima del salvataggio - **Crittografia**: Le password vengono crittografate prima del salvataggio