Skip to content

Commit

Permalink
Merge pull request #13 from cloudnautique/main
Browse files Browse the repository at this point in the history
ci - use buildx to do multiplatform builds
  • Loading branch information
cloudnautique authored Feb 8, 2024
2 parents d89fd14 + 5ece945 commit b68cffe
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/main-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 }}
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/tag-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 }}
Expand Down
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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

0 comments on commit b68cffe

Please sign in to comment.