Allow for fully native builds too

Skipping multiarch if there's a platform match between dev and prod.
This commit is contained in:
David Heinemeier Hansson
2023-01-13 09:31:47 +01:00
parent 05f1ef5ee8
commit 6ccb3d2319
6 changed files with 129 additions and 56 deletions

View File

@@ -0,0 +1,19 @@
require "mrsk/commands/base"
class Mrsk::Commands::Builder::Multiarch < Mrsk::Commands::Base
def create
docker :buildx, :create, "--use", "--name", "mrsk"
end
def remove
docker :buildx, :rm, "mrsk"
end
def push
docker :buildx, :build, "--push", "--platform linux/amd64,linux/arm64", "-t", config.absolute_image, "."
end
def pull
docker :pull, config.absolute_image
end
end

View File

@@ -0,0 +1,19 @@
require "mrsk/commands/builder/multiarch"
class Mrsk::Commands::Builder::Multiarch::Remote < Mrsk::Commands::Builder::Multiarch
def create(arch)
super + [ "mrsk-#{arch}", "--platform", "linux/#{arch}" ]
end
def append(arch)
docker :buildx, :create, "--append", "--name", "mrsk", "mrsk-#{arch}", "--platform", "linux/#{arch}"
end
def create_context(arch, host)
docker :context, :create, "mrsk-#{arch}", "--description", "'MRSK #{arch} Native Host'", "--docker", "'host=#{host}'"
end
def remove_context(arch)
docker :context, :rm, "mrsk-#{arch}"
end
end

View File

@@ -0,0 +1,19 @@
require "mrsk/commands/base"
class Mrsk::Commands::Builder::Native < Mrsk::Commands::Base
def create
# No op on native
end
def remove
# No op on native
end
def push
docker :build, "--push", "-t", config.absolute_image, "."
end
def pull
docker :pull, config.absolute_image
end
end