babashka/.github/script/docker
Rahuλ Dé 7b1e9cbe62
[#699] Add alpine builds
* [#699] Add Dockerfile for alpine

* [#699] Add pod tests

* [#699] Add alpine image build

* [#699] Build images on CI

* [#699] Add actions

* [#699] Amend actions to the new flow
2021-01-03 14:18:34 +01:00

44 lines
1.4 KiB
Bash
Executable file

#!/usr/bin/env bash
set -eo pipefail
image_name="babashka/babashka"
image_tag=$(cat resources/BABASHKA_VERSION)
latest_tag="latest"
if [[ $image_tag =~ SNAPSHOT$ ]]
then
echo "This is a snapshot version"
snapshot="true"
else
echo "This is a non-snapshot version"
snapshot="false"
fi
if [ -z "$GITHUB_HEAD_REF" ] && [ "${GITHUB_REF##*/}" = "master" ]
then
echo "Building Docker image $image_name:$image_tag"
echo "$DOCKERHUB_PASS" | docker login -u "$DOCKERHUB_USER" --password-stdin
unzip "/tmp/release/babashka-${image_tag}-linux-amd64.zip"
docker build -t "$image_name" -f Dockerfile.ci .
docker tag "$image_name:$latest_tag" "$image_name:$image_tag"
rm -f bb
unzip "/tmp/release/babashka-${image_tag}-linux-static-amd64.zip"
docker build -t "$image_name:alpine" -f Dockerfile.alpine .
docker tag "$image_name:alpine" "$image_name:$image_tag-alpine"
# we only update latest when it's not a SNAPSHOT version
if [ "false" = "$snapshot" ]; then
echo "Pushing image $image_name:$latest_tag"
docker push "$image_name:$latest_tag"
echo "Pushing image $image_name:alpine"
docker push "$image_name:alpine"
fi
# we update the version tag, even if it's a SNAPSHOT version
echo "Pushing image $image_name:$image_tag"
docker push "$image_name:$image_tag"
docker push "$image_name:$image_tag-alpine"
else
echo "Not publishing Docker image"
fi
exit 0;