-
Notifications
You must be signed in to change notification settings - Fork 8
/
docker_runner.rb
executable file
·37 lines (30 loc) · 1.07 KB
/
docker_runner.rb
1
2
3
4
5
6
7
8
9
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
37
#! /usr/bin/env ruby
def get_env_or_fail(name)
if ENV.has_key?(name)
ENV[name]
else
$stderr.puts "Missing variable: #{name}"
exit 1
end
end
File.open("/app/config.yml", "w") do |config|
config.puts "database:"
config.puts " adapter: #{get_env_or_fail("DB_ADAPTER")}"
config.puts " host: #{get_env_or_fail("DB_HOSTNAME")}"
config.puts " port: #{get_env_or_fail("DB_PORT")}"
config.puts " user: #{get_env_or_fail("DB_USERNAME")}"
config.puts " password: #{get_env_or_fail("DB_PASSWORD")}"
config.puts " database: #{get_env_or_fail("DB_NAME")}"
config.puts " max_connections: 20"
config.puts "read_databases:"
read_databases = get_env_or_fail("READ_DATABASES").split(/\s*,\s*/)
read_databases.each do |read_database|
read_database = read_database.gsub(/\s/, '')
config.puts " - #{read_database}"
end
config.puts "misc:"
config.puts " defaultDb: #{get_env_or_fail("MISC_DEFAULT")}"
config.puts " dblistMatch: #{get_env_or_fail("MISC_DBLISTMATCH")}"
end
Dir.chdir("/app")
exec("/usr/bin/env bundle exec puma -t 16:16 -p 3000")