mirror of
https://ops.gitlab.net/gitlab-org/gitlab-build-images.git
synced 2025-12-09 10:02:56 +01:00
Use a manual job to trigger a selective build/push
This commit is contained in:
parent
a9204d345d
commit
3acad93b15
4 changed files with 34 additions and 61 deletions
|
|
@ -1,25 +0,0 @@
|
|||
function image_already_exists() {
|
||||
image=$1
|
||||
|
||||
$(docker pull $image > /dev/null)
|
||||
}
|
||||
|
||||
function build_if_needed() {
|
||||
image=$1
|
||||
|
||||
if ! image_already_exists $image; then
|
||||
docker build -t "$image" -f "Dockerfile.$image" .
|
||||
else
|
||||
echo "$image already exists, skipping build."
|
||||
fi
|
||||
}
|
||||
|
||||
function push_if_needed() {
|
||||
image=$1
|
||||
|
||||
if ! image_already_exists $image; then
|
||||
docker push "$image"
|
||||
else
|
||||
echo "$image already exists, skipping push."
|
||||
fi
|
||||
}
|
||||
|
|
@ -303,17 +303,11 @@ 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
|
||||
# This re-uses and builds an existing image if needed
|
||||
docker pull "$full_image" || true
|
||||
docker_command=$(generate_command --from-cache="$full_image_name" $@)
|
||||
echo "Building $build_image_name with $docker_command"
|
||||
eval $docker_command
|
||||
}
|
||||
|
||||
build_custom_if_needed $@
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue