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

feat(.dockerignore): revise .dockerignore to correctly ignore copying unrelated files #5009

Merged
merged 7 commits into from
Jul 18, 2024

Conversation

youtalk
Copy link
Member

@youtalk youtalk commented Jul 18, 2024

Description

This is the first countermeasure raised in the dicussion https://github.com/orgs/autowarefoundation/discussions/5007.

I found that the current .dockerignore does not properly ignore the copying of unrelated files at all. Therefore, this PR revises the .dockerignore to prevent unnecessary files under src from being copied into the container image.

As a result, the compressed image size of devel has been reduced by 1.5GB. The most effective one is .git.

In addition, since .dockerignore has been properly configured, I believe that executing the COPY command will allow the layer cache to function correctly.

Tests performed

Before revising the .dockerignore:
Screenshot from 2024-07-18 16-10-30

After revising the .dockerignore:
Screenshot from 2024-07-18 20-14-14

Effects on system behavior

Not applicable.

Interface changes

Pre-review checklist for the PR author

The PR author must check the checkboxes below when creating the PR.

In-review checklist for the PR reviewers

The PR reviewers must check the checkboxes below before approval.

Post-review checklist for the PR author

The PR author must check the checkboxes below before merging.

  • There are no open discussions or they are tracked via tickets.

After all checkboxes are checked, anyone who has write access can merge the PR.

youtalk added 2 commits July 17, 2024 21:18
Signed-off-by: Yutaka Kondo <[email protected]>
Signed-off-by: Yutaka Kondo <[email protected]>
@youtalk youtalk self-assigned this Jul 18, 2024
@youtalk youtalk added the type:containers Docker containers, containerization of components, or container orchestration. label Jul 18, 2024
@youtalk youtalk changed the title feat(.dockerignore): Revise .dockerignore to correctly ignore copying unrelated src files feat(.dockerignore): Revise .dockerignore to correctly ignore copying unrelated files Jul 18, 2024
@youtalk
Copy link
Member Author

youtalk commented Jul 18, 2024

The list of extensions to ignore was selected for larger sizes using the following one-liner.

