2020-03-21 02:42:13 -05:00
|
|
|
#!/bin/bash
|
2020-05-16 06:28:29 -05:00
|
|
|
|
2020-03-21 02:42:13 -05:00
|
|
|
set -e
|
|
|
|
|
2020-05-17 02:37:05 -05:00
|
|
|
# PLATFORMS="linux/arm/v7,linux/arm64/v8,linux/amd64"
|
|
|
|
PLATFORMS="linux/amd64"
|
2020-05-17 03:19:54 -05:00
|
|
|
DOCKER_IMAGE="shlinkio/shlink"
|
2020-05-05 14:58:23 -05: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
|
|
|
|
|
2020-03-21 02:42:13 -05:00
|
|
|
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-17 03:19:54 -05:00
|
|
|
TAGS="-t ${DOCKER_IMAGE}:${TRAVIS_TAG#?}"
|
2020-05-07 03:45:53 -05:00
|
|
|
# Push stable tag only if this is not an alpha or beta tag
|
2020-05-17 03:19:54 -05:00
|
|
|
[[ $TRAVIS_TAG != *"alpha"* && $TRAVIS_TAG != *"beta"* ]] && TAGS="${TAGS} -t ${DOCKER_IMAGE}:stable"
|
2020-05-15 11:40:20 -05:00
|
|
|
|
2020-05-05 14:58:23 -05:00
|
|
|
docker buildx build --push \
|
2020-05-16 03:39:47 -05:00
|
|
|
--build-arg SHLINK_VERSION=${TRAVIS_TAG#?} \
|
2020-05-17 02:37:05 -05:00
|
|
|
--platform ${PLATFORMS} \
|
2020-05-15 11:40:20 -05:00
|
|
|
${TAGS} .
|
|
|
|
|
2020-06-21 05:21:39 -05:00
|
|
|
# If build branch is develop, build latest (on main branch, when there's no tag, do not build anything)
|
2020-03-21 02:42:13 -05:00
|
|
|
elif [[ "$TRAVIS_BRANCH" == 'develop' ]]; then
|
2020-05-05 14:58:23 -05:00
|
|
|
docker buildx build --push \
|
2020-05-17 02:37:05 -05:00
|
|
|
--platform ${PLATFORMS} \
|
2020-05-17 03:19:54 -05:00
|
|
|
-t ${DOCKER_IMAGE}:latest .
|
2020-03-21 02:42:13 -05:00
|
|
|
fi
|