Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove non-public images from the git-sha-based target determination #525

Merged
merged 4 commits into from
Apr 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 25 additions & 5 deletions scripts/docker/build_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,18 @@ def get_ordered_build_chain_list(self) -> List[str]:
}.difference(targets_to_build)
)

# Implementation note: it would be less verbose to add `self.non_public_images` to the `difference`
# method above. However, the following implementation enables simpler logging of the skipped images.
for non_public_image in self.non_public_images:
if non_public_image in new_targets_to_build:
new_targets_to_build.remove(non_public_image)
print_colored(
f"Skipping building the Docker image `{non_public_image}` since it cannot be hosted "
f"publicly. This image needs to be rebuilt, please consider building using the "
f"`--targets` tag and hosting it in a non-public registry.",
Colors.YELLOW
)

# noinspection PyTypeChecker
return sorted(targets_to_build, key=self.get_build_priority)

Expand Down Expand Up @@ -387,11 +399,19 @@ def build_and_push(self):
if self.project_arguments.base_git_commit is not None:
changed_project_files = self.changed_project_files
print(f"changed_project_files: {changed_project_files}", file=sys.stderr)
self.project_arguments.targets = [
target for target, image_dependencies in self.dependencies.items()
if image_dependencies.has_change(changed_project_files)
]
print(f"targets = {self.project_arguments.targets}")
self.project_arguments.targets = []
for target, image_dependencies in self.dependencies.items():
if image_dependencies.has_change(changed_project_files):
if target not in self.non_public_images:
self.project_arguments.targets.append(target)
else:
print_colored(
f"Skipping building the Docker image `{target}` since it cannot be hosted publicly. "
f"This image needs to be rebuilt, please consider building using the "
f"`--targets` tag and hosting it in a non-public registry.",
Colors.YELLOW
)
print_colored(f"targets = {self.project_arguments.targets}", Colors.GREEN)
elif "all" in self.project_arguments.targets:
self.project_arguments.targets = ProjectBuilder.images_built_by_all
# get targets + their dependencies in order (so that builds succeed)
Expand Down