chore: Refactor CI workflow for Docker builds to include shared setup job
Some checks failed
Docker Build and Push / setup (push) Successful in 12s
Integration Tests / integration-tests (push) Failing after 34s
Integration Tests / performance-tests (push) Has been skipped
Docker Build and Push / build-push-api-gateway (push) Successful in 43s
Docker Build and Push / build-push-service-adapters (push) Successful in 39s
Docker Build and Push / build-push-api-docs (push) Successful in 35s
Docker Build and Push / build-push-frontend (push) Successful in 36s

### Summary of Changes
- Introduced a shared setup job in the CI workflow to streamline common steps for building and pushing Docker images.
- Updated individual build jobs for API Gateway, Service Adapters, API Docs, and Frontend to depend on the setup job, ensuring consistent versioning and labeling.

### Expected Results
- Enhanced maintainability and clarity of the CI workflow by reducing redundancy and centralizing setup steps, leading to more efficient Docker image builds.
This commit is contained in:
GSRN
2025-09-17 23:17:34 +02:00
parent c017403753
commit e9ebf31c88

View File

@@ -14,23 +14,17 @@ env:
IMAGE_PREFIX: labfusion IMAGE_PREFIX: labfusion
jobs: jobs:
build-and-push: # Shared setup job for common steps
setup:
runs-on: ubuntu-latest runs-on: ubuntu-latest
outputs:
version: ${{ steps.meta.outputs.version }}
labels: ${{ steps.meta.outputs.labels }}
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY_URL }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Extract metadata - name: Extract metadata
id: meta id: meta
uses: docker/metadata-action@v5 uses: docker/metadata-action@v5
@@ -49,46 +43,122 @@ jobs:
type=sha,prefix={{branch}}- type=sha,prefix={{branch}}-
type=raw,value=latest,enable={{is_default_branch}} type=raw,value=latest,enable={{is_default_branch}}
# API Gateway build and push
build-push-api-gateway:
runs-on: ubuntu-latest
needs: setup
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY_URL }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Build and push API Gateway - name: Build and push API Gateway
uses: docker/build-push-action@v5 uses: docker/build-push-action@v5
with: with:
context: ./services/api-gateway context: ./services/api-gateway
platforms: linux/amd64,linux/arm64 platforms: linux/amd64,linux/arm64
push: true push: true
tags: ${{ env.REGISTRY }}/${{ env.REPO_OWNER }}/api-gateway:${{ steps.meta.outputs.version }} tags: ${{ env.REGISTRY }}/${{ env.REPO_OWNER }}/api-gateway:${{ needs.setup.outputs.version }}
labels: ${{ steps.meta.outputs.labels }} labels: ${{ needs.setup.outputs.labels }}
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.REPO_OWNER }}/api-gateway:cache cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.REPO_OWNER }}/api-gateway:cache
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.REPO_OWNER }}/api-gateway:cache,mode=max cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.REPO_OWNER }}/api-gateway:cache,mode=max
# Service Adapters build and push
build-push-service-adapters:
runs-on: ubuntu-latest
needs: setup
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY_URL }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Build and push Service Adapters - name: Build and push Service Adapters
uses: docker/build-push-action@v5 uses: docker/build-push-action@v5
with: with:
context: ./services/service-adapters context: ./services/service-adapters
platforms: linux/amd64,linux/arm64 platforms: linux/amd64,linux/arm64
push: true push: true
tags: ${{ env.REGISTRY }}/${{ env.REPO_OWNER }}/service-adapters:${{ steps.meta.outputs.version }} tags: ${{ env.REGISTRY }}/${{ env.REPO_OWNER }}/service-adapters:${{ needs.setup.outputs.version }}
labels: ${{ steps.meta.outputs.labels }} labels: ${{ needs.setup.outputs.labels }}
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.REPO_OWNER }}/service-adapters:cache cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.REPO_OWNER }}/service-adapters:cache
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.REPO_OWNER }}/service-adapters:cache,mode=max cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.REPO_OWNER }}/service-adapters:cache,mode=max
# API Docs build and push
build-push-api-docs:
runs-on: ubuntu-latest
needs: setup
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY_URL }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Build and push API Docs - name: Build and push API Docs
uses: docker/build-push-action@v5 uses: docker/build-push-action@v5
with: with:
context: ./services/api-docs context: ./services/api-docs
platforms: linux/amd64,linux/arm64 platforms: linux/amd64,linux/arm64
push: true push: true
tags: ${{ env.REGISTRY }}/${{ env.REPO_OWNER }}/api-docs:${{ steps.meta.outputs.version }} tags: ${{ env.REGISTRY }}/${{ env.REPO_OWNER }}/api-docs:${{ needs.setup.outputs.version }}
labels: ${{ steps.meta.outputs.labels }} labels: ${{ needs.setup.outputs.labels }}
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.REPO_OWNER }}/api-docs:cache cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.REPO_OWNER }}/api-docs:cache
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.REPO_OWNER }}/api-docs:cache,mode=max cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.REPO_OWNER }}/api-docs:cache,mode=max
# Frontend build and push
build-push-frontend:
runs-on: ubuntu-latest
needs: setup
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY_URL }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Build and push Frontend - name: Build and push Frontend
uses: docker/build-push-action@v5 uses: docker/build-push-action@v5
with: with:
context: ./frontend context: ./frontend
platforms: linux/amd64,linux/arm64 platforms: linux/amd64,linux/arm64
push: true push: true
tags: ${{ env.REGISTRY }}/${{ env.REPO_OWNER }}/frontend:${{ steps.meta.outputs.version }} tags: ${{ env.REGISTRY }}/${{ env.REPO_OWNER }}/frontend:${{ needs.setup.outputs.version }}
labels: ${{ steps.meta.outputs.labels }} labels: ${{ needs.setup.outputs.labels }}
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.REPO_OWNER }}/frontend:cache cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.REPO_OWNER }}/frontend:cache
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.REPO_OWNER }}/frontend:cache,mode=max cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.REPO_OWNER }}/frontend:cache,mode=max