-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup
executable file
·45 lines (35 loc) · 1.25 KB
/
setup
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
38
39
40
41
42
43
44
45
#!/usr/bin/env ruby
# encoding: UTF-8
# frozen_string_literal: true
# path to your application root
APP_ROOT = File.expand_path('..', __dir__)
VAULT_TOKEN = ENV.fetch('VAULT_TOKEN', 'changeme')
Dir.chdir APP_ROOT do
puts "\n=== Copying config files ==="
system 'bin/init_config'
puts "\n=== Removing old logs and tempfiles ==="
system 'rm -f log/* log/daemons/*'
system 'bin/rake tmp:clear tmp:create'
if ENV['JWT_PUBLIC_KEY'].nil?
puts "\n=== Creating secrets"
system 'bundle exec peatio security keygen --path=config/secrets'
end
puts "\n=== Creting backend ==="
{'VAULT_TOKEN' => VAULT_TOKEN}.tap do |env|
system(env, 'docker-compose -f config/backend.yml up -Vd')
end
puts "\n=== Initialize InfluxDB ==="
system 'docker-compose -f config/backend.yml exec influxdb bash -c "cat influxdb.sql | influx"'
puts "\n=== Setup Vault"
system "bin/init_vault"
# in production we run db:setup as k8s jobs
if ENV['RAILS_ENV'] == 'production'
puts "\n=== Compiling assets ==="
system 'bin/rake assets:clobber assets:precompile'
puts "\n=== Preparing database schema ==="
system 'bin/rake db:schema:dump'
else
puts "\n=== Setup database ==="
system 'bin/rake db:create db:migrate; bin/rake db:seed'
end
end