$ find src/universe -type d -name ".git" -prune -o -type f -exec du -hs {} + | sort -rh | head -n 100
27M     src/universe/autoware.universe/common/autoware_test_utils/test_map/pointcloud_map.pcd
19M     src/universe/external/llh_converter/data/gsigeo2011_ver2_1.asc
19M     src/universe/external/eagleye/eagleye_core/coordinate/data/gsigeo2011_ver2.asc
17M     src/universe/autoware.universe/localization/pose_instability_detector/media/pose_instabilty_detector_procedure.svg
17M     src/universe/autoware.universe/control/autoware_smart_mpc_trajectory_follower/autoware_smart_mpc_trajectory_follower/python_simulator/slalom_course_data.csv
8.6M    src/universe/autoware.universe/perception/detected_object_validation/image/obstacle_pointcloud_based_validator/debug_image.gif
5.1M    src/universe/autoware.universe/planning/behavior_path_planner/autoware_behavior_path_static_obstacle_avoidance_module/images/how_to_decide_path_shape_one_object.drawio.svg
3.9M    src/universe/autoware.universe/perception/probabilistic_occupancy_grid_map/image/pointcloud_based_occupancy_grid_map_sample_image.gif
3.4M    src/universe/autoware.universe/planning/behavior_path_planner/autoware_behavior_path_static_obstacle_avoidance_module/images/shift_length_parameters.drawio.svg
3.1M    src/universe/autoware.universe/planning/behavior_velocity_planner/autoware_behavior_velocity_intersection_module/docs/static-occlusion-timeout.png
2.7M    src/universe/autoware.universe/planning/autoware_static_centerline_generator/test/data/bag_ego_trajectory_turn-left-right.db3
2.6M    src/universe/autoware.universe/planning/autoware_static_centerline_generator/test/data/bag_ego_trajectory_turn-right.db3
2.4M    src/universe/autoware.universe/planning/behavior_velocity_planner/autoware_behavior_velocity_intersection_module/docs/ttc.gif
2.2M    src/universe/external/muSSP/input_MOT_seq07_followme.txt
2.2M    src/universe/autoware.universe/planning/behavior_velocity_planner/autoware_behavior_velocity_run_out_module/docs/collision_detection_for_shape.svg
2.2M    src/universe/autoware.universe/planning/behavior_path_planner/autoware_behavior_path_lane_change_module/images/lane_change-enable_collision_check_at_prepare_phase.png
2.1M    src/universe/autoware.universe/perception/traffic_light_visualization/images/roi-visualization.png
2.1M    src/universe/autoware.universe/docs/assets/images/autoware_universe_front.png
2.0M    src/universe/autoware.universe/perception/occupancy_grid_map_outlier_filter/image/occupancy_grid_map_outlier_filter.drawio.svg
2.0M    src/universe/autoware.universe/perception/ground_segmentation/test/data/test.pcd
1.7M    src/universe/autoware.universe/planning/behavior_path_planner/autoware_behavior_path_static_obstacle_avoidance_module/images/how_to_decide_path_shape_multi_object_one_direction.drawio.svg
1.7M    src/universe/autoware.universe/planning/behavior_path_planner/autoware_behavior_path_static_obstacle_avoidance_module/images/how_to_decide_path_shape_multi_object_both_direction.drawio.svg
1.6M    src/universe/autoware.universe/planning/behavior_path_planner/autoware_behavior_path_goal_planner_module/images/goal_planner-threads.drawio.svg
1.6M    src/universe/autoware.universe/perception/traffic_light_map_based_detector/docs/traffic_light_map_based_detector_result.svg
1.5M    src/universe/autoware.universe/localization/autoware_landmark_based_localizer/doc_image/principle.png
1.5M    src/universe/autoware.universe/localization/autoware_landmark_based_localizer/autoware_ar_tag_based_localizer/doc_image/sample_result_in_awsim.png
1.4M    src/universe/autoware.universe/planning/behavior_path_planner/autoware_behavior_path_planner/image/limitations/limitation-chattering_shifts.png
1.4M    src/universe/autoware.universe/planning/behavior_path_planner/autoware_behavior_path_goal_planner_module/images/goal_planner-refined_goal.drawio.svg
1.4M    src/universe/autoware.universe/planning/behavior_path_planner/autoware_behavior_path_goal_planner_module/images/goal_planner-goal_distance.drawio.svg
1.4M    src/universe/autoware.universe/planning/behavior_path_planner/autoware_behavior_path_goal_planner_module/images/goal_planner-goal_candidates.drawio.svg
1.4M    src/universe/autoware.universe/planning/behavior_path_planner/autoware_behavior_path_goal_planner_module/images/goal_planner-collision_check_margin.drawio.svg
1.3M    src/universe/autoware.universe/planning/behavior_path_planner/autoware_behavior_path_goal_planner_module/images/goal_planner-safety_check.drawio.svg
1.3M    src/universe/autoware.universe/planning/behavior_path_planner/autoware_behavior_path_goal_planner_module/images/goal_planner-object_to_avoid.drawio.svg
1.3M    src/universe/autoware.universe/planning/behavior_path_planner/autoware_behavior_path_goal_planner_module/images/goal_planner-longitudinal_margin.drawio.svg
1.3M    src/universe/autoware.universe/planning/behavior_path_planner/autoware_behavior_path_goal_planner_module/images/goal_planner-is_safe.drawio.svg
1.3M    src/universe/autoware.universe/planning/behavior_path_planner/autoware_behavior_path_goal_planner_module/images/goal_planner-deciding_path.drawio.svg
1.3M    src/universe/autoware.universe/control/autoware_smart_mpc_trajectory_follower/images/autoware_smart_mpc.png
1.2M    src/universe/autoware.universe/tools/reaction_analyzer/media/sc2-awsim.png
1.2M    src/universe/autoware.universe/tools/reaction_analyzer/media/sc1-awsim.png
1.1M    src/universe/external/ndt_omp/data/251371071.pcd
1.1M    src/universe/external/ndt_omp/data/251370668.pcd
1016K   src/universe/external/muSSP/muSSP/cmake-build-debug/muSSP
1004K   src/universe/autoware.universe/planning/behavior_velocity_planner/autoware_behavior_velocity_run_out_module/docs/create_dynamic_obstacle.svg
...

