Revert "storagenode: docker image autoupdate binaries"

This reverts commit 244c488b10.
This commit is contained in:
igor gaidaienko 2021-05-13 13:36:21 +03:00 committed by Igor
parent 59f443e71a
commit d32ae0459b
5 changed files with 22 additions and 141 deletions

View File

@ -178,14 +178,14 @@ satellite-image: satellite_linux_arm satellite_linux_arm64 satellite_linux_amd64
-f cmd/satellite/Dockerfile . -f cmd/satellite/Dockerfile .
.PHONY: storagenode-image .PHONY: storagenode-image
storagenode-image: ## Build storagenode Docker image storagenode-image: storagenode_linux_arm storagenode_linux_arm64 storagenode_linux_amd64 ## Build storagenode Docker image
${DOCKER_BUILD} --pull=true -t storjlabs/storagenode:${TAG}${CUSTOMTAG}-amd64 \ ${DOCKER_BUILD} --pull=true -t storjlabs/storagenode:${TAG}${CUSTOMTAG}-amd64 \
-f cmd/storagenode/Dockerfile . -f cmd/storagenode/Dockerfile .
${DOCKER_BUILD} --pull=true -t storjlabs/storagenode:${TAG}${CUSTOMTAG}-arm32v6 \ ${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 \
-f cmd/storagenode/Dockerfile . -f cmd/storagenode/Dockerfile .
${DOCKER_BUILD} --pull=true -t storjlabs/storagenode:${TAG}${CUSTOMTAG}-arm64v8 \ ${DOCKER_BUILD} --pull=true -t storjlabs/storagenode:${TAG}${CUSTOMTAG}-arm64v8 \
--build-arg=GOARCH=arm --build-arg=DOCKER_ARCH=arm64v8 --build-arg=APK_ARCH=aarch64 \ --build-arg=GOARCH=arm --build-arg=DOCKER_ARCH=arm64v8 \
-f cmd/storagenode/Dockerfile . -f cmd/storagenode/Dockerfile .
.PHONY: uplink-image .PHONY: uplink-image
uplink-image: uplink_linux_arm uplink_linux_arm64 uplink_linux_amd64 ## Build uplink Docker image uplink-image: uplink_linux_arm uplink_linux_arm64 uplink_linux_amd64 ## Build uplink Docker image

View File

@ -1,33 +1,24 @@
ARG DOCKER_ARCH ARG DOCKER_ARCH
ARG APK_ARCH
# Fetch ca-certificates file and supervisor apk pkg with dependecies for arch independent builds below # Fetch ca-certificates file for arch independent builds below
FROM alpine as alpine FROM alpine as ca-cert
RUN apk -U add ca-certificates RUN apk -U add ca-certificates
RUN echo ${APK_ARCH:-x86_64} > /etc/apk/arch
RUN mkdir /tmp/apk-supervisor
RUN apk fetch --no-cache -R -o /tmp/apk-supervisor supervisor
FROM ${DOCKER_ARCH:-amd64}/alpine FROM ${DOCKER_ARCH:-amd64}/alpine
ARG TAG ARG TAG
ARG GOARCH ARG GOARCH
ARG VERSION_SERVER_URL ENV GOARCH ${GOARCH}
ENV GOARCH ${GOARCH:-amd64}
ENV VERSION_SERVER_URL ${VERSION_SERVER_URL:-https://version.storj.io}
EXPOSE 28967 EXPOSE 28967
EXPOSE 14002 WORKDIR /app
COPY --from=alpine /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt COPY --from=ca-cert /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=alpine /tmp/apk-supervisor/* /var/lib/apk-supervisor/ COPY release/${TAG}/storagenode_linux_${GOARCH:-amd64} /app/storagenode
COPY cmd/storagenode/entrypoint /entrypoint COPY cmd/storagenode/entrypoint /entrypoint
COPY cmd/storagenode/dashboard.sh /app/dashboard.sh COPY cmd/storagenode/dashboard.sh /app/dashboard.sh
COPY cmd/storagenode/supervisord.conf /etc/supervisord.conf
COPY cmd/storagenode/systemctl /bin/systemctl
WORKDIR /app
ENTRYPOINT ["/entrypoint"] ENTRYPOINT ["/entrypoint"]
# Remove after the alpha
ENV ADDRESS="" \ ENV ADDRESS="" \
EMAIL="" \ EMAIL="" \
WALLET="" \ WALLET="" \
STORAGE="2.0TB" \ STORAGE="2.0TB" \
SETUP="false" \ SETUP="false"
AUTO_UPDATE="true"

View File

@ -1,90 +1,20 @@
#!/bin/sh #!/bin/sh
set -euo pipefail set -euo pipefail
function get_default_url { if [[ "${SETUP:-}" == "true" ]]
process=$1 then
version=$2 ./storagenode setup --config-dir config --identity-dir identity
echo $(wget -O - "${VERSION_SERVER_URL}/processes/${process}/${version}/url?os=linux&arch=${GOARCH}") else
}
function get_binary {
binary=$1
url=$2
wget -O - ${url} | unzip -p - > /app/${binary}
chmod u+x /app/${binary}
}
if [[ ! -f "storagenode-updater" ]]; then
echo "downloading storagenode-updater"
get_binary storagenode-updater $(get_default_url storagenode-updater minimum)
if ./storagenode-updater should-update storagenode-updater \
--binary-location /app/storagenode-updater \
--identity-dir identity \
--version.server-address=${VERSION_SERVER_URL} 2>/dev/null
then
echo "updating storagenode-updater"
get_binary storagenode-updater $(get_default_url storagenode-updater suggested)
fi
fi
if [[ ! -f "storagenode" ]]; then
echo "downloading storagenode"
if ./storagenode-updater should-update storagenode \
--identity-dir identity \
--version.server-address=${VERSION_SERVER_URL} 2>/dev/null
then
get_binary storagenode $(get_default_url storagenode suggested)
else
get_binary storagenode $(get_default_url storagenode minimum)
fi
fi
RUN_PARAMS="${RUN_PARAMS:-} --config-dir config" RUN_PARAMS="${RUN_PARAMS:-} --config-dir config"
RUN_PARAMS="${RUN_PARAMS:-} --identity-dir identity" RUN_PARAMS="${RUN_PARAMS:-} --identity-dir identity"
RUN_PARAMS="${RUN_PARAMS:-} --metrics.app-suffix=-alpha" RUN_PARAMS="${RUN_PARAMS:-} --metrics.app-suffix=-alpha"
RUN_PARAMS="${RUN_PARAMS:-} --metrics.interval=30m" RUN_PARAMS="${RUN_PARAMS:-} --metrics.interval=30m"
RUN_PARAMS="${RUN_PARAMS:-} --contact.external-address=${ADDRESS}"
RUN_PARAMS="${RUN_PARAMS:-} --operator.email=${EMAIL}"
RUN_PARAMS="${RUN_PARAMS:-} --operator.wallet=${WALLET}"
RUN_PARAMS="${RUN_PARAMS:-} --console.address=:14002" RUN_PARAMS="${RUN_PARAMS:-} --console.address=:14002"
RUN_PARAMS="${RUN_PARAMS:-} --storage.allocated-disk-space=${STORAGE}"
if [[ -n "${VERSION_SERVER_URL:-}" ]]; then exec ./storagenode run $RUN_PARAMS "$@"
RUN_PARAMS="${RUN_PARAMS:-} --version.server-address=${VERSION_SERVER_URL}" fi
fi
if [[ -n "${ADDRESS:-}" ]]; then
RUN_PARAMS="${RUN_PARAMS:-} --contact.external-address=${ADDRESS}"
fi
if [[ -n "${EMAIL:-}" ]]; then
RUN_PARAMS="${RUN_PARAMS:-} --operator.email=${EMAIL}"
fi
if [[ -n "${WALLET:-}" ]]; then
RUN_PARAMS="${RUN_PARAMS:-} --operator.wallet=${WALLET}"
fi
if [[ -n "${STORAGE:-}" ]]; then
RUN_PARAMS="${RUN_PARAMS:-} --storage.allocated-disk-space=${STORAGE}"
fi
if [[ "${AUTO_UPDATE:-}" != "true" ]]; then
AUTO_UPDATE="false"
fi
if [[ "${SETUP:-}" == "true" ]]; then
exec ./storagenode setup $RUN_PARAMS ${*}
else
# install supervisor
if ! apk list supervisor 2>/dev/null | grep "supervisor"; then
echo "installing supervisor"
mkdir -p /var/log/supervisor
# permorm 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
sed -i \
"s#^command=/app/storagenode\$#command=/app/storagenode run ${RUN_PARAMS} ${*}#" \
/etc/supervisord.conf
fi
exec /usr/bin/supervisord -c /etc/supervisord.conf
fi

View File

@ -1,32 +0,0 @@
[supervisord]
user=root
nodaemon=true
logfile=/var/log/supervisor/supervisord.log
pidfile=/run/supervisord.pid
childlogdir=/var/log/supervisor
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[inet_http_server]
port = 127.0.0.1:9001
[supervisorctl]
serverurl = http://127.0.0.1:9001
[program:storagenode-updater]
command=/app/storagenode-updater
autostart=%(ENV_AUTO_UPDATE)s
autorestart=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stdout
stderr_logfile_maxbytes=0
[program:storagenode]
command=/app/storagenode
autorestart=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stdout
stderr_logfile_maxbytes=0

View File

@ -1,8 +0,0 @@
#!/bin/sh
if [[ "$*" != "show --property=MainPID storagenode" ]]; then
echo "invalid command" >&2
exit 1
fi
printf "MainPID=$(supervisorctl pid storagenode)"