Merge branch 'main' into global-logging-config
This commit is contained in:
@@ -1,12 +1,19 @@
|
||||
class Mrsk::Commands::App < Mrsk::Commands::Base
|
||||
def run(role: :web)
|
||||
role = config.role(role)
|
||||
attr_reader :role
|
||||
|
||||
def initialize(config, role: nil)
|
||||
super(config)
|
||||
@role = role
|
||||
end
|
||||
|
||||
def run
|
||||
role = config.role(self.role)
|
||||
|
||||
docker :run,
|
||||
"--detach",
|
||||
"--restart unless-stopped",
|
||||
"--name", service_with_version_and_destination,
|
||||
"-e", "MRSK_CONTAINER_NAME=\"#{service_with_version_and_destination}\"",
|
||||
"--name", container_name,
|
||||
"-e", "MRSK_CONTAINER_NAME=\"#{container_name}\"",
|
||||
*role.env_args,
|
||||
*config.logging_args,
|
||||
*config.volume_args,
|
||||
@@ -17,7 +24,7 @@ class Mrsk::Commands::App < Mrsk::Commands::Base
|
||||
end
|
||||
|
||||
def start
|
||||
docker :start, service_with_version_and_destination
|
||||
docker :start, container_name
|
||||
end
|
||||
|
||||
def stop(version: nil)
|
||||
@@ -52,7 +59,7 @@ class Mrsk::Commands::App < Mrsk::Commands::Base
|
||||
def execute_in_existing_container(*command, interactive: false)
|
||||
docker :exec,
|
||||
("-it" if interactive),
|
||||
service_with_version_and_destination,
|
||||
container_name,
|
||||
*command
|
||||
end
|
||||
|
||||
@@ -97,7 +104,7 @@ class Mrsk::Commands::App < Mrsk::Commands::Base
|
||||
|
||||
def remove_container(version:)
|
||||
pipe \
|
||||
container_id_for(container_name: service_with_version_and_destination(version)),
|
||||
container_id_for(container_name: container_name(version)),
|
||||
xargs(docker(:container, :rm))
|
||||
end
|
||||
|
||||
@@ -115,12 +122,12 @@ class Mrsk::Commands::App < Mrsk::Commands::Base
|
||||
|
||||
|
||||
private
|
||||
def service_with_version_and_destination(version = nil)
|
||||
[ config.service, config.destination, version || config.version ].compact.join("-")
|
||||
def container_name(version = nil)
|
||||
[ config.service, role, config.destination, version || config.version ].compact.join("-")
|
||||
end
|
||||
|
||||
def container_id_for_version(version)
|
||||
container_id_for(container_name: service_with_version_and_destination(version))
|
||||
container_id_for(container_name: container_name(version))
|
||||
end
|
||||
|
||||
def filter_args
|
||||
@@ -130,6 +137,7 @@ class Mrsk::Commands::App < Mrsk::Commands::Base
|
||||
def filters
|
||||
[ "label=service=#{config.service}" ].tap do |filters|
|
||||
filters << "label=destination=#{config.destination}" if config.destination
|
||||
filters << "label=role=#{role}" if role
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user