Sha256: 212b56ee7bb0ee0be96a2cc74efe1fd8a98d8d55fb5dee15fca9ee91481e4c10

Contents?: true

Size: 693 Bytes

Versions: 51

Compression:

Stored size: 693 Bytes

Contents

require 'docker'

module DockerDatabase

  POSTGRES_IMAGE_NAME = 'postgres:9.6'.freeze

  def self.start(options)
    Docker::Image.create('fromImage' => POSTGRES_IMAGE_NAME)
    host_port = options.fetch(:port)
    Docker::Container.create(
      'Image' => POSTGRES_IMAGE_NAME,
      'name' => options.fetch(:name),
      'ExposedPorts' => { '5432/tcp' => {} },
      'HostConfig' => {
        'PortBindings' => {
          '5432/tcp' => [{ 'HostPort' => host_port }]
        }
      }
    ).start({})
    # .tap(&:start).attach { |stream, chunk| puts "#{stream}: #{chunk}" }
  end

  def self.stop_and_remove(name)
    ::Docker::Container.get(name).remove(force: true) rescue nil
  end
end

Version data entries

51 entries across 51 versions & 1 rubygems

Version Path
pact_broker-2.79.1 tasks/docker_database.rb
pact_broker-2.79.0 tasks/docker_database.rb
pact_broker-2.78.1 tasks/docker_database.rb
pact_broker-2.78.0 tasks/docker_database.rb
pact_broker-2.77.0 tasks/docker_database.rb
pact_broker-2.76.2 tasks/docker_database.rb
pact_broker-2.76.1 tasks/docker_database.rb
pact_broker-2.76.0 tasks/docker_database.rb
pact_broker-2.75.0 tasks/docker_database.rb
pact_broker-2.74.1 tasks/docker_database.rb
pact_broker-2.74.0 tasks/docker_database.rb
pact_broker-2.73.0 tasks/docker_database.rb
pact_broker-2.72.0 tasks/docker_database.rb
pact_broker-2.71.0 tasks/docker_database.rb
pact_broker-2.70.0 tasks/docker_database.rb
pact_broker-2.69.0 tasks/docker_database.rb
pact_broker-2.68.1 tasks/docker_database.rb
pact_broker-2.68.0 tasks/docker_database.rb
pact_broker-2.67.0 tasks/docker_database.rb
pact_broker-2.66.0 tasks/docker_database.rb