Created
June 26, 2020 18:52
-
-
Save keithmeng/e2f15c682966f4187246c06b836112ab to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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