shlink/docker/build

35 lines
1.2 KiB
Text
Raw Normal View History

#!/bin/bash
set -e
# PLATFORMS="linux/arm/v7,linux/arm64/v8,linux/amd64"
PLATFORMS="linux/amd64"
2020-05-05 22:58:23 +03:00
BUILDX_VER=v0.4.1
export DOCKER_CLI_EXPERIMENTAL=enabled
mkdir -vp ~/.docker/cli-plugins/ ~/dockercache
curl --silent -L "https://github.com/docker/buildx/releases/download/${BUILDX_VER}/buildx-${BUILDX_VER}.linux-amd64" > ~/.docker/cli-plugins/docker-buildx
chmod a+x ~/.docker/cli-plugins/docker-buildx
docker buildx create --use
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
# If there is a tag, regardless the branch, build that docker tag and also "stable"
if [[ ! -z $TRAVIS_TAG ]]; then
2020-05-15 19:40:20 +03:00
TAGS="-t shlinkio/shlink:${TRAVIS_TAG#?}"
# Push stable tag only if this is not an alpha or beta tag
2020-05-15 19:40:20 +03:00
[[ $TRAVIS_TAG != *"alpha"* && $TRAVIS_TAG != *"beta"* ]] && TAGS="${TAGS} -t shlinkio/shlink:stable"
2020-05-05 22:58:23 +03:00
docker buildx build --push \
--build-arg SHLINK_VERSION=${TRAVIS_TAG#?} \
--platform ${PLATFORMS} \
2020-05-15 19:40:20 +03:00
${TAGS} .
# If build branch is develop, build latest (on master, when there's no tag, do not build anything)
elif [[ "$TRAVIS_BRANCH" == 'develop' ]]; then
2020-05-05 22:58:23 +03:00
docker buildx build --push \
--platform ${PLATFORMS} \
-t shlinkio/shlink:latest .
fi