@@ -104,53 +104,56 @@ function push_pull_remove_images::pull_image_github_dockerhub() {
104104 set -e
105105}
106106
107- # Force pulls the python base image
108- function push_pull_remove_images::force_pull_python_base_image() {
107+ # Rebuilds python base image from the latest available Python version
108+ function push_pull_remove_images::rebuild_python_base_image() {
109+ echo
110+ echo " Rebuilding ${AIRFLOW_PYTHON_BASE_IMAGE} from latest ${PYTHON_BASE_IMAGE} "
111+ echo
109112 docker pull " ${PYTHON_BASE_IMAGE} "
110- echo " FROM ${PYTHON_BASE_IMAGE} " | \
113+ echo " FROM ${PYTHON_BASE_IMAGE} " | \
111114 docker build \
112115 --label " org.opencontainers.image.source=https://github.com/${GITHUB_REPOSITORY} " \
113116 -t " ${AIRFLOW_PYTHON_BASE_IMAGE} " -
114117}
115118
116119# Pulls the base Python image. This image is used as base for CI and PROD images, depending on the parameters used:
117120#
118- # * if FORCE_PULL_IMAGES is true or UPGRADE_TO_NEWER_DEPENDENCIES != false, then it pulls the latest Python image available first and
119- # adds `org.opencontainers.image.source` label to it, so that it is linked to Airflow repository when
120- # we push it to GHCR registry
121+ # * if FORCE_PULL_BASE_PYTHON_IMAGE != false, then it rebuild the image using latest Python image available
122+ # and adds `org.opencontainers.image.source` label to it, so that it is linked to Airflow
123+ # repository when we push it to GHCR registry
121124# * Otherwise it pulls the Python base image from either GitHub registry or from DockerHub
122125# depending on USE_GITHUB_REGISTRY variable. In case we pull specific build image (via suffix)
123126# it will pull the right image using the specified suffix
124127function push_pull_remove_images::pull_base_python_image() {
128+ if [[ ${FORCE_PULL_BASE_PYTHON_IMAGE} == " true" ]] ; then
129+ push_pull_remove_images::rebuild_python_base_image
130+ return
131+ fi
125132 echo
126- echo " Force pull python base image ${AIRFLOW_PYTHON_BASE_IMAGE} . Upgrade to newer dependencies : ${UPGRADE_TO_NEWER_DEPENDENCIES} "
133+ echo " Docker pulling base python image . Upgrade to newer deps : ${UPGRADE_TO_NEWER_DEPENDENCIES} "
127134 echo
128135 if [[ -n ${DETECTED_TERMINAL=} ]]; then
129- echo -n "
130- Docker pulling ${AIRFLOW_PYTHON_BASE_IMAGE} . Upgrade to newer dependencies ${UPGRADE_TO_NEWER_DEPENDENCIES}
136+ echo -n " Docker pulling base python image. Upgrade to newer deps: ${UPGRADE_TO_NEWER_DEPENDENCIES}
131137" > " ${DETECTED_TERMINAL} "
132138 fi
133- if [[ " ${FORCE_PULL_IMAGES} " == " true" || ${UPGRADE_TO_NEWER_DEPENDENCIES} != " false" ]]; then
134- push_pull_remove_images::force_pull_python_base_image
135- else
136- if [[ ${USE_GITHUB_REGISTRY} == " true" ]]; then
137- PYTHON_TAG_SUFFIX=" "
138- if [[ ${GITHUB_REGISTRY_PULL_IMAGE_TAG} != " latest" ]]; then
139- PYTHON_TAG_SUFFIX=" -${GITHUB_REGISTRY_PULL_IMAGE_TAG} "
140- fi
141- push_pull_remove_images::pull_image_github_dockerhub " ${AIRFLOW_PYTHON_BASE_IMAGE} " \
142- " ${GITHUB_REGISTRY_PYTHON_BASE_IMAGE}${PYTHON_TAG_SUFFIX} "
143- else
144- docker pull " ${AIRFLOW_PYTHON_BASE_IMAGE} "
139+ if [[ ${USE_GITHUB_REGISTRY} == " true" ]]; then
140+ PYTHON_TAG_SUFFIX=" "
141+ if [[ ${GITHUB_REGISTRY_PULL_IMAGE_TAG} != " latest" ]]; then
142+ PYTHON_TAG_SUFFIX=" -${GITHUB_REGISTRY_PULL_IMAGE_TAG} "
145143 fi
144+ push_pull_remove_images::pull_image_github_dockerhub " ${AIRFLOW_PYTHON_BASE_IMAGE} " \
145+ " ${GITHUB_REGISTRY_PYTHON_BASE_IMAGE}${PYTHON_TAG_SUFFIX} "
146+ else
147+ docker pull " ${AIRFLOW_PYTHON_BASE_IMAGE} "
146148 fi
147149}
148150
149151# Pulls CI image in case caching strategy is "pulled" and the image needs to be pulled
150152function push_pull_remove_images::pull_ci_images_if_needed() {
151153 local python_image_hash
152154 python_image_hash=$( docker images -q " ${AIRFLOW_PYTHON_BASE_IMAGE} " 2> /dev/null || true)
153- if [[ -z " ${python_image_hash=} " || " ${FORCE_PULL_IMAGES} " == " true" ]]; then
155+ if [[ -z " ${python_image_hash=} " || " ${FORCE_PULL_IMAGES} " == " true" || \
156+ ${FORCE_PULL_BASE_PYTHON_IMAGE} == " true" ]]; then
154157 push_pull_remove_images::pull_base_python_image
155158 fi
156159 if [[ " ${DOCKER_CACHE} " == " pulled" ]]; then
@@ -168,7 +171,8 @@ function push_pull_remove_images::pull_ci_images_if_needed() {
168171function push_pull_remove_images::pull_prod_images_if_needed() {
169172 local python_image_hash
170173 python_image_hash=$( docker images -q " ${AIRFLOW_PYTHON_BASE_IMAGE} " 2> /dev/null || true)
171- if [[ -z " ${python_image_hash=} " || " ${FORCE_PULL_IMAGES} " == " true" ]]; then
174+ if [[ -z " ${python_image_hash=} " || " ${FORCE_PULL_IMAGES} " == " true" || \
175+ ${FORCE_PULL_BASE_PYTHON_IMAGE} == " true" ]]; then
172176 push_pull_remove_images::pull_base_python_image
173177 fi
174178 if [[ " ${DOCKER_CACHE} " == " pulled" ]]; then
0 commit comments