ci: aggiungi pipeline build staging e Dockerfile
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
name: Reusable Build
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
registry:
|
||||
description: "Registry hostname (es: gitea.example.com)"
|
||||
required: true
|
||||
type: string
|
||||
image_name:
|
||||
description: "Nome completo dell'immagine (es: gitea.example.com/org/app)"
|
||||
required: true
|
||||
type: string
|
||||
image_tag:
|
||||
description: "Tag fisso da applicare (es: staging, latest)"
|
||||
required: false
|
||||
type: string
|
||||
default: "latest"
|
||||
dockerfile:
|
||||
description: "Path del Dockerfile da usare"
|
||||
required: false
|
||||
type: string
|
||||
default: "Dockerfile"
|
||||
|
||||
jobs:
|
||||
build_image:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
permissions:
|
||||
packages: write
|
||||
contents: read
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Configura Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
with:
|
||||
buildkitd-flags: --debug
|
||||
|
||||
- name: Login al registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ inputs.registry }}
|
||||
username: ${{ secrets.DOCKER_LOGIN_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_LOGIN_TOKEN }}
|
||||
|
||||
- name: Genera metadata Docker
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ${{ inputs.image_name }}
|
||||
tags: |
|
||||
type=ref,event=tag
|
||||
type=raw,value=${{ inputs.image_tag }}
|
||||
labels: |
|
||||
org.opencontainers.image.title=learn
|
||||
org.opencontainers.image.description=Applicazione Rails/Laravel
|
||||
org.opencontainers.image.vendor=Procne SRL
|
||||
|
||||
- name: Create dummy .npmrc_secret
|
||||
run: touch ./.npmrc_secret
|
||||
|
||||
- name: Build e Push immagine
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
file: ${{ inputs.dockerfile }}
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
cache-from: type=registry,ref=${{ inputs.image_name }}:buildcache
|
||||
cache-to: type=registry,ref=${{ inputs.image_name }}:buildcache,mode=max
|
||||
secret-files: |
|
||||
npmrc=./.npmrc_secret
|
||||
|
||||
- name: Riepilogo build
|
||||
run: |
|
||||
echo "=== Build completata ==="
|
||||
echo "Immagine: ${{ inputs.image_name }}"
|
||||
echo "Tag: ${{ inputs.image_tag }}"
|
||||
echo "Tags generati:"
|
||||
echo "${{ steps.meta.outputs.tags }}"
|
||||
echo ""
|
||||
echo "La cache è stata salvata su: ${{ inputs.image_name }}:buildcache"
|
||||
Reference in New Issue
Block a user