Sha256: 002bb85093c68019aa8513a5c484aa50bab049cabaa1a4fd2f93d24facf5f900

Contents?: true

Size: 693 Bytes

Versions: 12

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

12 entries across 12 versions & 1 rubygems

Version Path
pact_broker-2.89.1 tasks/docker_database.rb
pact_broker-2.89.0 tasks/docker_database.rb
pact_broker-2.88.0 tasks/docker_database.rb
pact_broker-2.87.0 tasks/docker_database.rb
pact_broker-2.86.0 tasks/docker_database.rb
pact_broker-2.85.1 tasks/docker_database.rb
pact_broker-2.85.0 tasks/docker_database.rb
pact_broker-2.84.0 tasks/docker_database.rb
pact_broker-2.83.0 tasks/docker_database.rb
pact_broker-2.82.0 tasks/docker_database.rb
pact_broker-2.81.0 tasks/docker_database.rb
pact_broker-2.80.0 tasks/docker_database.rb