Skip to content

Use Thread and various performance improvements #4

Use Thread and various performance improvements

Use Thread and various performance improvements #4

Workflow file for this run

name: Docker Build and Push
on:
push:
branches:
- '**' # Match all branches
tags: [ "v*" ]
pull_request:
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
docker:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Extract version from Cargo.toml
id: version
run: |
VERSION=$(awk -F '"' '/^version = / {print $2}' Cargo.toml)
echo "CARGO_VERSION=${VERSION}" >> $GITHUB_ENV
echo "Version found: ${VERSION}"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# Always build to verify Dockerfile, but push only on main
- name: Build Docker image (non-main branch)
if: github.ref != 'refs/heads/main'
uses: docker/build-push-action@v5
with:
context: .
push: false
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
# Main branch handling - build and push
- name: Log in to GitHub Container Registry
if: github.ref == 'refs/heads/main'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata for GHCR
if: github.ref == 'refs/heads/main'
id: meta-ghcr
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest
type=raw,value=${{ env.CARGO_VERSION }}
- name: Build and push to GitHub Container Registry
if: github.ref == 'refs/heads/main'
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta-ghcr.outputs.tags }}
labels: ${{ steps.meta-ghcr.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64,linux/arm64
- name: Login to Docker Hub
if: github.ref == 'refs/heads/main'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push to Docker Hub
if: github.ref == 'refs/heads/main'
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: |
magicapi1/magicapi-ai-gateway:latest
magicapi1/magicapi-ai-gateway:${{ env.CARGO_VERSION }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64