Skip to content
Snippets Groups Projects
Commit 31f5b45c authored by Corné Lukken's avatar Corné Lukken
Browse files

L2SS-205: Build more images once unconditionally

parent 9736a5ea
No related branches found
No related tags found
1 merge request!183Docker image building & pushing with CI pipeline caching
...@@ -61,6 +61,20 @@ docker_store_images_changes: ...@@ -61,6 +61,20 @@ docker_store_images_changes:
refs: refs:
- tags - tags
- master - master
# TODO(Corne): Remove this job after it has run once
docker_build_image_all:
extends: .base_docker_images
script:
- bash $CI_PROJECT_DIR/sbin/tag_and_push_docker_image.sh lofar-device-base $tag
- bash $CI_PROJECT_DIR/sbin/tag_and_push_docker_image.sh elk $tag
- bash $CI_PROJECT_DIR/sbin/tag_and_push_docker_image.sh elk-configure-host $tag
- bash $CI_PROJECT_DIR/sbin/tag_and_push_docker_image.sh grafana $tag
- bash $CI_PROJECT_DIR/sbin/tag_and_push_docker_image.sh prometheus $tag
- bash $CI_PROJECT_DIR/sbin/tag_and_push_docker_image.sh lofar-device-base $tag
- bash $CI_PROJECT_DIR/sbin/tag_and_push_docker_image.sh jupyter $tag
- bash $CI_PROJECT_DIR/sbin/tag_and_push_docker_image.sh itango $tag
- bash $CI_PROJECT_DIR/sbin/tag_and_push_docker_image.sh integration-test $tag
- bash $CI_PROJECT_DIR/sbin/tag_and_push_docker_image.sh tango-prometheus-exporter $tag
docker_build_image_elk: docker_build_image_elk:
extends: .base_docker_images extends: .base_docker_images
only: only:
...@@ -90,14 +104,14 @@ docker_build_image_prometheus: ...@@ -90,14 +104,14 @@ docker_build_image_prometheus:
script: script:
# Do not remove 'bash' or statement will be ignored by primitive docker shell # Do not remove 'bash' or statement will be ignored by primitive docker shell
- bash $CI_PROJECT_DIR/sbin/tag_and_push_docker_image.sh prometheus $tag - bash $CI_PROJECT_DIR/sbin/tag_and_push_docker_image.sh prometheus $tag
#docker_build_image_docker-compose_itango: docker_build_image_itango:
# extends: .base_docker_images extends: .base_docker_images
# only: only:
# changes: changes:
# - docker-compose/itango.yml - docker-compose/itango.yml
# script: script:
# # Do not remove 'bash' or statement will be ignored by primitive docker shell # Do not remove 'bash' or statement will be ignored by primitive docker shell
# - bash $CI_PROJECT_DIR/sbin/tag_and_push_docker_image.sh itango - bash $CI_PROJECT_DIR/sbin/tag_and_push_docker_image.sh itango $tag
docker_build_image_grafana: docker_build_image_grafana:
extends: .base_docker_images extends: .base_docker_images
only: only:
......
...@@ -39,14 +39,13 @@ fi ...@@ -39,14 +39,13 @@ fi
# Tuple of images and queries to detect changes # Tuple of images and queries to detect changes
# TODO(Corne): Have this list generated from the .yml files # TODO(Corne): Have this list generated from the .yml files
LOCAL_IMAGES=( LOCAL_IMAGES=(
"elk" "elk-configure-host" "grafana" "prometheus" "lofar-device-base" "elk elk" "elk-configure-host elk-configure-host" "grafana grafana"
"prometheus prometheus" "lofar-device-base lofar-device-base"
"jupyter docker-compose_jupyter" "itango docker-compose_itango"
"integration-test docker-compose_integration-test"
"tango-prometheus-exporter docker-compose_tango-prometheus-exporter"
) )
# TBD TODO(Corne): Verify using these images as cache works
# "docker-compose_jupyter" "docker-compose_integration-test"
# "docker-compose_itango" "docker-compose_tango-prometheus-exporter"
#)
# If first argument set run second stage, determine LOCAL_IMAGE to build and # If first argument set run second stage, determine LOCAL_IMAGE to build and
# push from the argument # push from the argument
if [ ! -z "${1+x}" ] && [ "${1}" != "pull" ]; then if [ ! -z "${1+x}" ] && [ "${1}" != "pull" ]; then
...@@ -57,16 +56,20 @@ if [ ! -z "${1+x}" ] && [ "${1}" != "pull" ]; then ...@@ -57,16 +56,20 @@ if [ ! -z "${1+x}" ] && [ "${1}" != "pull" ]; then
exit 1 exit 1
fi fi
# Set the tag variable # Set the tag and image variable, variables $1 and $2 are shadowed later
local_image="${1}"
tag="${2}" tag="${2}"
cd "${LOFAR20_DIR}/docker-compose" || exit 1 cd "${LOFAR20_DIR}/docker-compose" || exit 1
# Loop through images and find the specified one # Loop through images and find the specified one
for image in "${LOCAL_IMAGES[@]}"; do for image in "${LOCAL_IMAGES[@]}"; do
if [ "${1}" == "${image}" ]; then # Set, splits tuple into $1 and $2. this shadows previous variables
echo "Building image for ${image} container" # shellcheck disable=SC2086
local_url="${LOCAL_DOCKER_REGISTRY_HOST}/${LOCAL_DOCKER_REGISTRY_USER}/${image}" set -- $image
if [ "${local_image}" == "${1}" ]; then
echo "Building image for ${1} container"
local_url="${LOCAL_DOCKER_REGISTRY_HOST}/${LOCAL_DOCKER_REGISTRY_USER}/${2}"
# If tag is not latest, than it is not a tagged master build and we can # If tag is not latest, than it is not a tagged master build and we can
# pull the latest image as cache. # pull the latest image as cache.
...@@ -74,8 +77,8 @@ if [ ! -z "${1+x}" ] && [ "${1}" != "pull" ]; then ...@@ -74,8 +77,8 @@ if [ ! -z "${1+x}" ] && [ "${1}" != "pull" ]; then
docker pull "${local_url}:latest" docker pull "${local_url}:latest"
fi fi
make build "${image}" make build "${1}"
docker tag "${image}" "${local_url}:${tag}" docker tag "${2}" "${local_url}:${tag}"
docker push "${local_url}:${tag}" docker push "${local_url}:${tag}"
fi fi
done done
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment