Skip to content

Commit

Permalink
Fix PROD image package installation in CI (apache#39035)
Browse files Browse the repository at this point in the history
When PROD image packages are installed in in CI, the local sources
should not be present in the image, also constraints from sources
shoudl replace the one downloaded from main.
  • Loading branch information
potiuk authored Apr 15, 2024
1 parent f902dbe commit 246f697
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,10 @@ function install_airflow_and_providers_from_docker_context_files(){
${ADDITIONAL_PIP_INSTALL_FLAGS} --constraint "${local_constraints_file}" \
"${install_airflow_package[@]}" "${installing_providers_packages[@]}"
set +x
echo
echo "${COLOR_BLUE}Copying ${local_constraints_file} to ${HOME}/constraints.txt${COLOR_RESET}"
echo
cp "${local_constraints_file}" "${HOME}/constraints.txt"
else
echo
echo "${COLOR_BLUE}Installing docker-context-files packages with constraints from GitHub${COLOR_RESET}"
Expand Down
13 changes: 13 additions & 0 deletions dev/breeze/src/airflow_breeze/params/build_prod_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,19 @@ def _extra_prod_docker_build_flags(self) -> list[str]:
)
self.airflow_constraints_location = constraints_location
extra_build_flags.extend(self.args_for_remote_install)
elif self.install_packages_from_context:
extra_build_flags.extend(
[
"--build-arg",
"AIRFLOW_SOURCES_FROM=/empty",
"--build-arg",
"AIRFLOW_SOURCES_TO=/empty",
"--build-arg",
f"AIRFLOW_INSTALLATION_METHOD={self.installation_method}",
"--build-arg",
f"AIRFLOW_CONSTRAINTS_REFERENCE={self.airflow_constraints_reference}",
],
)
else:
extra_build_flags.extend(
[
Expand Down
6 changes: 6 additions & 0 deletions docker_tests/test_prod_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,12 @@ def test_pip_dependencies_conflict(self, default_docker_image):
def test_check_dependencies_imports(self, package_name, import_names, default_docker_image):
run_python_in_docker(f"import {','.join(import_names)}", image=default_docker_image)

def test_there_is_no_opt_airflow_airflow_folder(self, default_docker_image):
output = run_bash_in_docker(
"find /opt/airflow/airflow/ 2>/dev/null | wc -l", image=default_docker_image
)
assert output == "0"


class TestExecuteAsRoot:
def test_execute_airflow_as_root(self, default_docker_image):
Expand Down
4 changes: 4 additions & 0 deletions scripts/docker/install_from_docker_context_files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ function install_airflow_and_providers_from_docker_context_files(){
${ADDITIONAL_PIP_INSTALL_FLAGS} --constraint "${local_constraints_file}" \
"${install_airflow_package[@]}" "${installing_providers_packages[@]}"
set +x
echo
echo "${COLOR_BLUE}Copying ${local_constraints_file} to ${HOME}/constraints.txt${COLOR_RESET}"
echo
cp "${local_constraints_file}" "${HOME}/constraints.txt"
else
echo
echo "${COLOR_BLUE}Installing docker-context-files packages with constraints from GitHub${COLOR_RESET}"
Expand Down

0 comments on commit 246f697

Please sign in to comment.