Extract builder from app

Building is different from running
This commit is contained in:
David Heinemeier Hansson
2023-01-12 18:16:52 +01:00
parent 08c30a14b9
commit b3992973d6
6 changed files with 49 additions and 36 deletions

View File

@@ -1,5 +1,6 @@
require "mrsk/configuration"
require "mrsk/commands/app"
require "mrsk/commands/builder"
require "mrsk/commands/prune"
require "mrsk/commands/traefik"
require "mrsk/commands/registry"
@@ -20,6 +21,10 @@ class Mrsk::Commander
@app ||= Mrsk::Commands::App.new(config)
end
def builder
@builder ||= Mrsk::Commands::Builder.new(config)
end
def traefik
@traefik ||= Mrsk::Commands::Traefik.new(config)
end

View File

@@ -1,14 +1,6 @@
require "mrsk/commands/base"
class Mrsk::Commands::App < Mrsk::Commands::Base
def push
docker :buildx, :build, "--push", "--platform linux/amd64,linux/arm64", "-t", config.absolute_image, "."
end
def pull
docker :pull, config.absolute_image
end
def run(role: :web)
role = config.role(role)
@@ -64,10 +56,6 @@ class Mrsk::Commands::App < Mrsk::Commands::Base
docker :image, :prune, "-a", "-f", *service_filter
end
def create_new_builder
docker :buildx, :create, "--use", "--name", "mrsk"
end
private
def service_filter
[ "--filter", "label=service=#{config.service}" ]

View File

@@ -0,0 +1,15 @@
require "mrsk/commands/base"
class Mrsk::Commands::Builder < Mrsk::Commands::Base
def create
docker :buildx, :create, "--use", "--name", "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