Skip to content

Commit 1bc947c

Browse files
authored
Merge pull request #837 from jshufro/jms/fixarm
Use multiarch builds instead of manifests
2 parents 500d0ff + aea0a29 commit 1bc947c

3 files changed

Lines changed: 26 additions & 31 deletions

File tree

.github/workflows/build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,4 @@ jobs:
3434
push: false
3535
files: docker/daemon-bake.hcl
3636
targets: smartnode
37+
set: smartnode.platform=linux/amd64

Makefile

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
VERSION=v$(shell cat shared/version.txt)
2-
LOCAL_OS=$(shell go env GOOS)-$(shell go env GOARCH)
2+
LOCAL_OS=$(shell go env GOOS)
3+
LOCAL_ARCH=$(shell go env GOARCH)
4+
# Needed for binary artifacts of format `rocketpool-cli-linux-amd64`
5+
LOCAL_TARGET=${LOCAL_OS}-${LOCAL_ARCH}
6+
# Needed for docker --platform arguments of format `linux/amd64`
7+
LOCAL_PLATFORM=${LOCAL_OS}/${LOCAL_ARCH}
38

49
BUILD_DIR=build
510
BIN_DIR=${BUILD_DIR}/${VERSION}/bin
@@ -35,17 +40,17 @@ all: ${BUILD_DIR}/rocketpool-cli ${BUILD_DIR}/rocketpool-daemon ${BUILD_DIR}/tre
3540
release: ${CLI_TARGET_STRINGS} ${DAEMON_TARGET_STRINGS} ${TREEGEN_TARGET_STRINGS} ${BUILD_DIR}/rocketpool-cli ${BUILD_DIR}/rocketpool-daemon ${BUILD_DIR}/treegen
3641

3742
# Target for build/rocketpool-cli which is a symlink to an os-specific build
38-
${BUILD_DIR}/rocketpool-cli: ${BIN_DIR}/rocketpool-cli-${LOCAL_OS}
39-
ln -sf $(shell pwd)/${BIN_DIR}/rocketpool-cli-${LOCAL_OS} ${BUILD_DIR}/rocketpool-cli
43+
${BUILD_DIR}/rocketpool-cli: ${BIN_DIR}/rocketpool-cli-${LOCAL_TARGET}
44+
ln -sf $(shell pwd)/${BIN_DIR}/rocketpool-cli-${LOCAL_TARGET} ${BUILD_DIR}/rocketpool-cli
4045

4146

4247
# Target for build/rocketpool-daemon which is a symlink to an os-specific build
43-
${BUILD_DIR}/rocketpool-daemon: ${BIN_DIR}/rocketpool-daemon-${LOCAL_OS}
44-
ln -sf $(shell pwd)/${BIN_DIR}/rocketpool-daemon-${LOCAL_OS} ${BUILD_DIR}/rocketpool-daemon
48+
${BUILD_DIR}/rocketpool-daemon: ${BIN_DIR}/rocketpool-daemon-${LOCAL_TARGET}
49+
ln -sf $(shell pwd)/${BIN_DIR}/rocketpool-daemon-${LOCAL_TARGET} ${BUILD_DIR}/rocketpool-daemon
4550

4651
# Target for build/treegen which is a symlink to a version-specific build
47-
${BUILD_DIR}/treegen: ${BIN_DIR}/treegen-${LOCAL_OS}
48-
ln -sf $(shell pwd)/${BIN_DIR}/treegen-${LOCAL_OS} ${BUILD_DIR}/treegen
52+
${BUILD_DIR}/treegen: ${BIN_DIR}/treegen-${LOCAL_TARGET}
53+
ln -sf $(shell pwd)/${BIN_DIR}/treegen-${LOCAL_TARGET} ${BUILD_DIR}/treegen
4954

5055
# docker-builder container
5156
.PHONY: docker-builder
@@ -111,32 +116,27 @@ endif
111116

112117
# Multiarch builder
113118
${BUILD_DIR}/docker-buildx-builder: ${BUILD_DIR}
114-
docker buildx create --name smartnode-builder --driver docker-container --platform linux/amd64,linux/arm64
119+
docker buildx create --name smartnode-builder --driver docker-container --platform linux/amd64,linux/arm64 || true
115120
touch ${BUILD_DIR}/docker-buildx-builder
116121

