Skip to content

Commit 8721645

Browse files
authored
fix: fix an issue that multi-arch images cannot be built from the project makefile (#6661)
Signed-off-by: kurokobo <[email protected]>
1 parent ce3a767 commit 8721645

File tree

3 files changed

+45
-10
lines changed

3 files changed

+45
-10
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# entries is a list of entries to include in
2+
# release notes and/or the migration guide
3+
entries:
4+
- description: >
5+
(helm/v1) Fix an issue that multi-arch images cannot be built from the project Makefile.
6+
7+
# kind is one of:
8+
# - addition
9+
# - change
10+
# - deprecation
11+
# - removal
12+
# - bugfix
13+
kind: "bugfix"
14+
15+
# Is this a breaking change?
16+
breaking: false
17+
18+
# NOTE: ONLY USE `pull_request_override` WHEN ADDING THIS
19+
# FILE FOR A PREVIOUSLY MERGED PULL_REQUEST!
20+
#
21+
# The generator auto-detects the PR number from the commit
22+
# message in which this file was originally added.
23+
#
24+
# What is the pull request number (without the "#")?
25+
# pull_request_override: 0
26+
27+
28+
# Migration can be defined to automatically add a section to
29+
# the migration guide. This is required for breaking changes.
30+
migration:
31+
header: To fix multi-arch build, replace docker-buildx target in project Makefile
32+
body: |
33+
In the project `Makefile`, replace existing `docker-buildx` target with following definition.
34+
35+
```make
36+
docker-buildx: ## Build and push docker image for the manager for cross-platform support
37+
- docker buildx create --name project-v3-builder
38+
docker buildx use project-v3-builder
39+
- docker buildx build --push --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile .
40+
- docker buildx rm project-v3-builder
41+
```

internal/plugins/helm/v1/scaffolds/internal/templates/makefile.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,11 @@ docker-push: ## Push docker image with the manager.
110110
# To properly provided solutions that supports more than one platform you should use this option.
111111
PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x,linux/ppc64le
112112
.PHONY: docker-buildx
113-
docker-buildx: test ## Build and push docker image for the manager for cross-platform support
114-
# copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile
115-
sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross
113+
docker-buildx: ## Build and push docker image for the manager for cross-platform support
116114
- docker buildx create --name project-v3-builder
117115
docker buildx use project-v3-builder
118-
- docker buildx build --push --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile.cross .
116+
- docker buildx build --push --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile .
119117
- docker buildx rm project-v3-builder
120-
rm Dockerfile.cross
121118
122119
##@ Deployment
123120

testdata/helm/memcached-operator/Makefile

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,11 @@ docker-push: ## Push docker image with the manager.
9595
# To properly provided solutions that supports more than one platform you should use this option.
9696
PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x,linux/ppc64le
9797
.PHONY: docker-buildx
98-
docker-buildx: test ## Build and push docker image for the manager for cross-platform support
99-
# copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile
100-
sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross
98+
docker-buildx: ## Build and push docker image for the manager for cross-platform support
10199
- docker buildx create --name project-v3-builder
102100
docker buildx use project-v3-builder
103-
- docker buildx build --push --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile.cross .
101+
- docker buildx build --push --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile .
104102
- docker buildx rm project-v3-builder
105-
rm Dockerfile.cross
106103

107104
##@ Deployment
108105

0 commit comments

Comments
 (0)