cmd/storagenode: use custom storagenode-base image

Updates https://github.com/storj/storj/issues/4489

Change-Id: I3585b50df598c69e58137f61b6a272dbd077c5be
This commit is contained in:
Clement Sam 2022-02-24 12:04:19 +00:00
parent 155c070837
commit 52a80b2c67
3 changed files with 12 additions and 34 deletions

View File

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

View File

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

View File

@ -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/supervisord.conf
/etc/supervisor/supervisord.conf
sed -i \
"s#^command=/app/storagenode\$#command=/app/storagenode run ${SNO_RUN_PARAMS} ${*}#" \
/etc/supervisord.conf
fi
/etc/supervisor/supervisord.conf
exec /usr/bin/supervisord -c /etc/supervisord.conf
exec /usr/bin/supervisord -c /etc/supervisor/supervisord.conf
fi