Improved docker build script to avoid duplicating code

This commit is contained in:
Alejandro Celaya 2020-03-20 07:12:07 +01:00 committed by GitHub
parent 584d1ec1ce
commit 38fc402b16
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3,12 +3,12 @@ set -e
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
# If a tag exists, build both that tag and stable if [[ -z $TRAVIS_TAG ]]; then
if [[ ! -z $TRAVIS_TAG ]]; then docker build -t shlinkio/shlink-web-client:latest .
docker build --build-arg VERSION=${TRAVIS_TAG#?} -t shlinkio/shlink-web-client:${TRAVIS_TAG#?} -t shlinkio/shlink-web-client:stable . else
docker build --build-arg VERSION=${TRAVIS_TAG#?} -t shlinkio/shlink-web-client:${TRAVIS_TAG#?} -t shlinkio/shlink-web-client:stable -t shlinkio/shlink-web-client:latest .
docker push shlinkio/shlink-web-client:${TRAVIS_TAG#?} docker push shlinkio/shlink-web-client:${TRAVIS_TAG#?}
docker push shlinkio/shlink-web-client:stable docker push shlinkio/shlink-web-client:stable
fi fi
docker build -t shlinkio/shlink-web-client:latest .
docker push shlinkio/shlink-web-client:latest docker push shlinkio/shlink-web-client:latest