cibus-frontend/scripts/build_release.sh
kjuulh 1f4f5ae181
Some checks failed
continuous-integration/drone/push Build is passing
continuous-integration/drone Build is failing
and agaaain,gcp ignore
2022-08-21 00:28:50 +02:00

47 lines
994 B
Bash
Executable File

#!/bin/bash
set -e
base_tag=$REGISTRY/$SERVICE
tag="$base_tag:${COMMIT_SHA:0:10}"
latest_tag="$base_tag:latest"
if [[ -n $DEBUG ]]
then
echo "debug:"
echo " REGISTRY: $REGISTRY"
echo " SERVICE: $SERVICE"
echo " COMMIT_SHA: $COMMIT_SHA"
echo " TMP: $TMP"
fi
echo "docker: logging in"
docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
export DOCKER_BUILDKIT=1
function build_target {
target=$1
echo "building $target"
latest_target_tag="$base_tag-$target:latest"
docker build \
--target "$target" \
--tag "$latest_target_tag" \
--build-arg BUILDKIT_INLINE_CACHE=1 \
--cache-from $latest_target_tag \
--file "$TMP/build_release.Dockerfile" .
}
build_target "deps"
build_target "builder"
docker build \
-t "$tag" \
--cache-from "$base_tag-deps:latest" \
--cache-from "$base_tag-builder:latest" \
--build-arg BUILDKIT_INLINE_CACHE=1 \
--cache-from $latest_tag \
-f "$TMP/build_release.Dockerfile" .
docker tag "$tag" "$latest_tag"