Class: Kaiser::Databases::Postgres
- Inherits:
-
Object
- Object
- Kaiser::Databases::Postgres
- Defined in:
- lib/kaiser/databases/postgres.rb
Instance Method Summary collapse
- #image_name ⇒ Object
-
#initialize(options) ⇒ Postgres
constructor
A new instance of Postgres.
- #options_hash ⇒ Object
Constructor Details
#initialize(options) ⇒ Postgres
Returns a new instance of Postgres.
6 7 8 |
# File 'lib/kaiser/databases/postgres.rb', line 6 def initialize() @options = end |
Instance Method Details
#image_name ⇒ Object
38 39 40 41 |
# File 'lib/kaiser/databases/postgres.rb', line 38 def image_name version = @options[:version] || 'alpine' "postgres:#{version}" end |
#options_hash ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/kaiser/databases/postgres.rb', line 10 def testpass = @options[:root_password] || 'testpassword' parameters = @options[:parameters] || '' port = @options[:port] || 3306 { port: port, data_dir: '/var/lib/postgresql/data', params: "-e POSTGRES_PASSWORD=#{testpass}", commands: parameters, waitscript_params: " -e PG_HOST=<%= db_container_name %> -e PG_USER=postgres -e PGPASSWORD=#{testpass} -e PG_DATABASE=postgres", waitscript: <<~SCRIPT #!/bin/sh RETRIES=5 until psql -h $PG_HOST -U $PG_USER -d $PG_DATABASE -c "select 1" > /dev/null 2>&1 || [ $RETRIES -eq 0 ]; do echo "Waiting for postgres server, $((RETRIES--)) remaining attempts..." sleep 1 done SCRIPT } end |