class Docker::Rails::CLI::Main

Public Instance Methods

bash_connect(target, service_name) click to toggle source
# File lib/docker/rails/cli/main.rb, line 142
def bash_connect(target, service_name)
  # init singleton with full options
  app = App.configured(target, options)

  invoke :compose, [target], []

  container = app.bash_connect(service_name)

  # Automatically cleanup any remnants of a simple bash session.
  return if container.nil?
  container.stop
  container.remove(v: true, force: true)
end
before(target) click to toggle source
# File lib/docker/rails/cli/main.rb, line 96
def before(target)
  app = App.configured(target, options)
  invoke :compose, [target], []
  app.before_command
end
build(target) click to toggle source
# File lib/docker/rails/cli/main.rb, line 76
def build(target)
  invoke :compose
  app = App.configured(target, options)
  app.create_dockito_vault
  begin
    app.compose_build
  ensure
    app.rm_dockito_vault
    app.after_build_command
  end
end
ci(target) click to toggle source
# File lib/docker/rails/cli/main.rb, line 20
def ci(target)
  # init singleton with full options
  app = App.configured(target, options)

  invoke :before, [target], []
  invoke :compose, [target], []
  begin
    invoke :build # on CI - always build to ensure dockerfile hasn't been altered - small price to pay for consistent CI.
    invoke :up
  ensure
    invoke :cleanup
  end

  exit app.exit_code
end
cleanup(target) click to toggle source
# File lib/docker/rails/cli/main.rb, line 47
def cleanup(target)
  invoke :extract if options[:extract]
  invoke :down
  invoke :rm_compose
  # invoke :rm_dangling # causes a brand new dockerfile build - don't do that. See https://github.com/alienfast/docker-rails/issues/26
  invoke :ps_all
end
compose(target) click to toggle source
# File lib/docker/rails/cli/main.rb, line 90
def compose(target)
  App.configured(target, options).compose
end
down(target) click to toggle source
# File lib/docker/rails/cli/main.rb, line 104
def down(target)
  invoke :compose
  App.configured(target, options).down
end
exec(target, service_name, command) click to toggle source
# File lib/docker/rails/cli/main.rb, line 158
def exec(target, service_name, command)
  # init singleton with full options
  app = App.configured(target, options)

  invoke :compose, [target], []

  app.run_service_command(service_name, command)
end
extract(target) click to toggle source
# File lib/docker/rails/cli/main.rb, line 38
def extract(target)
  app = App.configured(target, options)
  invoke :compose, [target], []
  app.extract_all
end
ps(target) click to toggle source
# File lib/docker/rails/cli/main.rb, line 129
def ps(target)
  invoke :compose
  App.configured(target, options).ps
end
ps_all(build = nil, target = nil) click to toggle source
# File lib/docker/rails/cli/main.rb, line 136
def ps_all(build = nil, target = nil)
  App.instance.ps_all
end
rm_compose(build = nil, target = nil) click to toggle source
# File lib/docker/rails/cli/main.rb, line 111
def rm_compose(build = nil, target = nil)
  App.instance.rm_compose
end
rm_dangling(build = nil, target = nil) click to toggle source
# File lib/docker/rails/cli/main.rb, line 117
def rm_dangling(build = nil, target = nil)
  App.instance.rm_dangling
end
rm_exited(build = nil, target = nil) click to toggle source
# File lib/docker/rails/cli/main.rb, line 123
def rm_exited(build = nil, target = nil)
  App.instance.rm_exited
end
up(target) click to toggle source
# File lib/docker/rails/cli/main.rb, line 58
def up(target)
  # init singleton with full options
  app = App.configured(target, options)
  base_options = options.except(:detached)

  invoke :before, [target], base_options

  if options[:detached]
    compose_options = '-d'
  else
    compose_options = '--abort-on-container-exit'
  end

  app.up(compose_options)
end