Skip to content

Instantly share code, notes, and snippets.

@keithmeng
Created June 26, 2020 18:55
Show Gist options
  • Save keithmeng/c31ac0be48b78ad6a24fd6662828d441 to your computer and use it in GitHub Desktop.
Save keithmeng/c31ac0be48b78ad6a24fd6662828d441 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
set -e
# Should be GITHUB_TOKEN passed if Dockerfile requires installation from private repo
BUILD_ARGS=""
if [[ ! -z $1 ]];
then
BUILD_ARGS="--build-arg GITHUB_TOKEN=$1"
fi
echo "pulling latest image from ${REGISTRY_HOST}, and building image from cache"
docker pull ${REGISTRY_HOST}/${APP_NAME}:latest || true
docker pull ${REGISTRY_HOST}/${APP_NAME}:${TRAVIS_COMMIT:0:7} || docker build --cache-from ${REGISTRY_HOST}/${APP_NAME}:latest ${BUILD_ARGS} -t ${REGISTRY_HOST}/${APP_NAME}:${TRAVIS_COMMIT:0:7} .
docker tag ${REGISTRY_HOST}/${APP_NAME}:${TRAVIS_COMMIT:0:7} ${REGISTRY_HOST}/${APP_NAME}:latest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment