kamal icon indicating copy to clipboard operation
kamal copied to clipboard

Dont build image if it has already been pushed

Open npezza93 opened this issue 1 year ago • 6 comments

This is useful when you push a branch to different environments at separate times from CI. It's also useful if you have CI setup to deploy main but have a concurrency key setup. If you push quickly youll end up deploying the same commit twice and the second time the image doesnt need to be built since it already exists.

npezza93 avatar Jul 15 '24 15:07 npezza93

@djmb How does the registry work in tests?

npezza93 avatar Jul 15 '24 16:07 npezza93

@npezza93 - the integration tests use docker compose to set up a few containers:

  1. A shared container that contains files needed across other containers (ssh keys)
  2. A deployment container we will run kamal from
  3. Some "host" containers to deploy to
  4. A container running an nginx load balancer pointing to the host containers
  5. A docker registry

This creates a mini environment we can deploy to and access the hosts from.

The docker registry is running in insecure mode. Any images that we are going to pull from docker hub (e.g. the nginx one) are copied across once and retagged to be pulled from the local registry. This is because otherwise you can hit docker hub rate limits pretty quickly if you are running the tests a lot.

djmb avatar Aug 26 '24 10:08 djmb

The test failure looks like some transient Docker issue.

@npezza93 - this change makes sense, but the one issue with it is that the pre-build hook will be skipped if you don't have to build the image. While that's probably the right thing to do, there may be people who are doing things they want to happen on every deployment in that hook.

As such I think we'll wait to add this to the 2.0 release (which should be happening fairly soon) and include it in the upgrade notes.

djmb avatar Aug 26 '24 10:08 djmb

@djmb Sounds good! Thanks for the info. Decided to just stub the call to manifest to force it to always be false which looks to have resolved the test failures.

npezza93 avatar Aug 26 '24 16:08 npezza93

Good call @djmb. Should be fixed now!

npezza93 avatar Sep 11 '24 13:09 npezza93

An interesting use case here could be building the image outside kamal, but then using kamal to deploy that image.

iloveitaly avatar Nov 08 '24 20:11 iloveitaly