-
Notifications
You must be signed in to change notification settings - Fork 495
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce a "build dev" command #1357
base: main
Are you sure you want to change the base?
Introduce a "build dev" command #1357
Conversation
@flavorjones Does this introduce a different behavior than setting your build context to the current directory with https://kamal-deploy.org/docs/configuration/builders/#build-context |
@nickhammond I'm not sure I understand the question? The idea behind this is to build a one-off container that doesn't get pushed anywhere by running a different command -- without having to write a new config. Part of the behavior is to build with the current directory as context, sure. The different behaviors are described in the description above. Does that answer your question? |
@flavorjones Is the use case to warm the build cache? Or just to verify that your image is building successfully without dealing with the login and push process? It's nice to have the standalone build process but What about |
@nickhammond The use case here is that I want to iterate on the contents of my Dockerfile. In particular, I was running into an issue with packages installed on the base image, so I wanted to quickly run through the process of:
It's possible to build the image with I got some feedback on this PR from my colleagues at 37signals that it could probably be merged into |
@flavorjones Great! It'll be really handy to have that when getting an app going. It has definitely been clunky to maintain a docker build script outside of kamal for testing because of env clear/secrets as you mentioned. |
13a47d0
to
528aa3e
Compare
I've rewritten this PR to decouple the build result export from the dirty working directory features. See the description for a longer explanation. |
2f13b3a
to
74f4eb2
Compare
which controls where the build result is exported. The default value is "registry" to reflect the current behavior of `build push`. Any value provided to this option will be passed to the `buildx build` command as a `--output=type=<VALUE>` flag. For example, the following command will push to the local docker image store: kamal build push --output=docker squash
74f4eb2
to
93644af
Compare
which will build a "dirty" image using the working directory. This command is different from `build push` in two important ways: - the image tags will have a suffix of `-dirty` - the export action is "docker", pushing to the local docker image store The command also supports the `--output` option just added to `build push` to override that default. This command is intended to allow developers to quickly iterate on a docker image built from their local working directory while avoiding any confusion with a pristine image built from a git clone, and keeping those images on the local dev system by default.
93644af
to
2127f17
Compare
Context
The problem I'm trying to solve with this PR is: During the development process, how can a developer iterate quickly on their container?
The primary obstacles to using Kamal to build development images in this way are:
build push
uses the config to determine the build context, and the default is to make a pristine build from a clean git clone. There's no command option override that configuration for a single invocation.build push
will push to the registry every time! For this use case, it's more likely the developer will simply want to push to the local docker image store.A secondary obstacle is the danger of accidentally using a development image (built from the dirty working directory) in production! If we're going to support development images, we should probably tag them explicitly to avoid confusion.
Alternatives considered
It's possible, but not trivial, to build the container in a manner that addresses this use case by running
docker buildx
from the commandline. However, for containers with build steps that require secrets to be injected, this can quickly become very complicated.Proposed solution
I've broken this feature out into two commits.
First, I introduce some flexibility into the
kamal build push
command with an--output
option which allows Kamal users to specify where they would like the build result to be exported. The default value is "registry" to reflect the current behavior ofbuild push
.Any value provided to this option will be passed to the
docker buildx build
command as a--output=type=<VALUE>
flag. For example, the following command will push to the local docker image store:Second, I introduce a new command,
build dev
which is similar tobuild push
but:-dirty
suffixThe command also supports the
--output
option.Other notes
Documentation PR is basecamp/kamal-site#158 (or will be once I update it).