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