From: garciadeblas Date: Thu, 4 May 2023 15:57:47 +0000 (+0200) Subject: Split generate_docker_images and pull_docker_images in installer X-Git-Tag: release-v14.0-start~66 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=53b217f94a1c19c58eb3f3077779b3dcdfb741e7;p=osm%2Fdevops.git Split generate_docker_images and pull_docker_images in installer Change-Id: I09fc0f0c566b481f78d818715be64dbcb855c955 Signed-off-by: garciadeblas --- diff --git a/installers/full_install_osm.sh b/installers/full_install_osm.sh index 03be9a62..c03f57b2 100755 --- a/installers/full_install_osm.sh +++ b/installers/full_install_osm.sh @@ -215,13 +215,12 @@ function docker_login() { [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function } -function generate_docker_images() { +function pull_docker_images() { [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function - echo "Pulling and generating docker images" - [ -n "${DOCKER_REGISTRY_URL}" ] && docker_login - echo "Pulling docker images" + [ -n "${DOCKER_REGISTRY_URL}" ] && docker_login + echo "Pulling non-OSM docker images" if [ -z "$TO_REBUILD" ] || echo $TO_REBUILD | grep -q KAFKA ; then sg docker -c "docker pull wurstmeister/zookeeper" || FATAL "cannot get zookeeper docker image" sg docker -c "docker pull wurstmeister/kafka:${KAFKA_TAG}" || FATAL "cannot get kafka docker image" @@ -248,48 +247,51 @@ function generate_docker_images() { sg docker -c "docker pull mysql:5" || FATAL "cannot get mysql docker image" fi - if [ -n "$PULL_IMAGES" ]; then - echo "Pulling OSM docker images" - for module in MON POL NBI KEYSTONE RO LCM NG-UI PLA osmclient; do + echo "Pulling OSM docker images" + for module in MON POL NBI KEYSTONE RO LCM NG-UI PLA osmclient Airflow; do + module_lower=${module,,} + if [ $module == "PLA" -a ! -n "$INSTALL_PLA" ]; then + continue + fi + module_tag="${OSM_DOCKER_TAG}" + if [ -n "${MODULE_DOCKER_TAG}" ] && echo $TO_REBUILD | grep -q $module ; then + module_tag="${MODULE_DOCKER_TAG}" + fi + echo "Pulling ${DOCKER_REGISTRY_URL}${DOCKER_USER}/${module_lower}:${module_tag} docker image" + sg docker -c "docker pull ${DOCKER_REGISTRY_URL}${DOCKER_USER}/${module_lower}:${module_tag}" || FATAL "cannot pull $module docker image" + done + + echo "Finished pulling docker images" + [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function +} + +function generate_docker_images() { + [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function + echo "Generating docker images" + _build_from=$COMMIT_ID + [ -z "$_build_from" ] && _build_from="latest" + echo "OSM Docker images generated from $_build_from" + LWTEMPDIR="$(mktemp -d -q --tmpdir "installosmlight.XXXXXX")" + trap 'rm -rf "${LWTEMPDIR}"' EXIT + for module in MON POL NBI KEYSTONE RO LCM NG-UI PLA; do + if [ -z "$TO_REBUILD" ] || echo $TO_REBUILD | grep -q ${module} ; then module_lower=${module,,} if [ $module == "PLA" -a ! -n "$INSTALL_PLA" ]; then continue fi - module_tag="${OSM_DOCKER_TAG}" - if [ -n "${MODULE_DOCKER_TAG}" ] && echo $TO_REBUILD | grep -q $module ; then - module_tag="${MODULE_DOCKER_TAG}" - fi - echo "Pulling ${DOCKER_REGISTRY_URL}${DOCKER_USER}/${module_lower}:${module_tag} docker image" - sg docker -c "docker pull ${DOCKER_REGISTRY_URL}${DOCKER_USER}/${module_lower}:${module_tag}" || FATAL "cannot pull $module docker image" - done - else - _build_from=$COMMIT_ID - [ -z "$_build_from" ] && _build_from="latest" - echo "OSM Docker images generated from $_build_from" - LWTEMPDIR="$(mktemp -d -q --tmpdir "installosmlight.XXXXXX")" - trap 'rm -rf "${LWTEMPDIR}"' EXIT - for module in MON POL NBI KEYSTONE RO LCM NG-UI PLA; do - if [ -z "$TO_REBUILD" ] || echo $TO_REBUILD | grep -q ${module} ; then - module_lower=${module,,} - if [ $module == "PLA" -a ! -n "$INSTALL_PLA" ]; then - continue - fi - git -C ${LWTEMPDIR} clone https://osm.etsi.org/gerrit/osm/$module - git -C ${LWTEMPDIR}/${module} checkout ${COMMIT_ID} - sg docker -c "docker build ${LWTEMPDIR}/${module} -f ${LWTEMPDIR}/${module}/docker/Dockerfile -t ${DOCKER_USER}/${module_lower} --no-cache" || FATAL "cannot build ${module} docker image" - fi - done - if [ -z "$TO_REBUILD" ] || echo $TO_REBUILD | grep -q osmclient; then - BUILD_ARGS+=(--build-arg REPOSITORY="$REPOSITORY") - BUILD_ARGS+=(--build-arg RELEASE="$RELEASE") - BUILD_ARGS+=(--build-arg REPOSITORY_KEY="$REPOSITORY_KEY") - BUILD_ARGS+=(--build-arg REPOSITORY_BASE="$REPOSITORY_BASE") - sg docker -c "docker build -t ${DOCKER_USER}/osmclient ${BUILD_ARGS[@]} -f $OSM_DEVOPS/docker/osmclient ." + git -C ${LWTEMPDIR} clone https://osm.etsi.org/gerrit/osm/$module + git -C ${LWTEMPDIR}/${module} checkout ${COMMIT_ID} + sg docker -c "docker build ${LWTEMPDIR}/${module} -f ${LWTEMPDIR}/${module}/docker/Dockerfile -t ${DOCKER_USER}/${module_lower} --no-cache" || FATAL "cannot build ${module} docker image" fi - echo "Finished generation of docker images" + done + if [ -z "$TO_REBUILD" ] || echo $TO_REBUILD | grep -q osmclient; then + BUILD_ARGS+=(--build-arg REPOSITORY="$REPOSITORY") + BUILD_ARGS+=(--build-arg RELEASE="$RELEASE") + BUILD_ARGS+=(--build-arg REPOSITORY_KEY="$REPOSITORY_KEY") + BUILD_ARGS+=(--build-arg REPOSITORY_BASE="$REPOSITORY_BASE") + sg docker -c "docker build -t ${DOCKER_USER}/osmclient ${BUILD_ARGS[@]} -f $OSM_DEVOPS/docker/osmclient ." fi - - echo "Finished pulling and generating docker images" + echo "Finished generation of docker images" [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function } @@ -790,7 +792,8 @@ function install_osm() { fi # Deploy OSM services - [ -z "$DOCKER_NOBUILD" ] && generate_docker_images + [ -z "$DOCKER_NOBUILD" ] && pull_docker_images + [ -z "$DOCKER_NOBUILD" ] && [ -z "$PULL_IMAGES" ] && generate_docker_images track docker_images docker_images_ok generate_k8s_manifest_files