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(ci): enable Docker build cache to 5 times faster container build #4730

Merged
merged 36 commits into from
May 25, 2024

Conversation

youtalk
Copy link
Member

@youtalk youtalk commented May 16, 2024

Description

This PR introduces the Docker build cache.
https://docs.docker.com/build/cache/

I uses max cache mode so that the all layers are cached even those of intermediate steps.
https://docs.docker.com/build/cache/backends/#cache-mode

Tests performed

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.

Signed-off-by: Yutaka Kondo <[email protected]>
Signed-off-by: Yutaka Kondo <[email protected]>
@youtalk youtalk marked this pull request as ready for review May 17, 2024 03:03
@youtalk youtalk requested a review from oguzkaganozt May 17, 2024 03:03
@youtalk youtalk changed the title feat(ci): enable Docker build cache feat(ci): enable Docker build cache to 5 times faster container build May 17, 2024
@mitsudome-r
Copy link
Member

I have a question regarding how Docker build cache works.

In Autoware's Docker file, there are commands like vcs import < autoware.repos. For this command, the file autoware.repos won't change, but the main branch of the repositories that are imported with vcs might change from the previous docker build.

Would docker build cache still able to detect such change?

@youtalk
Copy link
Member Author

youtalk commented May 17, 2024

It's a good point of view. I'm investigating the fact and please wait a while.

@youtalk
Copy link
Member Author

youtalk commented May 20, 2024

@mitsudome-r I've fixed the vcs import problem by #4738.
Please review it again.

@youtalk youtalk self-assigned this May 20, 2024
@youtalk youtalk added the type:ci Continuous Integration (CI) processes and testing. label May 20, 2024
@oguzkaganozt
Copy link
Contributor

After merging this PR, we should test this branch with docker-build-and-push to see the actual caching. See

Base automatically changed from upstream-vcs-import-outside-dockerfile to main May 23, 2024 04:27
@youtalk
Copy link
Member Author

youtalk commented May 23, 2024

I've merged the latest main branch 9d899e8 and am testing the docker-build-and-push-main: https://github.com/autowarefoundation/autoware/actions/runs/9202286332

@youtalk
Copy link
Member Author

youtalk commented May 23, 2024

Unfortunately cuda was failed due to the disk full problem again. We must fundamentally fix this problem.

@youtalk
Copy link
Member Author

youtalk commented May 23, 2024

To resolve the problem I'm checking the removal of --download-artifacts to diet the image size.
https://github.com/autowarefoundation/autoware/tree/upstream-disable-download-artifacts
https://github.com/autowarefoundation/autoware/actions/runs/9208339027

@xmfcx
Copy link
Contributor

xmfcx commented May 23, 2024

How are we filling up the disk space? We have 54GB of space to work with 😯

Could you add:

      - name: Show disk space
        run: |
          df -h

To some key places in https://github.com/autowarefoundation/autoware/blob/main/.github/actions/docker-build-and-push/action.yaml file so we know when it is filling up?

@youtalk
Copy link
Member Author

youtalk commented May 23, 2024

I think the exporting to docker image format consumes temporarily lots of disk space. https://github.com/autowarefoundation/autoware/actions/runs/9202286332/job/25311862778#step:7:16211

#62 [prebuilt] exporting cache to registry
#62 writing layer sha256:ddb6f24d072dea4bb47d142b42a63cf859b9f4b3465cdc8d7a969a16a0d41ce0 0.2s done
#62 writing layer sha256:e4421d97df0323dadf48afbce56f12c3ba90temporalilya5bf89b3c2fe15d7d020a3b641ff
#62 preparing build cache for export 136.2s done
#62 writing layer sha256:e4421d97df0323dadf48afbce56f12c3ba90a5bf89b3c2fe15d7d020a3b641ff 0.0s done
#62 writing layer sha256:e7aa205a7d8d546c887dbbee409f2270ce7a415f2b4562bc567a457af4c05156 0.1s done
#62 CANCELED

#61 [devel] exporting to docker image format
#61 sending tarball 60.1s done
#61 ERROR: failed to copy to tar: rpc error: code = Unknown desc = write /tmp/devel.tar: no space left on device

#58 [runtime] exporting to docker image format
#58 exporting layers 294.6s done
#58 CANCELED
------
 > [devel] exporting to docker image format:
------
ERROR: failed to solve: failed to copy to tar: rpc error: code = Unknown desc = write /tmp/devel.tar: no space left on device
Error: buildx bake failed with: ERROR: failed to solve: failed to copy to tar: rpc error: code = Unknown desc = write /tmp/devel.tar: no space left on device

Once this problem occurs, subsequent actions are interrupted, so there is an issue where the disk size cannot be checked.

