Sha256: a01efe6abaeecaa32a1143b76d382a5bd2bca46352b3d86224e152d4b22b63e4
Contents?: true
Size: 1.49 KB
Versions: 9
Compression:
Stored size: 1.49 KB
Contents
module Rascal class Environment attr_reader :name, :network, :container, :env_variables, :services, :volumes, :working_dir, :before_shell def initialize(full_name, name:, image:, env_variables: {}, services: [], volumes: [], before_shell: [], after_shell: [], working_dir: nil) @name = name @network = Docker::Network.new(full_name) @container = Docker::Container.new(full_name, image) @env_variables = env_variables @services = services @volumes = volumes @working_dir = working_dir @before_shell = before_shell @after_shell = after_shell end def run_shell download_missing start_services command = [*@before_shell, 'bash', *@after_shell].join(';') @container.run_and_attach('bash', '-c', command, env: @env_variables, network: @network, volumes: @volumes, working_dir: @working_dir, allow_failure: true ) end def clean(clean_volumes: false) @services.each(&:clean) @network.clean @volumes.each(&:clean) if clean_volumes end def update(skip: []) [ *@services.collect { |s| s.update(skip: skip) }, *@container.update(skip: skip), ] end private def download_missing @container.download_missing @services.each(&:download_missing) end def start_services @network.create unless @network.exists? @services.each { |s| s.start_if_stopped(network: @network) } end end end
Version data entries
9 entries across 9 versions & 1 rubygems