Skip to content

Improve docker build performance#5578

Merged
Warashi merged 2 commits intomasterfrom
improve-docker-build-perf-pipecd
Feb 18, 2025
Merged

Improve docker build performance#5578
Warashi merged 2 commits intomasterfrom
improve-docker-build-perf-pipecd

Conversation

@Warashi
Copy link
Member

@Warashi Warashi commented Feb 17, 2025

What this PR does:

  • Use --platform=$BUILDPLATFORM flag to build web static assets in a docker multi-stage build
  • Use docker build cache from the latest image in GitHub Actions Workflow

Why we need it:

  • I want to reduce CI build time

Which issue(s) this PR fixes:

Fixes #

Does this PR introduce a user-facing change?:

  • How are users affected by this change:
  • Is this breaking change:
  • How to migrate (if breaking change):

Signed-off-by: Shinnosuke Sawada-Dazai <shin@warashi.dev>
Signed-off-by: Shinnosuke Sawada-Dazai <shin@warashi.dev>
Comment on lines +3 to +4
# because this stage builds only web assets, we can use any platform
FROM --platform=$BUILDPLATFORM node:18.20.5-alpine3.21 AS web
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this modification, we can now use node 20 or later. I want to discuss whether we should upgrade this to current LTS versions.

@Warashi Warashi marked this pull request as ready for review February 17, 2025 06:54
@codecov
Copy link

codecov bot commented Feb 17, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 26.34%. Comparing base (14f3d0b) to head (0a065cd).
Report is 259 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #5578   +/-   ##
=======================================
  Coverage   26.33%   26.34%           
=======================================
  Files         467      467           
  Lines       50114    50114           
=======================================
+ Hits        13198    13202    +4     
+ Misses      35860    35857    -3     
+ Partials     1056     1055    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@khanhtc1202 khanhtc1202 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice improvement 👍

platforms: linux/amd64,linux/arm64
# parameter to use inline cache. ref; https://docs.docker.com/build/ci/github-actions/cache/#inline-cache
cache-from: type=registry,ref=${{ env.REGISTRY }}/pipe-cd/${{ matrix.image }}:latest
cache-to: type=inline
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[IMO] How about adding mode=max ?
It seems that we can cache all layer with it.
https://docs.docker.com/build/cache/backends/#cache-mode

It might be more efficient because our images are often built with mutl-stage build to download dependencies.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, the inline cache doesn't support the max cache mode.

However, note that the inline cache exporter only supports min cache mode.

ref; https://docs.docker.com/build/ci/github-actions/cache/#inline-cache

We can consider using the GitHub cache, but it's experimental yet. So, I want to start by using inline cache and min cache mode.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got it. Thanks!

@Warashi Warashi requested a review from ffjlabo February 18, 2025 04:53
@Warashi Warashi merged commit 9bfc827 into master Feb 18, 2025
18 checks passed
@Warashi Warashi deleted the improve-docker-build-perf-pipecd branch February 18, 2025 04:55
@github-actions github-actions bot mentioned this pull request Mar 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants