From 15a14288287fba0a1da23e48f5a2242d28d32652 Mon Sep 17 00:00:00 2001 From: Clement Sam Date: Thu, 24 Feb 2022 11:58:15 +0000 Subject: [PATCH] {cmd/storagenode,Makefile}: add storagenode base image Dockerfile Having the storagenode and storagenode-updater processes in one container requires a process manager to properly handle the individual processes. Using a process manager like supervisord requires that you package supervisord and it configuration in the image, along with the storagenode and storagenode-updater binaries. Installing supervisord requires that we run apk to install it and its dependencies at build time which makes it difficult to build multi-platoform images; executing apk forces a requirement of the build system to run foreign architechtures. This change adds a dockerfile which will be used to build the base image for the storagenode and has supervisord packaged. The base image will be built manually using docker buildx, with QEMU binfmt support. Updates https://github.com/storj/storj/issues/4489 Change-Id: I33f8f01398a7207bca08d8a4a43f4ed56b6a2473 --- Makefile | 24 ++++++++++++++++++++++-- cmd/storagenode/Dockerfile.base | 5 +++++ 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 cmd/storagenode/Dockerfile.base diff --git a/Makefile b/Makefile index a8e4acb69..99b826d25 100644 --- a/Makefile +++ b/Makefile @@ -5,12 +5,13 @@ GOPATH ?= $(shell go env GOPATH) NODE_VERSION ?= 16.11.1 COMPOSE_PROJECT_NAME := ${TAG}-$(shell git rev-parse --abbrev-ref HEAD) BRANCH_NAME ?= $(shell git rev-parse --abbrev-ref HEAD | sed "s!/!-!g") +GIT_TAG := $(shell git rev-parse --short HEAD) ifeq (${BRANCH_NAME},main) -TAG := $(shell git rev-parse --short HEAD)-go${GO_VERSION} +TAG := ${GIT_TAG}-go${GO_VERSION} TRACKED_BRANCH := true LATEST_TAG := latest else -TAG := $(shell git rev-parse --short HEAD)-${BRANCH_NAME}-go${GO_VERSION} +TAG := ${GIT_TAG}-${BRANCH_NAME}-go${GO_VERSION} ifneq (,$(findstring release-,$(BRANCH_NAME))) TRACKED_BRANCH := true LATEST_TAG := ${BRANCH_NAME}-latest @@ -26,6 +27,8 @@ endif DOCKER_BUILD := docker build \ --build-arg TAG=${TAG} +DOCKER_BUILDX := docker buildx build + .DEFAULT_GOAL := help .PHONY: help help: @@ -234,6 +237,23 @@ storagenode-image: ## Build storagenode Docker image --build-arg=GOARCH=arm64 --build-arg=DOCKER_ARCH=arm64v8 --build-arg=APK_ARCH=aarch64 \ -f cmd/storagenode/Dockerfile . +.PHONY: storagenode-base-image +storagenode-base-image: ## Build storagenode Docker base image. Requires buildx. This image is expected to be built manually using buildx and QEMU. + ${DOCKER_BUILDX} --pull=true -t storjlabs/storagenode-base:${GIT_TAG}${CUSTOMTAG}-amd64 \ + -f cmd/storagenode/Dockerfile.base . + ${DOCKER_BUILDX} --pull=true -t storjlabs/storagenode-base:${GIT_TAG}${CUSTOMTAG}-arm32v6 \ + --build-arg=GOARCH=arm --build-arg=DOCKER_ARCH=arm32v6 \ + -f cmd/storagenode/Dockerfile.base . + ${DOCKER_BUILDX} --pull=true -t storjlabs/storagenode-base:${GIT_TAG}${CUSTOMTAG}-arm64v8 \ + --build-arg=GOARCH=arm64 --build-arg=DOCKER_ARCH=arm64v8 \ + -f cmd/storagenode/Dockerfile.base . + +.PHONY: push-storagenode-base-image +push-storagenode-base-image: ## Push the storagenode base image to dockerhub + docker push storjlabs/storagenode-base:${GIT_TAG}${CUSTOMTAG}-amd64 + docker push storjlabs/storagenode-base:${GIT_TAG}${CUSTOMTAG}-arm32v6 + docker push storjlabs/storagenode-base:${GIT_TAG}${CUSTOMTAG}-arm64v8 + .PHONY: versioncontrol-image versioncontrol-image: versioncontrol_linux_arm versioncontrol_linux_arm64 versioncontrol_linux_amd64 ## Build versioncontrol Docker image ${DOCKER_BUILD} --pull=true -t storjlabs/versioncontrol:${TAG}${CUSTOMTAG}-amd64 \ diff --git a/cmd/storagenode/Dockerfile.base b/cmd/storagenode/Dockerfile.base new file mode 100644 index 000000000..dcbbe8bef --- /dev/null +++ b/cmd/storagenode/Dockerfile.base @@ -0,0 +1,5 @@ +ARG DOCKER_ARCH + +FROM ${DOCKER_ARCH:-amd64}/alpine:3.15 +RUN apk --no-cache -U add ca-certificates supervisor +RUN mkdir -p /var/log/supervisor \ No newline at end of file