If we get an error we'll only hold the deploy lock if it occurs while trying to switch the running containers. We'll also move tagging the latest image from when the image is pulled to just before the container switch. This ensures that earlier errors don't leave the hosts with an updated latest tag while still running the older version.
57 lines
1.2 KiB
Ruby
57 lines
1.2 KiB
Ruby
class Mrsk::Commands::Builder::Base < Mrsk::Commands::Base
|
|
delegate :argumentize, to: Mrsk::Utils
|
|
|
|
def clean
|
|
docker :image, :rm, "--force", config.absolute_image
|
|
end
|
|
|
|
def pull
|
|
docker :pull, config.absolute_image
|
|
end
|
|
|
|
def build_options
|
|
[ *build_tags, *build_labels, *build_args, *build_secrets, *build_dockerfile ]
|
|
end
|
|
|
|
def build_context
|
|
context
|
|
end
|
|
|
|
private
|
|
def build_tags
|
|
[ "-t", config.absolute_image, "-t", config.latest_image ]
|
|
end
|
|
|
|
def build_labels
|
|
argumentize "--label", { service: config.service }
|
|
end
|
|
|
|
def build_args
|
|
argumentize "--build-arg", args, sensitive: true
|
|
end
|
|
|
|
def build_secrets
|
|
argumentize "--secret", secrets.collect { |secret| [ "id", secret ] }
|
|
end
|
|
|
|
def build_dockerfile
|
|
argumentize "--file", dockerfile
|
|
end
|
|
|
|
def args
|
|
(config.builder && config.builder["args"]) || {}
|
|
end
|
|
|
|
def secrets
|
|
(config.builder && config.builder["secrets"]) || []
|
|
end
|
|
|
|
def dockerfile
|
|
(config.builder && config.builder["dockerfile"]) || "Dockerfile"
|
|
end
|
|
|
|
def context
|
|
(config.builder && config.builder["context"]) || "."
|
|
end
|
|
end
|