From 76be9e6efdf366a467f04a49d8a259f75936cfff Mon Sep 17 00:00:00 2001 From: Stefan Benten Date: Sun, 20 Feb 2022 22:56:33 +0100 Subject: [PATCH] cmd/multinode,Makefile: build docker image for multinode dashboard Closes #4547 We do not build an docker image for the multinode dashboard, which makes monitoring for docker-focused environments harder. This adds the basic image and ties it into CI/CD. Change-Id: I14c01a7f1f0019f6f5c1b8fd75dc424fc362b18d --- Makefile | 24 +++++++++++++++++++----- cmd/multinode/Dockerfile | 18 ++++++++++++++++++ cmd/multinode/entrypoint | 9 +++++++++ 3 files changed, 46 insertions(+), 5 deletions(-) create mode 100644 cmd/multinode/Dockerfile create mode 100644 cmd/multinode/entrypoint diff --git a/Makefile b/Makefile index f930bd123..77c422985 100644 --- a/Makefile +++ b/Makefile @@ -198,9 +198,20 @@ satellite-wasm: scripts/build-wasm.sh ;\ .PHONY: images -images: satellite-image storagenode-image versioncontrol-image ## Build satellite, storagenode, and versioncontrol Docker images +images: multinode-image satellite-image storagenode-image versioncontrol-image ## Build multinode, satellite, storagenode, and versioncontrol Docker images echo Built version: ${TAG} +.PHONY: multinode-image +satellite-image: multinode_linux_arm multinode_linux_arm64 multinode_linux_amd64 ## Build multinode Docker image + ${DOCKER_BUILD} --pull=true -t storjlabs/multinode:${TAG}${CUSTOMTAG}-amd64 \ + -f cmd/multinode/Dockerfile . + ${DOCKER_BUILD} --pull=true -t storjlabs/multinode:${TAG}${CUSTOMTAG}-arm32v6 \ + --build-arg=GOARCH=arm --build-arg=DOCKER_ARCH=arm32v6 \ + -f cmd/multinode/Dockerfile . + ${DOCKER_BUILD} --pull=true -t storjlabs/multinode:${TAG}${CUSTOMTAG}-arm64v8 \ + --build-arg=GOARCH=arm64 --build-arg=DOCKER_ARCH=arm64v8 \ + -f cmd/multinode/Dockerfile . + .PHONY: satellite-image satellite-image: satellite_linux_arm satellite_linux_arm64 satellite_linux_amd64 ## Build satellite Docker image ${DOCKER_BUILD} --pull=true -t storjlabs/satellite:${TAG}${CUSTOMTAG}-amd64 \ @@ -291,6 +302,9 @@ identity_%: .PHONY: inspector_% inspector_%: $(MAKE) binary-check COMPONENT=inspector GOARCH=$(word 3, $(subst _, ,$@)) GOOS=$(word 2, $(subst _, ,$@)) +.PHONE: multinode_% +multinode_%: multinode-console + $(MAKE) binary-check COMPONENT=multinode GOARCH=$(word 3, $(subst _, ,$@)) GOOS=$(word 2, $(subst _, ,$@)) .PHONY: satellite_% satellite_%: satellite-admin-ui $(MAKE) binary-check COMPONENT=satellite GOARCH=$(word 3, $(subst _, ,$@)) GOOS=$(word 2, $(subst _, ,$@)) @@ -311,11 +325,11 @@ multinode_%: multinode-console $(MAKE) binary-check COMPONENT=multinode GOARCH=$(word 3, $(subst _, ,$@)) GOOS=$(word 2, $(subst _, ,$@)) -COMPONENTLIST := certificates identity inspector satellite storagenode storagenode-updater uplink versioncontrol multinode +COMPONENTLIST := certificates identity inspector multinode satellite storagenode storagenode-updater uplink versioncontrol OSARCHLIST := linux_amd64 linux_arm linux_arm64 windows_amd64 freebsd_amd64 BINARIES := $(foreach C,$(COMPONENTLIST),$(foreach O,$(OSARCHLIST),$C_$O)) .PHONY: binaries -binaries: ${BINARIES} ## Build certificates, identity, inspector, satellite, storagenode, uplink, versioncontrol and multinode binaries (jenkins) +binaries: ${BINARIES} ## Build certificates, identity, inspector, multinode, satellite, storagenode, uplink, versioncontrol and multinode binaries (jenkins) .PHONY: sign-windows-installer sign-windows-installer: @@ -326,8 +340,7 @@ sign-windows-installer: .PHONY: push-images push-images: ## Push Docker images to Docker Hub (jenkins) # images have to be pushed before a manifest can be created - # satellite - for c in satellite storagenode uplink versioncontrol ; do \ + for c in multinode satellite storagenode uplink versioncontrol ; do \ docker push storjlabs/$$c:${TAG}${CUSTOMTAG}-amd64 \ && docker push storjlabs/$$c:${TAG}${CUSTOMTAG}-arm32v6 \ && docker push storjlabs/$$c:${TAG}${CUSTOMTAG}-arm64v8 \ @@ -373,6 +386,7 @@ binaries-clean: ## Remove all local release binaries (jenkins) .PHONY: clean-images clean-images: + -docker rmi storjlabs/multinode:${TAG}${CUSTOMTAG} -docker rmi storjlabs/satellite:${TAG}${CUSTOMTAG} -docker rmi storjlabs/storagenode:${TAG}${CUSTOMTAG} -docker rmi storjlabs/versioncontrol:${TAG}${CUSTOMTAG} diff --git a/cmd/multinode/Dockerfile b/cmd/multinode/Dockerfile new file mode 100644 index 000000000..1ba9d1132 --- /dev/null +++ b/cmd/multinode/Dockerfile @@ -0,0 +1,18 @@ +ARG DOCKER_ARCH + +# Fetch ca-certificates file for arch independent builds below +FROM alpine as ca-cert +RUN apk -U add ca-certificates + +FROM ${DOCKER_ARCH:-amd64}/alpine +ARG TAG +ARG GOARCH +ENV GOARCH ${GOARCH} + +ENV CONF_PATH=/root/.local/storj/multinode +WORKDIR /app +VOLUME /root/.local/storj/multinode +COPY --from=ca-cert /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt +COPY release/${TAG}/multinode_linux_${GOARCH:-amd64} /app/multinode +COPY cmd/multinode/entrypoint /entrypoint +ENTRYPOINT ["/entrypoint"] \ No newline at end of file diff --git a/cmd/multinode/entrypoint b/cmd/multinode/entrypoint new file mode 100644 index 000000000..1fcb472c2 --- /dev/null +++ b/cmd/multinode/entrypoint @@ -0,0 +1,9 @@ +#!/bin/sh +set -euo pipefail + +if [[ ! -f "${CONF_PATH}/config.yaml" ]]; then + ./multinode setup +fi + +RUN_PARAMS="${RUN_PARAMS:-} --config ${CONF_PATH} --console.address=:15002" +exec ./multinode run $RUN_PARAMS "$@" \ No newline at end of file