@youtalk youtalk force-pushed the upstream-update-dockerignore branch from efb731c to a4bca27 Compare July 18, 2024 12:09
@oguzkaganozt
Copy link
Contributor

Looking good @youtalk, but the caching needs to be tested after this merged. Thanks !

@xmfcx xmfcx added the tag:run-health-check Run health-check label Jul 18, 2024
@youtalk youtalk changed the title feat(.dockerignore): Revise .dockerignore to correctly ignore copying unrelated files feat(.dockerignore): revise .dockerignore to correctly ignore copying unrelated files Jul 18, 2024
@youtalk youtalk marked this pull request as ready for review July 18, 2024 21:12
@youtalk
Copy link
Member Author

youtalk commented Jul 18, 2024

The first time of the docker-build-and-push was finally success. https://github.com/autowarefoundation/autoware/actions/runs/9991232729
The second one is also being executed to make sure.
https://github.com/autowarefoundation/autoware/actions/runs/9998728294

The autoware-universe and devel image sizes are significantly slimming up by more than 1.5GB!
https://autowarefoundation.github.io/autoware-ci-metrics/
Screenshot from 2024-07-19 06-15-31

@oguzkaganozt It's time to review please.

@youtalk
Copy link
Member Author

youtalk commented Jul 18, 2024

@xmfcx Please review this too. The heal-check was success in this case.

@xmfcx
Copy link
Contributor

xmfcx commented Jul 18, 2024

https://github.com/autowarefoundation/autoware/actions/runs/9998715168/job/27638240438?pr=5009#step:5:779

colcon build command on cuda version was cached and not executed. Is this normal?

Shouldn't it actually build it?

And non-cuda version is still building https://github.com/autowarefoundation/autoware/actions/runs/9998715168/job/27638240136?pr=5009

@xmfcx
Copy link
Contributor

xmfcx commented Jul 18, 2024

image

feels suspicious 🤔

@youtalk
Copy link
Member Author

youtalk commented Jul 18, 2024

The layer cache of the docker build is now functioning correctly. Previously, the .git directory of all repositories under src was unintentionally being copied, causing the layer hash to change and triggering a rebuild whenever src was copied. I think this was due to some files under the .git directory having their hashes changed just by running git clone.

However, since this PR, .git is now ignored, preventing the unintentional copying of such files, and thus the layer cache works properly. The health-check's cuda job finished instantly because all layers utilized the build cache. On the other hand, the no-cuda job likely reran colcon build because the hash of some copied files changed.

This behavior is intentional for me, as stated in the PR description.

In addition, since .dockerignore has been properly configured, I believe that executing the COPY command will allow the layer cache to function correctly.

@xmfcx
Copy link
Contributor

xmfcx commented Jul 18, 2024

On the other hand, the no-cuda job likely reran colcon build because the hash of some copied files changed.

But how can no-cuda job run again while cuda job is cached?

Same hashes should affect both of them.

Maybe it was cached here: https://github.com/autowarefoundation/autoware/actions/runs/9998728294/job/27638271926

Anyway, let's merge and see, thank you!

@xmfcx xmfcx merged commit eac84a4 into main Jul 18, 2024
20 of 21 checks passed
@xmfcx xmfcx deleted the upstream-update-dockerignore branch July 18, 2024 21:54
@youtalk
Copy link
Member Author

youtalk commented Jul 18, 2024

@xmfcx The build cache is different between cuda and no-cuda jobs. That's why their behaviors can be different.
https://github.com/autowarefoundation/autoware/pkgs/container/autoware-buildcache

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tag:run-health-check Run health-check type:containers Docker containers, containerization of components, or container orchestration.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants