### Summary of Changes - Changed the runner configuration for all build jobs in the CI workflow from `ubuntu-latest` to `self-hosted`, ensuring that builds utilize self-hosted infrastructure. ### Expected Results - Improved build performance and resource management by leveraging self-hosted runners, aligning with the project's infrastructure strategy.
164 lines
5.3 KiB
YAML
164 lines
5.3 KiB
YAML
name: Docker Build and Push
|
|
|
|
on:
|
|
push:
|
|
branches: [ main, develop ]
|
|
tags: [ 'v*' ]
|
|
pull_request:
|
|
branches: [ main, develop ]
|
|
|
|
env:
|
|
REGISTRY: gittea.kammenstraatha.duckdns.org
|
|
REGISTRY_URL: https://gittea.kammenstraatha.duckdns.org
|
|
REPO_OWNER: admin
|
|
IMAGE_PREFIX: labfusion
|
|
|
|
jobs:
|
|
# Shared setup job for common steps
|
|
setup: self-hosted
|
|
outputs:
|
|
version: ${{ steps.meta.outputs.version }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Extract metadata
|
|
id: meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: |
|
|
${{ env.REGISTRY }}/${{ env.REPO_OWNER }}/api-gateway
|
|
${{ env.REGISTRY }}/${{ env.REPO_OWNER }}/service-adapters
|
|
${{ env.REGISTRY }}/${{ env.REPO_OWNER }}/api-docs
|
|
${{ env.REGISTRY }}/${{ env.REPO_OWNER }}/frontend
|
|
tags: |
|
|
type=ref,event=branch
|
|
type=ref,event=pr
|
|
type=semver,pattern={{version}}
|
|
type=semver,pattern={{major}}.{{minor}}
|
|
type=semver,pattern={{major}}
|
|
type=sha,prefix={{branch}}-
|
|
type=raw,value=latest,enable={{is_default_branch}}
|
|
|
|
# API Gateway build and push
|
|
build-push-api-gateway:
|
|
runs-on: self-hosted
|
|
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
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: ./services/api-gateway
|
|
platforms: linux/amd64,linux/arm64
|
|
push: true
|
|
tags: ${{ env.REGISTRY }}/${{ env.REPO_OWNER }}/api-gateway:${{ needs.setup.outputs.version }}
|
|
labels: ${{ needs.setup.outputs.labels }}
|
|
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
|
|
|
|
# Service Adapters build and push
|
|
build-push-service-adapters:
|
|
runs-on: self-hosted
|
|
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
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: ./services/service-adapters
|
|
platforms: linux/amd64,linux/arm64
|
|
push: true
|
|
tags: ${{ env.REGISTRY }}/${{ env.REPO_OWNER }}/service-adapters:${{ needs.setup.outputs.version }}
|
|
labels: ${{ needs.setup.outputs.labels }}
|
|
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
|
|
|
|
# API Docs build and push
|
|
build-push-api-docs:
|
|
runs-on: self-hosted
|
|
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
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: ./services/api-docs
|
|
platforms: linux/amd64,linux/arm64
|
|
push: true
|
|
tags: ${{ env.REGISTRY }}/${{ env.REPO_OWNER }}/api-docs:${{ needs.setup.outputs.version }}
|
|
labels: ${{ needs.setup.outputs.labels }}
|
|
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
|
|
|
|
# Frontend build and push
|
|
build-push-frontend:
|
|
runs-on: self-hosted
|
|
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
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: ./frontend
|
|
platforms: linux/amd64,linux/arm64
|
|
push: true
|
|
tags: ${{ env.REGISTRY }}/${{ env.REPO_OWNER }}/frontend:${{ needs.setup.outputs.version }}
|
|
labels: ${{ needs.setup.outputs.labels }}
|
|
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
|