Skip to content
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

Simplify builders config #905

Merged
merged 17 commits into from
Aug 29, 2024
Merged

Simplify builders config #905

merged 17 commits into from
Aug 29, 2024

Conversation

djmb
Copy link
Collaborator

@djmb djmb commented Aug 1, 2024

  • Just three builders now, local, remote and hybrid
  • Default to the docker container driver but allow it to be set. No need to infer when we need a "native" builder anymore
  • Specify the arches you want, but not where to build them. If you have a remote builder, Kamal will use it for non-local arches
  • Require that an arch is set, and default to amd64 in the templates
  • Remote is just the connection string now
  • If you have a remote string, but only build for the local arch we'll ignore it
  • Don't include the service in the remote builder name (fixes Duplicate buildkit daemon processes with multi-app deployments #592)
  • Include the remote connection string in the remote builder name, so you don't get clashes when changing remote builders

Examples:

On arm64, build for arm64 locally, amd64 remotely and
on amd64, build for amd64 locally, arm64 remotely:

builder:
  arch:
    - amd64
    - arm64
  remote: ssh://docker@docker-builder

On arm64, build amd64 on remote and on amd64 build locally:

builder:
  arch: amd64
  remote: ssh://docker@docker-builder

Build amd64 on local:

builder:
  arch: amd64

Use docker driver, building for local arch:

builder:
  driver: docker
  arch: <%= uname_m = `uname -m`; uname_m == "x86_64" ? "amd64" : uname_m %>

@djmb djmb force-pushed the simplify-builders-config branch 2 times, most recently from df04cd4 to e1de023 Compare August 28, 2024 10:45
@dhh
Copy link
Member

dhh commented Aug 28, 2024

Much nicer, much simpler. Need to update the Rails default config/deploy.yml when this is released.

djmb and others added 16 commits August 29, 2024 08:44
Combine the two builders, as they are almost identical. The only
difference was whether the platforms were set.

The native cached builder wasn't using the context it created, so now
we do.

We'll set the driver to `docker-container` - it seems to be the default
but the Docker docs claim it is `docker`.
It's just a remote builder, that will build whichever platform is asked
for, so let's remove the "native" part.

We'll also remove the service name from the builder name, so multiple
services can share the same builder.
We already ensure that buildx is installed, so let's always use it.
This ensures we use the docker-container driver and not whatever the
local default is.
Include the host name in the builder name, so we can have one builder
per host/arch across all kamal projects.

Inherit from the remote builder. The difference in the hybrid builder
is that we create a local buildx instance and append the remote context
to it.
The remote host is now encoded in the builder name so we don't need
to check it. We'll just do an inspect to confirm the builder exists.
Remote and local are only allowed when multiarch is enabled.
Remote requires a host and arch, local only requires an arch.
1. Add driver as an option, defaulting to `docker-container`. For a
   "native" build you can set it to `docker`
2. Set arch as a array of architectures to build for, defaulting to
   `[ "amd64", "arm64" ]` unless you are using the docker driver in
   which case we default to not setting a platform
3. Remote is now just a connection string for the remote builder
4. If remote is set, we only use it for non-local arches, if we are
   only building for the local arch, we'll ignore it.

Examples:

On arm64, build for arm64 locally, amd64 remotely or
On amd64, build for amd64 locally, arm64 remotely:

```yaml
builder:
  remote: ssh://docker@docker-builder
```

On arm64, build amd64 on remote,
On amd64 build locally:

```yaml
builder:
  arch:
    - amd64
  remote:
    host: ssh://docker@docker-builder
```

Build amd64 on local:

```yaml
builder:
  arch:
    - amd64
```

Use docker driver, building for local arch:

```yaml
builder:
  driver: docker
```
@djmb djmb merged commit 6adf3c1 into main Aug 29, 2024
9 checks passed
@djmb djmb deleted the simplify-builders-config branch August 29, 2024 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Duplicate buildkit daemon processes with multi-app deployments
2 participants