basecamp / kamal

Deploy web apps anywhere.
https://kamal-deploy.org
MIT License
9.39k stars 359 forks source link

Build from within a git clone by default #798

Closed djmb closed 1 month ago

djmb commented 1 month ago

Docker does not respect the .dockerignore file when building from a tar. See https://github.com/docker/buildx/issues/2353.

Thanks to @jpdombrowski for pointing this out in https://github.com/basecamp/kamal/pull/700.

Instead by default we'll make a local clone into a tmp directory and build from there. Subsequent builds will reset the clone to match the checkout.

Compared to building directly in the repo, we'll have more reproducible builds and avoid accidentally including local changes.

Compared to using a git archive:

  1. .dockerignore is respected
  2. We'll have faster builds - docker can be smarter about caching the build context on subsequent builds from a directory

To build from the repo directly, set the build context to "." in the config.

If there are uncommitted changes, we'll warn about them either being included or ignored depending on whether we build from the clone.