{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
This commit is contained in:
Clement Sam 2022-02-24 11:58:15 +00:00
parent 53e851bfb2
commit 15a1428828
2 changed files with 27 additions and 2 deletions

View File

@ -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 \

View File

@ -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