rubyvideo icon indicating copy to clipboard operation
rubyvideo copied to clipboard

Optimize deployment time for Kamal workflow

Open adrienpoly opened this issue 1 year ago • 5 comments

We have a GitHub workflow that runs tests and, upon success, deploys the main branch using Kamal.

The deployment process takes about 5 minutes with a warm cache but can extend to 25 minutes with a cold cache (e.g., when gems or the Ruby version need updating).

While this delay might be an inherent limitation of GitHub runners, I’d like to explore ways to optimize the deployment time and improve overall performance.

adrienpoly avatar Nov 09 '24 08:11 adrienpoly

maybe this could help down the road https://github.com/basecamp/kamal/pull/885/files

adrienpoly avatar Nov 09 '24 08:11 adrienpoly

I think this is what you are searching for https://wjwh.eu/posts/2019-02-18-prebuilt-base-image.html. The main problem is that this only helps with gem updates and not with new ruby versions, but updating a ruby version would even be slow with capistrano.

If you want, I can add it. The only problem with this approach is that it add some complexity to the CI. It is up to you to decide if the speed up is worth this complexity.

aronwolf90 avatar Sep 03 '25 21:09 aronwolf90

Another possibility could be to install the gems and npm packages with an entrypoint and mount a volume into the docker container. I am not a big fan of this, because it make things harder to debug.

aronwolf90 avatar Sep 03 '25 21:09 aronwolf90

thanks for your feedback we have made significant improvements since then. It is not perfect but acceptable. Our main issue is that our targets arch are arm where as the Github runners are amd. So the build on the Github runner is very slow.

We are now using a remote builder (the VPS that we use for the staging env). Sometime the build fails (1/20) but beside that it works better and we typically have a build of 4/5 minutes

adrienpoly avatar Sep 03 '25 21:09 adrienpoly

ok, thanks for the fast response.

Just curiosity: I am surprised that the server uses ARM. Is is a Raspberry PI? 😄

aronwolf90 avatar Sep 03 '25 23:09 aronwolf90