117122
# Docker containers
118123
.PHONY: docker
119124
docker: ${BUILD_DIR}/docker-buildx-builder
120-
VERSION=${VERSION} docker bake --builder smartnode-builder -f docker/daemon-bake.hcl smartnode
125+
# override the platform so we can load the resulting image into docker
126+
VERSION=${VERSION} docker bake --builder smartnode-builder -f docker/daemon-bake.hcl smartnode --set "smartnode.platform=${LOCAL_PLATFORM}"
121127

122128
.PHONY: docker-push
123-
docker-push: docker
124-
echo
125-
echo -n "Publishing smartnode:${VERSION} containers. Continue? [yN]: " && read ans && if [ $${ans:-'N'} != 'y' ]; then exit 1; fi
126-
rm -rf ~/.docker/manifests/docker.io_rocketpool_smartnode-${VERSION}
127-
docker push rocketpool/smartnode:${VERSION}-amd64
128-
docker push rocketpool/smartnode:${VERSION}-arm64
129-
docker manifest create rocketpool/smartnode:${VERSION} --amend rocketpool/smartnode:${VERSION}-amd64 --amend rocketpool/smartnode:${VERSION}-arm64
130-
docker manifest push --purge rocketpool/smartnode:${VERSION}
129+
docker-push: ${BUILD_DIR}/docker-buildx-builder
130+
echo -n "Building ${VERSION} and publishing containers. Continue? [yN]: " && read ans && if [ $${ans:-'N'} != 'y' ]; then exit 1; fi
131+
# override the output type to push to dockerhub
132+
VERSION=${VERSION} docker bake --builder smartnode-builder -f docker/daemon-bake.hcl smartnode --set "smartnode.output=type=registry"
131133
echo "Done!"
132134

133135
.PHONY: docker-latest
134-
docker-latest: docker-push
135-
echo
136-
echo -n "Publishing smartnode:${VERSION} as latest. Continue? [yN]: " && read ans && if [ $${ans:-'N'} != 'y' ]; then exit 1; fi
137-
rm -rf ~/.docker/manifests/docker.io_rocketpool_smartnode-latest
138-
docker manifest create rocketpool/smartnode:latest --amend rocketpool/smartnode:${VERSION}-amd64 --amend rocketpool/smartnode:${VERSION}-arm64
139-
docker manifest push --purge rocketpool/smartnode:latest
136+
docker-latest: ${BUILD_DIR}/docker-buildx-builder
137+
echo -n "Building ${VERSION}, tagging as latest, and publishing. Continue? [yN]: " && read ans && if [ $${ans:-'N'} != 'y' ]; then exit 1; fi
138+
# override the output type to push to dockerhub, and the tags array to tag latest
139+
VERSION=${VERSION} docker bake --builder smartnode-builder -f docker/daemon-bake.hcl smartnode --set "smartnode.output=type=registry" --set "smartnode.tags=rocketpool/smartnode:latest"
140140

141141
.PHONY: docker-prune
142142
docker-prune:

docker/daemon-bake.hcl

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,22 @@ target "builder" {
1010
dockerfile = "docker/rocketpool-dockerfile"
1111
tags = [
1212
"rocketpool/smartnode-builder:${VERSION}",
13-
"rocketpool/smartnode-builder:local"
1413
]
1514
target = "smartnode_dependencies"
1615
platforms = [ "linux/amd64" ]
1716
output = [{ "type": "docker" }]
1817
}
1918

2019
target "smartnode" {
21-
name = "smartnode-${arch}"
2220
dockerfile = "docker/rocketpool-dockerfile"
2321
args = {
2422
BUILDPLATFORM = "linux/amd64"
2523
VERSION = "${VERSION}"
2624
}
2725
tags = [
28-
"rocketpool/smartnode:${VERSION}-${arch}",
29-
"localhost/rocketpool/smartnode:${VERSION}-${arch}"
26+
"rocketpool/smartnode:${VERSION}",
3027
]
31-
matrix = {
32-
arch = [ "amd64", "arm64" ]
33-
}
3428
target = "smartnode"
35-
platforms = ["linux/${arch}"]
29+
platforms = ["linux/amd64", "linux/arm64"]
3630
output = [{ "type": "docker" }]
3731
}

0 commit comments

Comments
 (0)