Signed-off-by: Yutaka Kondo <[email protected]>
Signed-off-by: Yutaka Kondo <[email protected]>
Signed-off-by: Yutaka Kondo <[email protected]>
Signed-off-by: Yutaka Kondo <[email protected]>
Signed-off-by: Yutaka Kondo <[email protected]>
Signed-off-by: Yutaka Kondo <[email protected]>
Signed-off-by: Yutaka Kondo <[email protected]>
@youtalk youtalk changed the base branch from main to upstream-disable-download-artifacts May 24, 2024 13:54
Base automatically changed from upstream-disable-download-artifacts to main May 24, 2024 22:20
@youtalk
Copy link
Member Author

youtalk commented May 24, 2024

Finally we did it! https://github.com/autowarefoundation/autoware/actions/runs/9225112277
Let's merge and build faster ever!

@youtalk youtalk enabled auto-merge (squash) May 24, 2024 23:59
@youtalk youtalk merged commit ab8bbf5 into main May 25, 2024
12 of 13 checks passed
@youtalk youtalk deleted the introduce-cache-from-to branch May 25, 2024 00:29
youtalk added a commit to youtalk/autoware that referenced this pull request May 31, 2024
* chore(docker): separate `rosdep install` and `colcon build` RUN commands (autowarefoundation#4719)

* refactor(ci): reuse `load-env.yaml` to load env (autowarefoundation#4734)

* reuse load-env.yaml to load env

* update base_image

Signed-off-by: Yutaka Kondo <[email protected]>

* fix base_image

Signed-off-by: Yutaka Kondo <[email protected]>

---------

Signed-off-by: Yutaka Kondo <[email protected]>

* refactor(docker): introduce `src-imported` stage (autowarefoundation#4712)

* introduce src-imported stage

Signed-off-by: Yutaka Kondo <[email protected]>

* empty

Signed-off-by: Yutaka Kondo <[email protected]>

* generate install package lists

* append || true

Signed-off-by: Yutaka Kondo <[email protected]>

* cat packages

Signed-off-by: Yutaka Kondo <[email protected]>

* chore(docker): separate `rosdep install` and `colcon build` RUN commands (autowarefoundation#4719)

* wip

Signed-off-by: Yutaka Kondo <[email protected]>

* wip

Signed-off-by: Yutaka Kondo <[email protected]>

* Update Dockerfile

* Update Dockerfile

* install pacmod

* rename

* Revert "install pacmod"

This reverts commit ebff10f.

* install pacmod3

* register pamod3 repos

* ignore hadolint

* revert

* run set-dev-env.sh

* pip install

* copy

* rosdep update

---------

Signed-off-by: Yutaka Kondo <[email protected]>

* feat(docker): install minimum packages in `base` stage (autowarefoundation#4751)

* install ssh only and copy only once

Signed-off-by: Yutaka Kondo <[email protected]>

* install gosu

Signed-off-by: Yutaka Kondo <[email protected]>

* fix dir

Signed-off-by: Yutaka Kondo <[email protected]>

* revert ansible

Signed-off-by: Yutaka Kondo <[email protected]>

---------

Signed-off-by: Yutaka Kondo <[email protected]>

* chore: add discussion templates for general category (autowarefoundation#4764)

Signed-off-by: Ryohsuke Mitsudome <[email protected]>

* feat(ci,docker): change `vcs import` to `COPY src` (autowarefoundation#4738)

* introduce src-imported stage

Signed-off-by: Yutaka Kondo <[email protected]>

* empty

Signed-off-by: Yutaka Kondo <[email protected]>

* generate install package lists

* append || true

Signed-off-by: Yutaka Kondo <[email protected]>

* cat packages

Signed-off-by: Yutaka Kondo <[email protected]>

* chore(docker): separate `rosdep install` and `colcon build` RUN commands (autowarefoundation#4719)

* wip

Signed-off-by: Yutaka Kondo <[email protected]>

* wip

Signed-off-by: Yutaka Kondo <[email protected]>

* Update Dockerfile

* Update Dockerfile

* install pacmod

* rename

* Revert "install pacmod"

This reverts commit ebff10f.

* install pacmod3

* register pamod3 repos

* ignore hadolint

* revert

* run set-dev-env.sh

* pip install

* copy

* rosdep update

* vcs import outside dockerfile

Signed-off-by: Yutaka Kondo <[email protected]>

* refine order and remove /autoware/src at last

* fix hadolint

* remove tar files

Signed-off-by: Yutaka Kondo <[email protected]>

* shell: bash

Signed-off-by: Yutaka Kondo <[email protected]>

---------

Signed-off-by: Yutaka Kondo <[email protected]>

* feat(docker,ansible): download artifacts at runtime (autowarefoundation#4771)

* feat(ci): enable Docker build cache to 5 times faster container build (autowarefoundation#4730)

* introduce src-imported stage

Signed-off-by: Yutaka Kondo <[email protected]>

* empty

Signed-off-by: Yutaka Kondo <[email protected]>

* generate install package lists

* append || true

Signed-off-by: Yutaka Kondo <[email protected]>

* cat packages

Signed-off-by: Yutaka Kondo <[email protected]>

* chore(docker): separate `rosdep install` and `colcon build` RUN commands (autowarefoundation#4719)

* wip

Signed-off-by: Yutaka Kondo <[email protected]>

* wip

Signed-off-by: Yutaka Kondo <[email protected]>

* Update Dockerfile

* Update Dockerfile

* install pacmod

* rename

* Revert "install pacmod"

This reverts commit ebff10f.

* install pacmod3

* register pamod3 repos

* ignore hadolint

* revert

* run set-dev-env.sh

* pip install

* copy

* rosdep update

* vcs import outside dockerfile

Signed-off-by: Yutaka Kondo <[email protected]>

* enable docker build cache

Signed-off-by: Yutaka Kondo <[email protected]>

* empty

Signed-off-by: Yutaka Kondo <[email protected]>

* add no-cuda/cuda suffix

Signed-off-by: Yutaka Kondo <[email protected]>

* remove --download-artifacts

Signed-off-by: Yutaka Kondo <[email protected]>

* remove --download-artifacts

Signed-off-by: Yutaka Kondo <[email protected]>

* add --data-path option

Signed-off-by: Yutaka Kondo <[email protected]>

* wip

Signed-off-by: Yutaka Kondo <[email protected]>

* run download_artifacts

Signed-off-by: Yutaka Kondo <[email protected]>

* remove todo

Signed-off-by: Yutaka Kondo <[email protected]>

* revert run

Signed-off-by: Yutaka Kondo <[email protected]>

---------

Signed-off-by: Yutaka Kondo <[email protected]>

* feat(docker): cache `ccache` to the Docker build cache (autowarefoundation#4772)

* fix: add download url of yolox with semantic segmentation header (autowarefoundation#4012)

Signed-off-by: badai-nguyen <[email protected]>

* chore: add error handling for held packages during rmw installation (autowarefoundation#4781)

* chore: add error handling for held packages during apt installation

Signed-off-by: Naophis <[email protected]>

* feat: Add check for held ROS packages during installation

Signed-off-by: Naophis <[email protected]>

---------

Signed-off-by: Naophis <[email protected]>

* refactor(docker,ci): rename `autoware-openadk` to `autoware` and `adkit` to `openadkit` (autowarefoundation#4785)

* rename adkit to openadkit

Signed-off-by: Yutaka Kondo <[email protected]>

* rename autoware-openadkit to autoware

Signed-off-by: Yutaka Kondo <[email protected]>

* fix hcl path

Signed-off-by: Yutaka Kondo <[email protected]>

---------

Signed-off-by: Yutaka Kondo <[email protected]>

* feat(ci): disable `Upload Artifacts` on `docker-build-and-push` action (autowarefoundation#4789)

* remove upload artifact

Signed-off-by: Yutaka Kondo <[email protected]>

* remove build and push

Signed-off-by: Yutaka Kondo <[email protected]>

---------

Signed-off-by: Yutaka Kondo <[email protected]>

* feat(docker): cache apt archives to the Docker build cache (autowarefoundation#4778)

* mount apt cache

Signed-off-by: Yutaka Kondo <[email protected]>

* reorder

Signed-off-by: Yutaka Kondo <[email protected]>

* remove upload artifact

Signed-off-by: Yutaka Kondo <[email protected]>

* remove build and push

Signed-off-by: Yutaka Kondo <[email protected]>

---------

Signed-off-by: Yutaka Kondo <[email protected]>

* chore: update code owners (autowarefoundation#4797)

Signed-off-by: M. Fatih Cırıt <[email protected]>

* ci(pre-commit-ansible): autoupdate (autowarefoundation#4676)

Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions <[email protected]>

* ci: pre-commit autoupdate (autowarefoundation#4670)

[pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/igorshubovych/markdownlint-cli: v0.39.0 → v0.41.0](igorshubovych/markdownlint-cli@v0.39.0...v0.41.0)
- [github.com/AleksaC/hadolint-py: v2.12.1-beta → v2.12.1b3](AleksaC/hadolint-py@v2.12.1-beta...v2.12.1b3)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* ci(pre-commit): autoupdate (autowarefoundation#4662)

Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions <[email protected]>

* ci(pre-commit-optional): autoupdate (autowarefoundation#4766)

Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions <[email protected]>

* fix(ci): run `vsc import` on `build-main` workflows (autowarefoundation#4799)

Signed-off-by: Yutaka Kondo <[email protected]>

---------

Signed-off-by: Yutaka Kondo <[email protected]>
Signed-off-by: Ryohsuke Mitsudome <[email protected]>
Signed-off-by: badai-nguyen <[email protected]>
Signed-off-by: Naophis <[email protected]>
Signed-off-by: M. Fatih Cırıt <[email protected]>
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Ryohsuke Mitsudome <[email protected]>
Co-authored-by: badai nguyen <[email protected]>
Co-authored-by: Naophis <[email protected]>
Co-authored-by: M. Fatih Cırıt <[email protected]>
Co-authored-by: awf-autoware-bot[bot] <94889083+awf-autoware-bot[bot]@users.noreply.github.com>
Co-authored-by: github-actions <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:ci Continuous Integration (CI) processes and testing.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants