Github action how to cache builds to speed up deploys #332
Replies: 4 comments 12 replies
-
@adrienpoly To fix this, you can try setting up the builder before using it in the build step. Here's an updated version of your workflow that includes the builder setup and some changes to caching setup:
|
Beta Was this translation helpful? Give feedback.
-
I recommend you to remove the line bundler-cache: true in the Ruby setup, this causes it to install all the gems of the project unnecessarily, consuming a lot of time |
Beta Was this translation helpful? Give feedback.
-
BTW, were you able to do it? I haven't yet |
Beta Was this translation helpful? Give feedback.
-
@igor-alexandrov I'm trying to setup GHA cache. I followed your PR for kamal and I'm a bit confused.
and in GHA workflow:
I'm not seeing anything cached. Is there anything more needed to be done? |
Beta Was this translation helpful? Give feedback.
-
Thanks for pointing me in the correct direction to get a working Github action to run Mrsk and deploy an app once the code is pushed.
here is what I came up with as a working solution
Performances
It does work but it takes 25 minutes to build and deploy. It is expected as the runner doesn't have any built image locally so it needs to rebuild everything every time.
I tried several ways to pull first the docker image locally but with no success
here is one of my last try
here are some parts of the deploy log if it may help
Acquiring the deploy lock... Log into image registry... INFO [28d814e5] Running docker login -u [REDACTED] -p [REDACTED] as runner@localhost INFO [28d814e5] Finished in 0.111 seconds with exit status 0 (successful). INFO [aa09302c] Running docker login -u [REDACTED] -p [REDACTED] on 5.75.232.156 INFO [aa09302c] Finished in 6.[10](https://github.com/adrienpoly/rails_mrsk_hetzner/actions/runs/5256530839/jobs/9497990412#step:9:11)5 seconds with exit status 0 (successful). Build and push app image... INFO [95f00bef] Running docker --version && docker buildx version as runner@localhost INFO [95f00bef] Finished in 0.086 seconds with exit status 0 (successful). INFO [388f76c1] Running docker buildx build --push --platform linux/amd64,linux/arm64 --builder mrsk-rails_hetzner_mrsk-multiarch -t adrienpoly/rails_hetzner_mrsk:b442e8f9e083d54e31ff909106c3462892081c1e_uncommitted_17a9289aefbe396a -t adrienpoly/rails_hetzner_mrsk:latest --label service="rails_hetzner_mrsk" --file Dockerfile . as runner@localhost DEBUG [388f76c1] Command: docker buildx build --push --platform linux/amd64,linux/arm64 --builder mrsk-rails_hetzner_mrsk-multiarch -t adrienpoly/rails_hetzner_mrsk:b442e8f9e083d54e31ff909106c3462892081c1e_uncommitted_17a9289aefbe396a -t adrienpoly/rails_hetzner_mrsk:latest --label service="rails_hetzner_mrsk" --file Dockerfile . DEBUG [388f76c1] ERROR: no builder "mrsk-rails_hetzner_mrsk-multiarch" found ERROR Missing compatible builder, so creating a new one first INFO [a31e2f0e] Running docker buildx create --use --name mrsk-rails_hetzner_mrsk-multiarch as runner@localhost INFO [a31e2f0e] Finished in 0.077 seconds with exit status 0 (successful). INFO [8d62723e] Running docker buildx build --push --platform linux/amd64,linux/arm64 --builder mrsk-rails_hetzner_mrsk-multiarch -t adrienpoly/rails_hetzner_mrsk:b442e8f9e083d54e31ff909106c3462892081c1e_uncommitted_17a9289aefbe396a -t adrienpoly/rails_hetzner_mrsk:latest --label service="rails_hetzner_mrsk" --file Dockerfile . as runner@localhost DEBUG [8d62723e] Command: docker buildx build --push --platform linux/amd64,linux/arm64 --builder mrsk-rails_hetzner_mrsk-multiarch -t adrienpoly/rails_hetzner_mrsk:b442e8f9e083d54e31ff909106c3462892081c1e_uncommitted_17a9289aefbe396a -t adrienpoly/rails_hetzner_mrsk:latest --label service="rails_hetzner_mrsk" --file Dockerfile . DEBUG [8d62723e] #1 [internal] booting buildkit DEBUG [8d62723e] #1 pulling image moby/buildkit:buildx-stable-1 DEBUG [8d62723e] #1 pulling image moby/buildkit:buildx-stable-1 0.2s done DEBUG [8d62723e] #1 creating container buildx_buildkit_mrsk-rails_hetzner_mrsk-multiarch0 DEBUG [8d62723e] #1 creating container buildx_buildkit_mrsk-rails_hetzner_mrsk-multiarch0 0.6s done DEBUG [8d62723e] #1 DONE 0.7s DEBUG [8d62723e] DEBUG [8d62723e] #2 [internal] load .dockerignore DEBUG [8d62723e] #2 transferring context: 756B done DEBUG [8d62723e] #2 DONE 0.0s DEBUG [8d62723e] DEBUG [8d62723e] #3 [internal] load build definition from Dockerfile DEBUG [8d62723e] #3 transferring dockerfile: 2.42kB done DEBUG [8d62723e] #3 DONE 0.0s DEBUG [8d62723e] DEBUG [8d62723e] #4 [auth] docker/dockerfile:pull token for registry-1.docker.io DEBUG [8d62723e] #4 DONE 0.0s DEBUG [8d62723e] DEBUG [8d62723e] #5 resolve image config for docker.io/docker/dockerfile:1 DEBUG [8d62723e] #5 DONE 0.3s DEBUG [8d62723e] DEBUG [8d62723e] #6 docker-image://docker.io/docker/dockerfile:1@sha256:39b85bbfa7536a5feceb7372a0817649ecb2724562a38360f4d6a7782a409b14 DEBUG [8d62723e] #6 resolve docker.io/docker/dockerfile:1@sha256:39b85bbfa7536a5feceb7372a0817649ecb2724562a38360f4d6a7782a409b14 done DEBUG [8d62723e] #6 sha256:a47ff7046597eea0123ea02817165350e3680f75000dc5d69c9a310258e1bedd [11](https://github.com/adrienpoly/rails_mrsk_hetzner/actions/runs/5256530839/jobs/9497990412#step:9:12).55MB / 11.55MB 0.1s done DEBUG [8d62723e] #6 extracting sha256:a47ff7046597eea0[12](https://github.com/adrienpoly/rails_mrsk_hetzner/actions/runs/5256530839/jobs/9497990412#step:9:13)3ea02817165350e3680f75000dc5d69c9a310258e1bedd DEBUG [8d62723e] #6 extracting sha256:a47ff7046597eea0123ea02817165350e3680f75000dc5d69c9a310258e1bedd 0.2s done DEBUG [8d62723e] #6 DONE 0.3s DEBUG [8d62723e] DEBUG [8d62723e] #7 [linux/arm64 internal] load metadata for registry.docker.com/library/ruby:3.2.0-slim DEBUG [8d62723e] #7 DONE 0.9s DEBUG [8d62723e] DEBUG [8d62723e] #8 [linux/amd64 internal] load metadata for registry.docker.com/library/ruby:3.2.0-slim DEBUG [8d62723e] #8 DONE 0.8s DEBUG [8d62723e] DEBUG [8d62723e] #9 [linux/arm64 base 1/2] FROM registry.docker.com/library/ruby:3.2.0-slim@sha256:f2f2747508c05c6e0b21fc015ef7f0f577e6f644ffc450350d67b85995c23dd5 DEBUG [8d62723e] #9 resolve registry.docker.com/library/ruby:3.2.0-slim@sha256:f2f2747508c05c6e0b21fc015ef7f0f577e6f644ffc450350d67b85995c23dd5 done DEBUG [8d62723e] #9 DONE 0.1s DEBUG [8d62723e] DEBUG [8d62723e] #10 [linux/amd64 base 1/2] FROM registry.docker.com/library/ruby:3.2.0-slim@sha256:f2f2747508c05c6e0b21fc015ef7f0f577e6f644ffc450350d67b85995c23dd5 DEBUG [8d62723e] #10 resolve registry.docker.com/library/ruby:3.2.0-slim@sha256:f2f2747508c05c6e0b21fc015ef7f0f577e6f644ffc450350d67b85995c23dd5 done DEBUG [8d62723e] #10 sha256:7873f7dff942e7a1e87fc00297fd425cb6b865803d65e1b9749ff1734080c74e 176B / 176B 0.0s done DEBUG [8d62723e] #10 sha256:defb9747fcb73c78c26f4e85993c9791b035f4abe963ba7a0b1cc098fe1f123f 199B / 199B 0.0s done DEBUG [8d62723e] #10 sha256:a7e1c[14](https://github.com/adrienpoly/rails_mrsk_hetzner/actions/runs/5256530839/jobs/9497990412#step:9:15)5a86dfd6fe469fbc03d2368238db8dc024249ac6f25441ea2b10fa250 10.49MB / 34.56MB 0.2s DEBUG [8d62723e] #10 sha256:a7e1c145a86dfd6fe469fbc03d2368238db8dc024249ac6f25441ea2b10fa250 26.21MB / 34.56MB 0.3s DEBUG [8d62723e] #10 sha256:6a518007828d6d0dc1fa5ee4cd5318885881db3d8a6eeb9720b[15](https://github.com/adrienpoly/rails_mrsk_hetzner/actions/runs/5256530839/jobs/9497990412#step:9:16)6c740733e50 9.44MB / 10.02MB 0.2s DEBUG [8d62723e] #10 sha256:a7e1c145a86dfd6fe469fbc03d2368238db8dc024249ac6f25441ea2b10fa250 34.56MB / 34.56MB 0.5s DEBUG [8d62723e] #10 sha256:6a518007828d6d0dc1fa5ee4cd5318885881db3d8a6eeb9720b156c740733e50 10.02MB / 10.02MB 0.2s done DEBUG [8d62723e] #10 sha256:a7e1c145a86dfd6fe469fbc03d2368238db8dc024249ac6f25441ea2b10fa250 34.56MB / 34.56MB 0.5s done DEBUG [8d62723e] #10 sha256:01b5b2efb836d74b8b49da819514eca52e25290d[16](https://github.com/adrienpoly/rails_mrsk_hetzner/actions/runs/5256530839/jobs/9497990412#step:9:17)88db59420ffb9c6b65a03c 15.73MB / 31.40MB 0.2s DEBUG [8d62723e] #10 sha256:01b5b2efb836d74b8b49da819514eca52e25290d1688db59420ffb9c6b65a03c 31.40MB / 31.40MB 0.3s done DEBUG [8d62723e] #10 extracting sha256:01b5b2efb836d74b8b49da819514eca52e25290d1688db59420ffb9c6b65a03c DEBUG [8d62723e] #10 extracting sha256:01b5b2efb836d74b8b49da819514eca52e25290d1688db59420ffb9c6b65a03c 2.7s done DEBUG [8d62723e] #10 extracting sha256:6a5[18](https://github.com/adrienpoly/rails_mrsk_hetzner/actions/runs/5256530839/jobs/9497990412#step:9:19)007828d6d0dc1fa5ee4cd5318885881db3d8a6eeb97[20](https://github.com/adrienpoly/rails_mrsk_hetzner/actions/runs/5256530839/jobs/9497990412#step:9:21)b156c740733e50 DEBUG [8d627[23](https://github.com/adrienpoly/rails_mrsk_hetzner/actions/runs/5256530839/jobs/9497990412#step:9:24)e] #10 extracting sha256:6a518007828d6d0dc1fa5ee4cd5318885881db3d8a6eeb9720b156c740733e50 1.4s done DEBUG [8d62723e] #10 extracting sha256:defb9747fcb73c78c26f4e85993c9791b035f4abe963ba7a0b1cc098fe1f123f 0.0s done DEBUG [8d62723e] #10 extracting sha256:a7e1c145a86dfd6fe469fbc03d2368238db8dc0[24](https://github.com/adrienpoly/rails_mrsk_hetzner/actions/runs/5256530839/jobs/9497990412#step:9:25)249ac6f[25](https://github.com/adrienpoly/rails_mrsk_hetzner/actions/runs/5256530839/jobs/9497990412#step:9:26)441ea2b10fa250 DEBUG [8d6[27](https://github.com/adrienpoly/rails_mrsk_hetzner/actions/runs/5256530839/jobs/9497990412#step:9:28)23e] #10 ...Beta Was this translation helpful? Give feedback.
All reactions