mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-05-08 20:08:15 +00:00
automation/build.sh: build base, nodesuper and gosuper before supervisor, and use them for cache
Otherwise the step where we build them doesn't reuse what was built when building the supervisor, because we're explicitly setting `--cache-from` options. We also push the images as soon as they're built. Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
This commit is contained in:
parent
d7f7a0bf57
commit
d9605c71dd
@ -12,7 +12,6 @@
|
|||||||
# * ENABLE_TESTS
|
# * ENABLE_TESTS
|
||||||
# * PUBNUB_SUBSCRIBE_KEY, PUBNUB_PUBLISH_KEY, MIXPANEL_TOKEN: default keys to inject in the supervisor image
|
# * PUBNUB_SUBSCRIBE_KEY, PUBNUB_PUBLISH_KEY, MIXPANEL_TOKEN: default keys to inject in the supervisor image
|
||||||
# * EXTRA_TAG: when PUSH_IMAGES is true, additional tag to push to the registries
|
# * EXTRA_TAG: when PUSH_IMAGES is true, additional tag to push to the registries
|
||||||
# * DOCKER_USERNAME, DOCKER_PASSWORD: if the password is set, then these will be used to login to dockerhub before pushing
|
|
||||||
#
|
#
|
||||||
# Builds the supervisor for the architecture defined by $ARCH.
|
# Builds the supervisor for the architecture defined by $ARCH.
|
||||||
# Will produce and push an image tagged as resin/$ARCH-supervisor:$TAG
|
# Will produce and push an image tagged as resin/$ARCH-supervisor:$TAG
|
||||||
@ -24,7 +23,7 @@
|
|||||||
#
|
#
|
||||||
# In all of these cases it will use "master" if $TAG is not found.
|
# In all of these cases it will use "master" if $TAG is not found.
|
||||||
#
|
#
|
||||||
# If PUSH_IMAGES is "true", it will also push the supervisor and intermediate images
|
# If PUSH_IMAGES is "true", it will also push the supervisor and intermediate images (must be logged in to dockerhub)
|
||||||
# to the docker registry.
|
# to the docker registry.
|
||||||
# If CLEANUP is "true", all images will be removed after pushing - including any relevant images
|
# If CLEANUP is "true", all images will be removed after pushing - including any relevant images
|
||||||
# that may have been on the host from before the build, so be careful!
|
# that may have been on the host from before the build, so be careful!
|
||||||
@ -104,36 +103,42 @@ export PUBNUB_PUBLISH_KEY
|
|||||||
export PUBNUB_SUBSCRIBE_KEY
|
export PUBNUB_SUBSCRIBE_KEY
|
||||||
export MIXPANEL_TOKEN
|
export MIXPANEL_TOKEN
|
||||||
|
|
||||||
|
make IMAGE=$BASE_IMAGE base
|
||||||
|
if [ "$PUSH_IMAGES" = "true" ]; then
|
||||||
|
make IMAGE=$BASE_IMAGE deploy || true
|
||||||
|
fi
|
||||||
|
export DOCKER_BUILD_OPTIONS="${DOCKER_BUILD_OPTIONS} --cache-from ${BASE_IMAGE}"
|
||||||
|
|
||||||
|
make IMAGE=$GO_IMAGE gosuper
|
||||||
|
if [ "$PUSH_IMAGES" = "true" ]; then
|
||||||
|
make IMAGE=$GO_IMAGE deploy || true
|
||||||
|
fi
|
||||||
|
export DOCKER_BUILD_OPTIONS="${DOCKER_BUILD_OPTIONS} --cache-from ${GO_IMAGE}"
|
||||||
|
|
||||||
|
make IMAGE=$NODE_IMAGE nodesuper
|
||||||
|
if [ "$PUSH_IMAGES" = "true" ]; then
|
||||||
|
make IMAGE=$NODE_IMAGE deploy || true
|
||||||
|
fi
|
||||||
|
export DOCKER_BUILD_OPTIONS="${DOCKER_BUILD_OPTIONS} --cache-from ${NODE_IMAGE}"
|
||||||
|
|
||||||
# This is the step that actually builds the supervisor
|
# This is the step that actually builds the supervisor
|
||||||
make IMAGE=$TARGET_IMAGE supervisor
|
make IMAGE=$TARGET_IMAGE supervisor
|
||||||
|
|
||||||
if [ "$PUSH_IMAGES" = "true" ]; then
|
if [ "$PUSH_IMAGES" = "true" ]; then
|
||||||
if [ -n "$DOCKER_PASSWORD" ]; then
|
|
||||||
docker login --username $DOCKER_USERNAME --password $DOCKER_PASSWORD
|
|
||||||
fi
|
|
||||||
make IMAGE=$TARGET_IMAGE deploy
|
make IMAGE=$TARGET_IMAGE deploy
|
||||||
|
|
||||||
if [ -n "$EXTRA_TAG" ]; then
|
if [ -n "$EXTRA_TAG" ]; then
|
||||||
docker tag $TARGET_IMAGE resin/$ARCH-supervisor:$EXTRA_TAG
|
docker tag $TARGET_IMAGE resin/$ARCH-supervisor:$EXTRA_TAG
|
||||||
make IMAGE=resin/$ARCH-supervisor:$EXTRA_TAG deploy
|
make IMAGE=resin/$ARCH-supervisor:$EXTRA_TAG deploy
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Try to push the intermediate images to improve caching in future builds
|
|
||||||
# But we don't care much if any of this fails.
|
|
||||||
( make IMAGE=$BASE_IMAGE base && make IMAGE=$BASE_IMAGE deploy ) || true
|
|
||||||
( make IMAGE=$GO_IMAGE gosuper && make IMAGE=$GO_IMAGE deploy ) || true
|
|
||||||
( make IMAGE=$NODE_IMAGE node && make IMAGE=$NODE_IMAGE deploy ) || true
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$CLEANUP" = "true" ]; then
|
if [ "$CLEANUP" = "true" ]; then
|
||||||
tryRemove $TARGET_IMAGE
|
tryRemove $TARGET_IMAGE
|
||||||
|
|
||||||
# Only attempt to remove intermediate imaegs if we built them
|
tryRemove $BASE_IMAGE
|
||||||
if [ "$PUSH_IMAGES" = "true" ]; then
|
tryRemove $GO_IMAGE
|
||||||
tryRemove $BASE_IMAGE
|
tryRemove $NODE_IMAGE
|
||||||
tryRemove $GO_IMAGE
|
|
||||||
tryRemove $NODE_IMAGE
|
|
||||||
fi
|
|
||||||
|
|
||||||
tryRemove $TARGET_CACHE
|
tryRemove $TARGET_CACHE
|
||||||
tryRemove $BASE_CACHE
|
tryRemove $BASE_CACHE
|
||||||
|
@ -41,12 +41,11 @@ defaults: &defaults
|
|||||||
export EXTRA_TAG=$VERSION_TAG
|
export EXTRA_TAG=$VERSION_TAG
|
||||||
fi
|
fi
|
||||||
echo "Starting build.sh"
|
echo "Starting build.sh"
|
||||||
|
docker login --username $DOCKER_USERNAME --password $DOCKER_PASSWORD
|
||||||
# start the build for this architecture
|
# start the build for this architecture
|
||||||
export TAG=${CIRCLE_BRANCH}
|
export TAG=${CIRCLE_BRANCH}
|
||||||
export ARCH=${ARCH}
|
export ARCH=${ARCH}
|
||||||
export PUSH_IMAGES=${PUSH_IMAGES}
|
export PUSH_IMAGES=${PUSH_IMAGES}
|
||||||
export DOCKER_USERNAME=${DOCKER_USERNAME}
|
|
||||||
export DOCKER_PASSWORD=${DOCKER_PASSWORD}
|
|
||||||
bash automation/build.sh
|
bash automation/build.sh
|
||||||
if [ "${CIRCLE_BRANCH}" = "master" ] && [ "${DEPLOY_TO_RESIN}" = "true" ]; then
|
if [ "${CIRCLE_BRANCH}" = "master" ] && [ "${DEPLOY_TO_RESIN}" = "true" ]; then
|
||||||
echo "Deploying to Resin API (staging)"
|
echo "Deploying to Resin API (staging)"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user