mirror of
https://ops.gitlab.net/gitlab-org/gitlab-build-images.git
synced 2025-12-09 10:02:56 +01:00
Only build/tag/push images once
Signed-off-by: Rémy Coutable <remy@rymai.me>
This commit is contained in:
parent
cc680155e8
commit
611204c382
4 changed files with 73 additions and 8 deletions
|
|
@ -3,6 +3,8 @@
|
|||
set -e
|
||||
IFS=$'\n\t'
|
||||
|
||||
source scripts/build-helpers.sh
|
||||
|
||||
function print_golang_args() {
|
||||
|
||||
case "$1" in
|
||||
|
|
@ -198,10 +200,10 @@ function parse_arguments() {
|
|||
}
|
||||
|
||||
function generate_command() {
|
||||
buildimage_name=$1; shift;
|
||||
build_image_name=$1; shift;
|
||||
|
||||
printf -- "docker build "
|
||||
echo $buildimage_name | tr '-' '\n' | parse_arguments
|
||||
echo $build_image_name | tr '-' '\n' | parse_arguments
|
||||
|
||||
for i in "$@"
|
||||
do
|
||||
|
|
@ -210,6 +212,21 @@ function generate_command() {
|
|||
printf -- ".\\n"
|
||||
}
|
||||
|
||||
docker_command=$(generate_command $@)
|
||||
echo "$1: executing $docker_command"
|
||||
eval $docker_command
|
||||
function build_custom_if_needed() {
|
||||
build_image_name=$1
|
||||
full_image_name="$CI_REGISTRY_IMAGE:$build_image_name"
|
||||
|
||||
if [[ "$FORCE_BUILD" == "true" ]] || ! image_already_exists $full_image_name; then
|
||||
docker_command=$(generate_command $@)
|
||||
if [[ "$FORCE_BUILD" == "true" ]]; then
|
||||
echo "Force building $build_image_name due to `\$FORCE_BUILD=true` with $docker_command"
|
||||
else
|
||||
echo "Building $build_image_name with $docker_command"
|
||||
fi
|
||||
eval $docker_command
|
||||
else
|
||||
echo "$build_image_name already exists, skipping build."
|
||||
fi
|
||||
}
|
||||
|
||||
build_custom_if_needed $@
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue