Class: Wellcar::Commands::Base
- Inherits:
-
Object
- Object
- Wellcar::Commands::Base
- Defined in:
- lib/wellcar/commands/base.rb
Instance Attribute Summary collapse
-
#app_name ⇒ Object
Returns the value of attribute app_name.
-
#domain_name ⇒ Object
Returns the value of attribute domain_name.
-
#github_account ⇒ Object
Returns the value of attribute github_account.
-
#ruby_version ⇒ Object
Returns the value of attribute ruby_version.
-
#use_bundler_2 ⇒ Object
Returns the value of attribute use_bundler_2.
Instance Method Summary collapse
- #build_development_environment ⇒ Object
- #clean_docker ⇒ Object
- #core_docker_templates ⇒ Object
- #create_directories ⇒ Object
- #create_wellcar_folder ⇒ Object
- #write_files ⇒ Object
Instance Attribute Details
#app_name ⇒ Object
Returns the value of attribute app_name.
4 5 6 |
# File 'lib/wellcar/commands/base.rb', line 4 def app_name @app_name end |
#domain_name ⇒ Object
Returns the value of attribute domain_name.
4 5 6 |
# File 'lib/wellcar/commands/base.rb', line 4 def domain_name @domain_name end |
#github_account ⇒ Object
Returns the value of attribute github_account.
4 5 6 |
# File 'lib/wellcar/commands/base.rb', line 4 def github_account @github_account end |
#ruby_version ⇒ Object
Returns the value of attribute ruby_version.
4 5 6 |
# File 'lib/wellcar/commands/base.rb', line 4 def ruby_version @ruby_version end |
#use_bundler_2 ⇒ Object
Returns the value of attribute use_bundler_2.
4 5 6 |
# File 'lib/wellcar/commands/base.rb', line 4 def use_bundler_2 @use_bundler_2 end |
Instance Method Details
#build_development_environment ⇒ Object
70 71 72 |
# File 'lib/wellcar/commands/base.rb', line 70 def build_development_environment exit 128 unless system "docker-compose build web webpack-dev-server database" end |
#clean_docker ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/wellcar/commands/base.rb', line 52 def clean_docker # Make sure that no pre-existing containers are running. Although # very unlikely, it's worth being thorough. This makes the command # slow but for the time being this ensures the containers and images # are as expected. exit 8 unless system "docker-compose down --remove-orphans" removable_volumes = ["#{app_name}_gem_cache", "#{app_name}_node_modules"] volumes_to_remove = %x(docker volume ls --format='{{.Name}}') .split("\n") & removable_volumes return if volumes_to_remove.empty? puts "Removing the following volumes: #{volumes_to_remove.join(", ")}" system "docker volume rm #{volumes_to_remove.join(" ")}" end |
#core_docker_templates ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/wellcar/commands/base.rb', line 10 def core_docker_templates master_key = File.exist?("config/credentials/production.key") ? File.read("config/credentials/production.key") : nil [ Wellcar::Templates::Dockerfile.new(ruby_version, app_name, use_bundler_2), Wellcar::Templates::DockerStack.new(app_name, github_account), Wellcar::Templates::EnvDevelopmentDatabase.new(app_name), Wellcar::Templates::EnvDevelopmentWeb.new, Wellcar::Templates::EnvProductionWeb.new(master_key), Wellcar::Templates::EnvProductionDatabase.new(app_name), Wellcar::Templates::Dockerignore.new, Wellcar::Templates::DockerEntrypoint.new, Wellcar::Templates::BuildProductionImage.new(app_name, github_account), Wellcar::Templates::ReverseProxyConf.new(domain_name) ] end |
#create_directories ⇒ Object
29 30 31 32 33 34 |
# File 'lib/wellcar/commands/base.rb', line 29 def create_directories FileUtils.mkdir_p "config" FileUtils.mkdir_p "bin" FileUtils.mkdir_p ".env/development" FileUtils.mkdir_p ".env/production" end |
#create_wellcar_folder ⇒ Object
45 46 47 48 49 50 |
# File 'lib/wellcar/commands/base.rb', line 45 def create_wellcar_folder return if Dir.exist? ".wellcar" Dir.mkdir ".wellcar" FileUtils.touch ".wellcar/.keep" end |
#write_files ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/wellcar/commands/base.rb', line 36 def write_files files_before_docker = Dir['*'] system "curl -o bin/wait-for https://raw.githubusercontent.com/mrako/wait-for/master/wait-for" docker_files.each(&:write) puts "Wellcar created:\n#{Dir['*'] - files_before_docker}\n" end |