Files
ubuntu/build_command.sh

36 lines
1.3 KiB
Bash

#!/usr/bin/env sh
set -x # For verbosity
set -o errexit # The following two causes the script to fail even if one command fail.
set -o pipefail
export BUILDER_NAME=`docker buildx create --use`
docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
# Following only adds the :latest tag if it is the latest LTS version.
if [ "$LATEST_VER" = "$UBUNTU_VER" ];
then
docker buildx build . \
-f Dockerfile \
--build-arg UBUNTU_VER=$UBUNTU_VER \
-t $CI_REGISTRY/docker/$CI_PROJECT_NAME/ubuntu-$UBUNTU_VER:`date "+%Y-%m-%d"` \
-t $CI_REGISTRY/docker/$CI_PROJECT_NAME/ubuntu-$UBUNTU_VER:latest \
-t $CI_REGISTRY/docker/$CI_PROJECT_NAME:$UBUNTU_VER \
--platform $PLATFORMS \
--push --provenance false
else
docker buildx build . \
-f Dockerfile \
--build-arg UBUNTU_VER=$UBUNTU_VER \
-t $CI_REGISTRY/docker/$CI_PROJECT_NAME:ubuntu-$UBUNTU_VER:`date "+%Y-%m-%d"` \
-t $CI_REGISTRY/docker/$CI_PROJECT_NAME:ubuntu-$UBUNTU_VER:latest \
-t $CI_REGISTRY/docker/$CI_PROJECT_NAME:$UBUNTU_VER \
-t $CI_REGISTRY/docker/$CI_PROJECT_NAME:latest \
--platform $PLATFORMS \
--push --provenance false
fi
docker buildx prune --builder $BUILDER_NAME -f
docker buildx stop $BUILDER_NAME
docker buildx rm $BUILDER_NAME