diff --git a/.github/workflows/main-release.yaml b/.github/workflows/main-release.yaml index 072ad17..4154ad6 100644 --- a/.github/workflows/main-release.yaml +++ b/.github/workflows/main-release.yaml @@ -12,6 +12,12 @@ jobs: - name: Checkout code uses: actions/checkout@v3 + - name: Set up QEMU and Docker Buildx + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - name: Log in to GitHub Container Registry (GHCR) uses: docker/login-action@v2 with: @@ -21,7 +27,7 @@ jobs: - name: Build and Push Docker Images run: | - make push_images + make build_and_push_images env: REGISTRY: "ghcr.io" ORG: ${{ github.repository_owner }} diff --git a/.github/workflows/tag-release.yaml b/.github/workflows/tag-release.yaml index 376bc59..5939b0a 100644 --- a/.github/workflows/tag-release.yaml +++ b/.github/workflows/tag-release.yaml @@ -12,6 +12,12 @@ jobs: - name: Checkout code uses: actions/checkout@v3 + - name: Set up QEMU and Docker Buildx + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - name: Log in to GitHub Container Registry (GHCR) uses: docker/login-action@v2 with: @@ -21,7 +27,7 @@ jobs: - name: Build and Push Docker Images run: | - TAG=${GITHUB_REF#refs/tags/} make push_images + TAG=${GITHUB_REF#refs/tags/} make build_and_push_images env: REGISTRY: ghcr.io ORG: ${{ github.repository_owner }} diff --git a/Makefile b/Makefile index 3847cc1..9483d10 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,7 @@ TAG := $(or $(TAG),main) REGISTRY := $(or $(REGISTRY),index.docker.io) +PLATFORMS := linux/amd64,linux/arm64 +BUILDX_FLAGS := --platform $(PLATFORMS) --push define get_full_tag $(if $(REGISTRY),$(REGISTRY)/)$(if $(ORG),$(ORG)/)$(if $(REPO),$(REPO)/)$(1):$(TAG) @@ -19,16 +21,17 @@ build_images: fi \ done -push_images: build_images +build_and_push_images: @if [ -z "$(REGISTRY)" ] || [ -z "$(ORG)" ]; then \ echo "Error: REGISTRY and ORG must be set to push images."; \ exit 1; \ fi + docker buildx create --use @for dir in ./services/backend/* ./services/frontend/*; do \ if [ -d "$$dir" ] && [ -f "$$dir/Dockerfile" ]; then \ SERVICE=$$(basename $$dir); \ FULL_TAG=$(call get_full_tag,$$SERVICE); \ echo "Pushing Docker image $$FULL_TAG"; \ - docker push $$FULL_TAG; \ + docker buildx build $(BUILDX_FLAGS) -t $$FULL_TAG $$dir; \ fi \ done \ No newline at end of file