Allow disabling of local builds

To disable local builds set:
```
builder:
   local: false
   remote: ssh://docker@docker-builder
```
This commit is contained in:
Donal McBreen
2024-09-03 14:33:25 +01:00
parent 9b9e60ec7f
commit a2549b1f60
5 changed files with 40 additions and 2 deletions

View File

@@ -28,7 +28,9 @@ class Kamal::Configuration::Builder
end
def local_arches
@local_arches ||= if remote
@local_arches ||= if local_disabled?
[]
elsif remote
arches & [ Kamal::Utils.docker_arch ]
else
arches
@@ -48,7 +50,7 @@ class Kamal::Configuration::Builder
end
def local?
arches.empty? || local_arches.any?
!local_disabled? && (arches.empty? || local_arches.any?)
end
def cached?
@@ -79,6 +81,10 @@ class Kamal::Configuration::Builder
builder_config.fetch("driver", "docker-container")
end
def local_disabled?
builder_config["local"] == false
end
def cache_from
if cached?
case builder_config["cache"]["type"]

View File

@@ -30,6 +30,11 @@ builder:
# If you have a remote builder, you can configure it here
remote: ssh://docker@docker-builder
# Whether to allow local builds
#
# Defaults to true
local: true
# Builder cache
#
# The type must be either 'gha' or 'registry'

View File

@@ -7,5 +7,7 @@ class Kamal::Configuration::Validator::Builder < Kamal::Configuration::Validator
end
error "Builder arch not set" unless config["arch"].present?
error "Cannot disable local builds, no remote is set" if config["local"] == false && config["remote"].blank?
end
end