Module: Rumination::Deploy::ClassMethods

Included in:
Rumination::Deploy
Defined in:
lib/rumination/deploy/class_methods.rb

Instance Method Summary collapse

Instance Method Details

#app_container_full_nameObject



75
76
77
# File 'lib/rumination/deploy/class_methods.rb', line 75

def app_container_full_name
  "#{compose_project_name}_#{app_container_name}_1"
end

#app_container_nameObject



71
72
73
# File 'lib/rumination/deploy/class_methods.rb', line 71

def app_container_name
  config.app_container || :app
end

#bootstrapped_flag_pathObject



83
84
85
# File 'lib/rumination/deploy/class_methods.rb', line 83

def bootstrapped_flag_path
  "/opt/app/bootstrapped.ok"
end

#compose_project_nameObject



79
80
81
# File 'lib/rumination/deploy/class_methods.rb', line 79

def compose_project_name
  (ENV["COMPOSE_PROJECT_NAME"] || File.basename(Dir.pwd)).gsub("_","")
end

#development_target?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/rumination/deploy/class_methods.rb', line 43

def development_target?
  self.target.to_s == "development"
end

#docker_envObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/rumination/deploy/class_methods.rb', line 16

def docker_env
  env = {}
  if config.docker_machine
    dm_env_str = `docker-machine env #{config.docker_machine}`
    env = env.merge(Dotenv::Parser.call(dm_env_str))
  end
  env["COMPOSE_FILE"] = config.compose_file if config.compose_file.present?
  env["VIRTUAL_HOST"] = config.virtual_host if config.virtual_host.present?
  if config.letsencrypt_email.present?
    env["LETSENCRYPT_HOST"] = config.virtual_host
    env["LETSENCRYPT_EMAIL"] = config.letsencrypt_email
  end
  if ENV["NEWRELIC_KEY"].present?
    env["NEWRELIC_NAME"] = project_with_target_name
  end
  env = env.merge(config.docker_env || {})
  env
end

#factory_reset!Object



8
9
10
11
12
13
14
# File 'lib/rumination/deploy/class_methods.rb', line 8

def factory_reset!
  config.clear
  configure do |config|
    config.bootstrap = OpenStruct.new
  end
  self.target = nil
end

#files_to_copy_on_bootstrapObject



63
64
65
# File 'lib/rumination/deploy/class_methods.rb', line 63

def files_to_copy_on_bootstrap
  (config.bootstrap && config.bootstrap.copy_files) || []
end

#files_to_copy_on_deployObject



67
68
69
# File 'lib/rumination/deploy/class_methods.rb', line 67

def files_to_copy_on_deploy
  config.copy_files || []
end

#load_target_config(target_name) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/rumination/deploy/class_methods.rb', line 35

def load_target_config target_name
  load shared_config_path if File.exists?(shared_config_path)
  load "./config/deploy/targets/#{target_name}.rb"
  self.target = target_name
rescue LoadError => e
  raise UnknownTarget, e.message
end

#migrate_on_deploy?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/rumination/deploy/class_methods.rb', line 47

def migrate_on_deploy?
  config.migrate_on_deploy
end

#project_with_target_nameObject



59
60
61
# File 'lib/rumination/deploy/class_methods.rb', line 59

def project_with_target_name
  "#{compose_project_name} (#{target})"
end

#seeds_dump_fileObject



87
88
89
# File 'lib/rumination/deploy/class_methods.rb', line 87

def seeds_dump_file
  "/opt/app/seeds.sql.gz"
end

#write_env_file(path) ⇒ Object



51
52
53
54
55
56
57
# File 'lib/rumination/deploy/class_methods.rb', line 51

def write_env_file path
  File.open(path, "w") do |io|
    persistent_env.merge(generated_passwords).each do |var, val|
      io.puts %Q[export #{var}="#{val}"]
    end
  end
end