From 52a80b2c6791b9b127f7253b1326e5b82b13b979 Mon Sep 17 00:00:00 2001 From: Clement Sam Date: Thu, 24 Feb 2022 12:04:19 +0000 Subject: [PATCH] cmd/storagenode: use custom storagenode-base image Updates https://github.com/storj/storj/issues/4489 Change-Id: I3585b50df598c69e58137f61b6a272dbd077c5be --- Makefile | 4 ++-- cmd/storagenode/Dockerfile | 17 ++--------------- cmd/storagenode/docker/entrypoint | 25 ++++++++----------------- 3 files changed, 12 insertions(+), 34 deletions(-) diff --git a/Makefile b/Makefile index 76e36ac23..6d65f5da9 100644 --- a/Makefile +++ b/Makefile @@ -220,10 +220,10 @@ storagenode-image: ## Build storagenode Docker image ${DOCKER_BUILD} --pull=true -t storjlabs/storagenode:${TAG}${CUSTOMTAG}-amd64 \ -f cmd/storagenode/Dockerfile . ${DOCKER_BUILD} --pull=true -t storjlabs/storagenode:${TAG}${CUSTOMTAG}-arm32v6 \ - --build-arg=GOARCH=arm --build-arg=DOCKER_ARCH=arm32v6 --build-arg=APK_ARCH=armhf \ + --build-arg=GOARCH=arm --build-arg=DOCKER_ARCH=arm32v6 --build-arg=DOCKER_PLATFORM=linux/arm/v6 \ -f cmd/storagenode/Dockerfile . ${DOCKER_BUILD} --pull=true -t storjlabs/storagenode:${TAG}${CUSTOMTAG}-arm64v8 \ - --build-arg=GOARCH=arm64 --build-arg=DOCKER_ARCH=arm64v8 --build-arg=APK_ARCH=aarch64 \ + --build-arg=GOARCH=arm64 --build-arg=DOCKER_ARCH=arm64v8 --build-arg=DOCKER_PLATFORM=linux/arm64 \ -f cmd/storagenode/Dockerfile . .PHONY: storagenode-base-image diff --git a/cmd/storagenode/Dockerfile b/cmd/storagenode/Dockerfile index bc1a4cbf6..ed4c898b4 100644 --- a/cmd/storagenode/Dockerfile +++ b/cmd/storagenode/Dockerfile @@ -1,18 +1,7 @@ ARG DOCKER_ARCH +ARG DOCKER_PLATFORM -FROM ${DOCKER_ARCH:-amd64}/alpine as alpine-arch - -# Fetch ca-certificates file and supervisor apk pkg with dependecies for arch independent builds below -FROM alpine as alpine-generic -ARG APK_ARCH=x86_64 -RUN apk -U add ca-certificates && cat /etc/apk/arch -RUN echo $APK_ARCH > /etc/apk/arch && cat /etc/apk/arch -RUN mkdir /tmp/apk-supervisor -RUN rm -rf /etc/apk/keys/* -COPY --from=alpine-arch /etc/apk/keys /etc/apk/keys -RUN apk fetch --no-cache -R -o /tmp/apk-supervisor supervisor - -FROM alpine-arch +FROM --platform=${DOCKER_PLATFORM:-linux/amd64} storjlabs/storagenode-base:155c07083-${DOCKER_ARCH:-amd64} ARG TAG ARG GOARCH ARG VERSION_SERVER_URL @@ -20,8 +9,6 @@ ENV GOARCH ${GOARCH:-amd64} ENV VERSION_SERVER_URL ${VERSION_SERVER_URL:-https://version.storj.io} EXPOSE 28967 EXPOSE 14002 -COPY --from=alpine-generic /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt -COPY --from=alpine-generic /tmp/apk-supervisor/* /var/lib/apk-supervisor/ COPY cmd/storagenode/docker/ / WORKDIR /app ENTRYPOINT ["/entrypoint"] diff --git a/cmd/storagenode/docker/entrypoint b/cmd/storagenode/docker/entrypoint index b3c36e36e..7fada75a7 100755 --- a/cmd/storagenode/docker/entrypoint +++ b/cmd/storagenode/docker/entrypoint @@ -78,24 +78,15 @@ fi if [ "${SETUP:-}" = "true" ]; then echo "Running ./storagenode setup $SNO_RUN_PARAMS" - exec ./storagenode setup "$SNO_RUN_PARAMS" "${*}" + exec ./storagenode setup ${SNO_RUN_PARAMS} ${*} else - # install supervisor - # TODO: use docker buildx instead of installing packages at runtime? - if ! apk list supervisor 2>/dev/null | grep "supervisor"; then - echo "installing supervisor" - mkdir -p /var/log/supervisor - # perform installation during runtime to not use dockerfile RUN directive to support arch-independent build process - apk add --no-cache --repositories-file=/dev/null /var/lib/apk-supervisor/*.apk + sed -i \ + "s#^command=/app/storagenode-updater\$#command=/app/storagenode-updater run --binary-location /app/storagenode ${RUN_PARAMS} #" \ + /etc/supervisor/supervisord.conf - sed -i \ - "s#^command=/app/storagenode-updater\$#command=/app/storagenode-updater run --binary-location /app/storagenode ${RUN_PARAMS} #" \ - /etc/supervisord.conf + sed -i \ + "s#^command=/app/storagenode\$#command=/app/storagenode run ${SNO_RUN_PARAMS} ${*}#" \ + /etc/supervisor/supervisord.conf - sed -i \ - "s#^command=/app/storagenode\$#command=/app/storagenode run ${SNO_RUN_PARAMS} ${*}#" \ - /etc/supervisord.conf - fi - - exec /usr/bin/supervisord -c /etc/supervisord.conf + exec /usr/bin/supervisord -c /etc/supervisor/supervisord.conf fi