Skip to content

Commit 62403e0

Browse files
committed
Rework docker builds to better match fornax's workflow
1 parent a054da9 commit 62403e0

File tree

3 files changed

+33
-4
lines changed

3 files changed

+33
-4
lines changed

Makefile

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ LOCAL_OS=$(shell go env GOOS)-$(shell go env GOARCH)
44
BUILD_DIR=build
55
CLI_DIR=${BUILD_DIR}/${VERSION}/cli
66
DAEMON_DIR=${BUILD_DIR}/${VERSION}/daemon
7+
DOCKER_DIR=${BUILD_DIR}/${VERSION}/docker
78

89
CLI_TARGET_OOS:=linux darwin
910
ARCHS:=arm64 amd64
@@ -25,7 +26,7 @@ endef
2526
all: ${BUILD_DIR}/rocketpool-cli ${BUILD_DIR}/rocketpool-daemon lint
2627

2728
.PHONY: release
28-
release: clean docker ${CLI_TARGET_STRINGS} ${DAEMON_TARGET_STRINGS} ${BUILD_DIR}/rocketpool-cli ${BUILD_DIR}/rocketpool-daemon
29+
release: clean ${CLI_TARGET_STRINGS} ${DAEMON_TARGET_STRINGS} ${BUILD_DIR}/rocketpool-cli ${BUILD_DIR}/rocketpool-daemon
2930

3031
# Target for build/rocketpool-cli which is a symlink to an os-specific build
3132
${BUILD_DIR}/rocketpool-cli: ${CLI_DIR}/rocketpool-cli-${LOCAL_OS}
@@ -73,18 +74,40 @@ ${CLI_DIR}:
7374
mkdir -p ${CLI_DIR}
7475
${DAEMON_DIR}:
7576
mkdir -p ${DAEMON_DIR}
77+
${DOCKER_DIR}:
78+
mkdir -p ${DOCKER_DIR}
7679

7780
$(foreach oos,$(CLI_TARGET_OOS),$(foreach arch,$(ARCHS),$(eval $(call rocketpool-cli-template,$(oos),$(arch)))))
7881

7982

8083
# Docker containers
8184
.PHONY: docker
82-
docker:
85+
docker: ${DOCKER_DIR}
86+
VERSION=${VERSION} docker bake -f docker/daemon-bake.hcl daemon
87+
88+
.PHONY: docker-load
89+
docker-load: docker
90+
docker import - smartnode:${VERSION}-amd64 < ${DOCKER_DIR}/smartnode:${VERSION}-amd64.tar
91+
docker import - smartnode:${VERSION}-arm64 < ${DOCKER_DIR}/smartnode:${VERSION}-arm64.tar
92+
93+
.PHONY: docker-push
94+
docker-push: docker-load
95+
echo
96+
echo -n "Publishing smartnode:${VERSION} containers. Continue? [yN]: " && read ans && if [ $${ans:-'N'} != 'y' ]; then exit 1; fi
97+
docker push rocketpool/smartnode:${VERSION}-amd64
98+
docker push rocketpool/smartnode:${VERSION}-arm64
99+
echo "Done!"
100+
101+
.PHONY: docker-latest
102+
docker-latest: docker-push
103+
echo
104+
echo -n "Publishing smartnode:${VERSION} as latest. Continue? [yN]: " && read ans && if [ $${ans:-'N'} != 'y' ]; then exit 1; fi
83105
rm -rf ~/.docker/manifests/docker.io_rocketpool_smartnode-latest
84106
rm -rf ~/.docker/manifests/docker.io_rocketpool_smartnode-${VERSION}
85-
VERSION=${VERSION} docker bake -f docker/daemon-bake.hcl daemon
86107
docker manifest create rocketpool/smartnode:${VERSION} --amend rocketpool/smartnode:${VERSION}-amd64 --amend rocketpool/smartnode:${VERSION}-arm64
87108
docker manifest create rocketpool/smartnode:latest --amend rocketpool/smartnode:${VERSION}-amd64 --amend rocketpool/smartnode:${VERSION}-arm64
109+
docker manifest push --purge rocketpool/smartnode:${VERSION}
110+
docker manifest push --purge rocketpool/smartnode:latest
88111

89112
define lint-template
90113
.PHONY: lint-$1

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,13 @@ A [Makefile](./Makefile) is included for building, testing, and linting.
3434
* It will tag docker images as latest as well as the version in `shared/version.txt`
3535
* It will put cli and native mode binaries in build/\<version\>
3636
* `make build/rocketpool-cli` builds just the cli
37+
* The cli is always built natively.
3738
* `make build/rocketpool-daemon` builds just the daemon
38-
* `make docker` builds the rocketpool/smartnode container and tags it with latest as well as the version from `shared/version.txt`
39+
* The daemon is built in docker, unless you run `make NO_DOCKER=true \<cmd\>`
40+
* `make docker` builds the rocketpool/smartnode containers for all supported architectures and saves them in build/\<version\>/docker
41+
* `make docker-load` builds and loads the smartnode containers.
42+
* `make docker-publish` builds, loads, and pushes the smartnode containers.
43+
* `make docker-latest` builds, loads, pushes, tags as latest, and creates a multi-arch manifest, which is also pushed.
3944
* `make lint` runs the linter.
4045
* `make test` runs all unit tests.
4146
* `make clean` deletes any binaries. It does not clear your go caches. It does not clean up old docker images.

docker/daemon-bake.hcl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,5 @@ target "daemon" {
3131
}
3232
target = "daemon"
3333
platform = "linux/${arch}"
34+
output = [{ "type": "tar", "dest": "build/${VERSION}/docker/smartnode:${VERSION}-${arch}.tar" }]
3435
}

0 commit comments

Comments
 (0)