Class: Shiprails::Ship::Install
- Inherits:
-
Thor::Group
- Object
- Thor::Group
- Shiprails::Ship::Install
- Includes:
- Thor::Actions
- Defined in:
- lib/shiprails/ship/install.rb
Class Method Summary collapse
Instance Method Summary collapse
- #application_host ⇒ Object
- #config_s3_bucket ⇒ Object
- #create_configuration ⇒ Object
- #create_docker_compose ⇒ Object
- #create_dockerfile ⇒ Object
- #create_dot_env ⇒ Object
- #ec2_ssh_private_key_path ⇒ Object
- #environments ⇒ Object
- #ignore_dot_env ⇒ Object
Class Method Details
.source_root ⇒ Object
15 16 17 |
# File 'lib/shiprails/ship/install.rb', line 15 def self.source_root File.("../install", __FILE__) end |
Instance Method Details
#application_host ⇒ Object
19 20 21 |
# File 'lib/shiprails/ship/install.rb', line 19 def application_host "#{project_name}.dev" end |
#config_s3_bucket ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/shiprails/ship/install.rb', line 33 def config_s3_bucket return @bucket_name unless @bucket_name.nil? @_s3_client ||= Aws::S3::Client.new(region: ENV.fetch("AWS_REGION", "us-west-2"), access_key_id: aws_access_key_id, secret_access_key: aws_access_key_secret) begin bucket_name = "#{project_name}-config" bucket_name = ask "S3 bucket name for configuration store", default: bucket_name resp = @_s3_client.create_bucket({ bucket: bucket_name }) rescue Aws::S3::Errors::BucketAlreadyExists error "'#{bucket_name}' already exists" retry rescue Aws::S3::Errors::BucketAlreadyOwnedByYou end @bucket_name = bucket_name end |
#create_configuration ⇒ Object
138 139 140 |
# File 'lib/shiprails/ship/install.rb', line 138 def create_configuration template("shiprails.yml.erb", "#{[:path]}/.shiprails.yml") end |
#create_docker_compose ⇒ Object
134 135 136 |
# File 'lib/shiprails/ship/install.rb', line 134 def create_docker_compose template("docker-compose.yml.erb", "#{[:path]}/docker-compose.yml") end |
#create_dockerfile ⇒ Object
113 114 115 116 |
# File 'lib/shiprails/ship/install.rb', line 113 def create_dockerfile template("Dockerfile.erb", "#{[:path]}/Dockerfile") template("Dockerfile.production.erb", "#{[:path]}/Dockerfile.production") end |
#create_dot_env ⇒ Object
118 119 120 121 |
# File 'lib/shiprails/ship/install.rb', line 118 def create_dot_env template(".env.erb", "#{[:path]}/.env") template(".env.erb", "#{[:path]}/.env.example") end |
#ec2_ssh_private_key_path ⇒ Object
50 51 52 |
# File 'lib/shiprails/ship/install.rb', line 50 def ec2_ssh_private_key_path @ec2_ssh_private_key_path ||= ask "Where is your AWS EC2 SSH private key?", default: "#{project_name}.pem" end |
#environments ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/shiprails/ship/install.rb', line 54 def environments environments = Dir.entries("#{Dir.getwd}/config/environments").grep(/\.rb$/).map { |fname| fname.chomp!(".rb") }.select{ |e| !['development', 'test'].include? e } rescue ['production'] environments ||= ['production'] @regions ||= ask("Which regions?", default: 'us-west-2').split(',') environments.map do |environment| { name: environment, regions: @regions } end end |
#ignore_dot_env ⇒ Object
123 124 125 126 127 128 129 130 131 132 |
# File 'lib/shiprails/ship/install.rb', line 123 def ignore_dot_env if File.exists?(".gitignore") append_to_file(".gitignore", <<-EOF) # Ignore Docker ENV /.env /shiprails.pem EOF end end |