Building directly from a checkout will pull in uncommitted files to or more sneakily files that are git ignored, but not docker ignored. To avoid this, we'll add an option to build from a git archive of HEAD instead. Docker doesn't provide a way to build directly from a git repo, so instead we create a tarball of the current HEAD with git archive and pipe it into the build command. When building from a git archive, we'll still display the warning about uncommitted changes, but we won't add the `_uncommitted_...` suffix to the container name as they won't be included in the build. Perhaps this should be the default, but we'll leave that decision for now.
18 lines
365 B
Ruby
18 lines
365 B
Ruby
class Kamal::Commands::Builder::Native::Cached < Kamal::Commands::Builder::Native
|
|
def create
|
|
docker :buildx, :create, "--use", "--driver=docker-container"
|
|
end
|
|
|
|
def remove
|
|
docker :buildx, :rm, builder_name
|
|
end
|
|
|
|
private
|
|
def build_and_push
|
|
docker :buildx, :build,
|
|
"--push",
|
|
*build_options,
|
|
build_context
|
|
end
|
|
end
|