Skip to content

Commit f07dd07

Browse files
authored
fix: use multi-arch docker build (#282)
* fix: use multi-arch docker build * Added error handling for missing REPO_OWNER variable in docker-build-publish target.
1 parent 4c8c600 commit f07dd07

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

.github/workflows/release.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,8 @@ jobs:
3939
- name: Build & Push Docker image
4040
run: |
4141
VERSION=${GITHUB_REF##*/} # extract v0.1.0
42-
echo "Building Docker image with version $VERSION"
43-
make docker-prod VERSION=$VERSION
44-
docker tag leafwiki:$VERSION ghcr.io/${{ github.repository_owner }}/leafwiki:$VERSION
45-
docker tag leafwiki:$VERSION ghcr.io/${{ github.repository_owner }}/leafwiki:latest
46-
docker push ghcr.io/${{ github.repository_owner }}/leafwiki:$VERSION
47-
docker push ghcr.io/${{ github.repository_owner }}/leafwiki:latest
42+
echo "Building Multi-Arch Docker image with version $VERSION"
43+
make docker-build-publish VERSION=$VERSION REPO_OWNER=${{ github.repository_owner }}
4844
4945
- name: Get latest tag before current one
5046
id: latest

Makefile

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,17 @@ $(PLATFORMS):
5252
echo "📦 Compressed: zip and tar.gz"
5353

5454
# Final production Docker image
55-
docker-prod:
56-
docker build -f Dockerfile -t leafwiki:$(VERSION) --target final .
57-
docker tag leafwiki:$(VERSION) leafwiki:latest
55+
docker-build-publish:
56+
ifndef REPO_OWNER
57+
$(error REPO_OWNER is not set. Usage: make docker-build-publish VERSION=vX.Y.Z REPO_OWNER=your_github_username)
58+
endif
59+
docker buildx build \
60+
--platform linux/amd64,linux/arm64 \
61+
--file Dockerfile \
62+
--target final \
63+
--tag ghcr.io/$(REPO_OWNER)/leafwiki:$(VERSION) \
64+
--tag ghcr.io/$(REPO_OWNER)/leafwiki:latest \
65+
--push .
5866

5967
help:
6068
@echo "Available commands:"
@@ -63,6 +71,6 @@ help:
6371
@echo " make clean – Clean all generated files"
6472
@echo " make test – Run all Go tests"
6573
@echo " make run – Run development server"
66-
@echo " make docker-prod – Build final Docker image"
74+
@echo " make docker-build-publish – Build and push multi-arch Docker image"
6775

68-
.PHONY: all build run clean test fmt lint help
76+
.PHONY: all build run clean test fmt lint help docker-build-publish

0 commit comments

Comments
 (0)