Skip to content

Commit 6362ab5

Browse files
committed
fix: build multiple architectures; use toTag and fromTag
1 parent 9a74f89 commit 6362ab5

3 files changed

Lines changed: 24 additions & 8 deletions

File tree

.github/workflows/main.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,14 @@ jobs:
144144
shell: bash
145145
env:
146146
DOCKER_BUILDKIT: "1" # Enable Docker Buildkit
147+
PLATFORMS: linux/amd64,linux/arm64
147148
run: |
148149
echo "Building bundle"
149150
export IMG="${{ env.IMAGE_REPO }}:${{ env.OPERATOR_VERSION }}"
150151
export BUNDLE_IMG="${{ env.IMAGE_REPO }}-bundle:${{ env.OPERATOR_VERSION }}"
151-
make docker-build docker-push
152+
make docker-buildx
152153
make bundle
153-
make bundle-build bundle-push
154+
make bundle-buildx
154155
155156
release:
156157
needs: [prepare, buildah, operator]
@@ -168,7 +169,8 @@ jobs:
168169
uses: requarks/changelog-action@v1.8.0
169170
with:
170171
token: ${{ github.token }}
171-
fromTag: ${{ env.current }}
172+
fromTag: ${{ github.ref_name }}
173+
toTag: ${{ env.current }}
172174
# Create a new release on GitHub with the semantic version number
173175
- name: Create Release
174176
uses: ncipollo/release-action@v1.12.0

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
bin
99
testbin/*
1010
Dockerfile.cross
11+
*.Dockerfile.cross
1112

1213
# Test binary, build with `go test -c`
1314
*.test

Makefile

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,10 @@ docker-push: ## Push docker image with the manager.
134134
# To properly provided solutions that supports more than one platform you should use this option.
135135
PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x,linux/ppc64le
136136
.PHONY: docker-buildx
137-
docker-buildx: test ## Build and push docker image for the manager for cross-platform support
137+
docker-buildx: test create-buildx ## Build and push docker image for the manager for cross-platform support
138138
# copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile
139139
sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross
140-
- docker buildx create --name project-v3-builder
141-
docker buildx use project-v3-builder
142-
- docker buildx build --push --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile.cross
143-
- docker buildx rm project-v3-builder
140+
- docker buildx build --push --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile.cross .
144141
rm Dockerfile.cross
145142

146143
##@ Deployment
@@ -213,6 +210,22 @@ bundle-build: ## Build the bundle image.
213210
bundle-push: ## Push the bundle image.
214211
$(MAKE) docker-push IMG=$(BUNDLE_IMG)
215212

213+
.PHONY: bundle-buildx
214+
bundle-buildx: test create-buildx ## Build and push docker image for the manager for cross-platform support
215+
# copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile
216+
sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' bundle.Dockerfile > bundle.Dockerfile.cross
217+
- docker buildx build --push --platform=$(PLATFORMS) --tag ${BUNDLE_IMG} -f bundle.Dockerfile.cross .
218+
rm bundle.Dockerfile.cross
219+
220+
.PHONY: create-buildx
221+
create-buildx: ## Create a buildx builder
222+
- docker buildx create --name project-v3-builder
223+
docker buildx use project-v3-builder
224+
225+
.PHONY: cleanup-buildx
226+
cleanup-buildx: ## Cleanup a buildx builder
227+
- docker buildx rm project-v3-builder
228+
216229
.PHONY: opm
217230
OPM = ./bin/opm
218231
opm: ## Download opm locally if necessary.

0 commit comments

Comments
 (0)