module Rumination::Deploy::ClassMethods

Public Instance Methods

app_container_full_name() click to toggle source
# File lib/rumination/deploy/class_methods.rb, line 75
def app_container_full_name
  "#{compose_project_name}_#{app_container_name}_1"
end
app_container_name() click to toggle source
# File lib/rumination/deploy/class_methods.rb, line 71
def app_container_name
  config.app_container || :app
end
bootstrapped_flag_path() click to toggle source
# File lib/rumination/deploy/class_methods.rb, line 83
def bootstrapped_flag_path
  "/opt/app/bootstrapped.ok"
end
compose_project_name() click to toggle source
# 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?() click to toggle source
# File lib/rumination/deploy/class_methods.rb, line 43
def development_target?
  self.target.to_s == "development"
end
docker_env() click to toggle source
# 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!() click to toggle source
# 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_bootstrap() click to toggle source
# 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_deploy() click to toggle source
# File lib/rumination/deploy/class_methods.rb, line 67
def files_to_copy_on_deploy
  config.copy_files || []
end
load_target_config(target_name) click to toggle source
# 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?() click to toggle source
# File lib/rumination/deploy/class_methods.rb, line 47
def migrate_on_deploy?
  config.migrate_on_deploy
end
project_with_target_name() click to toggle source
# File lib/rumination/deploy/class_methods.rb, line 59
def project_with_target_name
  "#{compose_project_name} (#{target})"
end
seeds_dump_file() click to toggle source
# File lib/rumination/deploy/class_methods.rb, line 87
def seeds_dump_file
  "/opt/app/seeds.sql.gz"
end
write_env_file(path) click to toggle source
# 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

Private Instance Methods

default_persistent_env() click to toggle source
# File lib/rumination/deploy/class_methods.rb, line 97
def default_persistent_env
  {
    "SECRET_KEY_BASE" => Generate.secret_key_base
  }
end
generated_passwords() click to toggle source
# File lib/rumination/deploy/class_methods.rb, line 103
def generated_passwords
  password_vars.map{|var| [var, Generate.password]}.to_h
end
password_vars() click to toggle source
# File lib/rumination/deploy/class_methods.rb, line 107
def password_vars
  config.generate_passwords || Array(config.generate_password)
end
persistent_env() click to toggle source
# File lib/rumination/deploy/class_methods.rb, line 93
def persistent_env
  default_persistent_env.merge(config.persistent_env || {})
end
shared_config_path() click to toggle source
# File lib/rumination/deploy/class_methods.rb, line 111
def shared_config_path
  "./config/deploy/shared.rb"
end