From cbb323ad52772d567889dddc6c7734a3623c9e83 Mon Sep 17 00:00:00 2001 From: Matt Robinson Date: Tue, 21 May 2019 07:57:20 -0400 Subject: [PATCH] Give the bootstrap image the business. (#2005) --- Makefile | 21 +++++++++++++++++---- cmd/bootstrap/Dockerfile | 16 ++++++---------- cmd/bootstrap/entrypoint | 8 +++----- 3 files changed, 26 insertions(+), 19 deletions(-) diff --git a/Makefile b/Makefile index 8569763fa..710b589af 100644 --- a/Makefile +++ b/Makefile @@ -120,9 +120,16 @@ test-all-in-one: ## Test docker images locally ##@ Build .PHONY: images -images: satellite-image storagenode-image uplink-image gateway-image versioncontrol-image ## Build gateway, satellite, storagenode, uplink and versioncontrol Docker images +images: bootstrap-image gateway-image satellite-image storagenode-image uplink-image versioncontrol-image ## Build bootstrap, gateway, satellite, storagenode, uplink, and versioncontrol Docker images echo Built version: ${TAG} +.PHONY: bootstrap-image +bootstrap-image: bootstrap_linux_arm bootstrap_linux_amd64 ## Build bootstrap Docker image + ${DOCKER_BUILD} --pull=true -t storjlabs/bootstrap:${TAG}${CUSTOMTAG}-amd64 \ + -f cmd/bootstrap/Dockerfile . + ${DOCKER_BUILD} --pull=true -t storjlabs/bootstrap:${TAG}${CUSTOMTAG}-arm32v6 \ + --build-arg=GOARCH=arm --build-arg=DOCKER_ARCH=arm32v6 \ + -f cmd/bootstrap/Dockerfile . .PHONY: gateway-image gateway-image: gateway_linux_arm gateway_linux_amd64 ## Build gateway Docker image ${DOCKER_BUILD} --pull=true -t storjlabs/gateway:${TAG}${CUSTOMTAG}-amd64 \ @@ -182,6 +189,10 @@ binary: [ "${FILEEXT}" = ".exe" ] && storj-sign release/${TAG}/$(COMPONENT)_${GOOS}_${GOARCH}${FILEEXT} || echo "Skipping signing" rm -f release/${TAG}/${COMPONENT}_${GOOS}_${GOARCH}.zip +.PHONY: bootstrap_% +bootstrap_%: + GOOS=$(word 2, $(subst _, ,$@)) GOARCH=$(word 3, $(subst _, ,$@)) COMPONENT=bootstrap $(MAKE) binary + $(MAKE) binary-check COMPONENT=bootstrap GOARCH=$(word 3, $(subst _, ,$@)) GOOS=$(word 2, $(subst _, ,$@)) .PHONY: gateway_% gateway_%: GOOS=$(word 2, $(subst _, ,$@)) GOARCH=$(word 3, $(subst _, ,$@)) COMPONENT=gateway $(MAKE) binary @@ -213,11 +224,11 @@ inspector_%: versioncontrol_%: GOOS=$(word 2, $(subst _, ,$@)) GOARCH=$(word 3, $(subst _, ,$@)) COMPONENT=versioncontrol $(MAKE) binary -COMPONENTLIST := gateway satellite storagenode uplink identity certificates inspector versioncontrol +COMPONENTLIST := bootstrap certificates gateway identity inspector satellite storagenode uplink versioncontrol OSARCHLIST := darwin_amd64 linux_amd64 linux_arm windows_amd64 BINARIES := $(foreach C,$(COMPONENTLIST),$(foreach O,$(OSARCHLIST),$C_$O)) .PHONY: binaries -binaries: ${BINARIES} ## Build gateway, satellite, storagenode, uplink, identity, and certificates binaries (jenkins) +binaries: ${BINARIES} ## Build bootstrap, certificates, gateway, identity, inspector, satellite, storagenode, uplink, and versioncontrol binaries (jenkins) ##@ Deploy @@ -232,7 +243,7 @@ deploy: ## Update Kubernetes deployments in staging (jenkins) push-images: ## Push Docker images to Docker Hub (jenkins) # images have to be pushed before a manifest can be created # satellite - for c in satellite storagenode uplink gateway versioncontrol; do \ + for c in bootstrap gateway satellite storagenode uplink versioncontrol ; do \ docker push storjlabs/$$c:${TAG}${CUSTOMTAG}-amd64 \ && docker push storjlabs/$$c:${TAG}${CUSTOMTAG}-arm32v6 \ && for t in ${TAG}${CUSTOMTAG} ${LATEST_TAG}; do \ @@ -259,10 +270,12 @@ binaries-clean: ## Remove all local release binaries (jenkins) .PHONY: clean-images clean-images: + -docker rmi storjlabs/bootstrap:${TAG}${CUSTOMTAG} -docker rmi storjlabs/gateway:${TAG}${CUSTOMTAG} -docker rmi storjlabs/satellite:${TAG}${CUSTOMTAG} -docker rmi storjlabs/storagenode:${TAG}${CUSTOMTAG} -docker rmi storjlabs/uplink:${TAG}${CUSTOMTAG} + -docker rmi storjlabs/versioncontrol:${TAG}${CUSTOMTAG} .PHONY: test-docker-clean test-docker-clean: ## Clean up Docker environment used in test-docker target diff --git a/cmd/bootstrap/Dockerfile b/cmd/bootstrap/Dockerfile index 5c4ba4ec0..a7b503723 100644 --- a/cmd/bootstrap/Dockerfile +++ b/cmd/bootstrap/Dockerfile @@ -1,14 +1,10 @@ -ARG CGO_ENABLED=1 -ARG REPOSITORY=../storj.io/storj -ARG PACKAGE=storj.io/storj/cmd/bootstrap -FROM storjlabs/golang as build-env - -# final stage -FROM alpine -ENV CONF_PATH=/root/.local/share/storj/bootstrap +ARG DOCKER_ARCH +FROM ${DOCKER_ARCH:-amd64}/alpine +ARG TAG +ARG GOARCH +ENV GOARCH ${GOARCH} EXPOSE 28967 WORKDIR /app -VOLUME /root/.local/share/storj/bootstrap -COPY --from=build-env /app /app/bootstrap +COPY release/${TAG}/bootstrap_linux_${GOARCH:-amd64} /app/bootstrap COPY cmd/bootstrap/entrypoint /entrypoint ENTRYPOINT ["/entrypoint"] diff --git a/cmd/bootstrap/entrypoint b/cmd/bootstrap/entrypoint index e9caa4fb7..311548f28 100755 --- a/cmd/bootstrap/entrypoint +++ b/cmd/bootstrap/entrypoint @@ -1,10 +1,8 @@ #!/bin/sh set -euo pipefail -if [[ ! -f "${CONF_PATH}/config.yaml" ]]; then - ./bootstrap setup +if [ ! -f $HOME/.local/share/storj/bootstrap/config.yaml ]; then + /app/bootstrap setup fi -RUN_PARAMS="${RUN_PARAMS:-} --config-dir ${CONF_PATH}" - -exec ./bootstrap run $RUN_PARAMS "$@" +exec ./bootstrap run "$@"