Create missing buildx builder if missing automatically
This commit is contained in:
@@ -29,7 +29,7 @@ registry:
|
|||||||
password: real-password
|
password: real-password
|
||||||
```
|
```
|
||||||
|
|
||||||
Now you're ready to deploy a multi-arch image (FIXME: currently you need to manually run `docker buildx create --use` once first):
|
Now you're ready to deploy a multi-arch image:
|
||||||
|
|
||||||
```
|
```
|
||||||
rake mrsk:deploy
|
rake mrsk:deploy
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
class Mrsk::Commands::App < Mrsk::Commands::Base
|
class Mrsk::Commands::App < Mrsk::Commands::Base
|
||||||
def push
|
def push
|
||||||
# TODO: Run 'docker buildx create --use' when needed
|
|
||||||
# TODO: Make multiarch an option so Linux users can enjoy speedier builds
|
|
||||||
docker :buildx, :build, "--push", "--platform linux/amd64,linux/arm64", "-t", config.absolute_image, "."
|
docker :buildx, :build, "--push", "--platform linux/amd64,linux/arm64", "-t", config.absolute_image, "."
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -64,6 +62,10 @@ class Mrsk::Commands::App < Mrsk::Commands::Base
|
|||||||
docker :image, :prune, "-a", "-f", *service_filter
|
docker :image, :prune, "-a", "-f", *service_filter
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def create_new_builder
|
||||||
|
docker :buildx, :create, "--use", "--name", config.service
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def service_filter
|
def service_filter
|
||||||
[ "--filter", "label=service=#{config.service}" ]
|
[ "--filter", "label=service=#{config.service}" ]
|
||||||
|
|||||||
@@ -9,7 +9,15 @@ namespace :mrsk do
|
|||||||
|
|
||||||
desc "Build locally and push app image to registry"
|
desc "Build locally and push app image to registry"
|
||||||
task :push do
|
task :push do
|
||||||
run_locally { execute *app.push } unless ENV["VERSION"]
|
run_locally do
|
||||||
|
begin
|
||||||
|
execute *app.push
|
||||||
|
rescue SSHKit::Command::Failed => e
|
||||||
|
error "Missing compatible buildx builder, so creating a new one first"
|
||||||
|
execute *app.create_new_builder
|
||||||
|
execute *app.push
|
||||||
|
end
|
||||||
|
end unless ENV["VERSION"]
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "Pull app image from the registry onto servers"
|
desc "Pull app image from the registry onto servers"
|
||||||
|
|||||||
Reference in New Issue
Block a user