Class: Railsdock::Commands::Install
- Inherits:
-
Railsdock::Command
- Object
- Railsdock::Command
- Railsdock::Commands::Install
- Defined in:
- lib/railsdock/commands/install.rb
Constant Summary collapse
- OPTIONS_HASH =
{ database: { name: 'Database', options: %i[postgres mysql], default_port: { postgres: 5432, mysql: 3306 } }, mem_store: { name: 'In-Memory Store', options: %i[redis memcached] } }.freeze
- POST_INSTALL_MESSAGE =
<<~PIM Railsdock successfully installed Run `docker-compose build` then `docker-compose up` to start your app, PIM
- BASE_TEMPLATE_DIR =
File.("#{__dir__}/../templates/install").freeze
Instance Method Summary collapse
- #execute(input: $stdin, output: $stdout) ⇒ Object
-
#initialize(options) ⇒ Install
constructor
A new instance of Install.
Methods inherited from Railsdock::Command
#cmd, #color, #file, #platform, #prompt
Constructor Details
#initialize(options) ⇒ Install
Returns a new instance of Install.
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/railsdock/commands/install.rb', line 36 def initialize() @options = @variables = OpenStruct.new( app_name: [:app_name] || get_app_name, is_windows?: platform.windows?, is_mac?: platform.mac?, uid: cmd.run('id -u').out.chomp, ruby_version: get_ruby_version ) end |
Instance Method Details
#execute(input: $stdin, output: $stdout) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/railsdock/commands/install.rb', line 47 def execute(input: $stdin, output: $stdout) output.puts Railsdock::Logo.call @variables[:dockerfile_dir] = prompt_for_dockerfile_directory copy_default_files service_hash = collect_service_selections service_hash.each do |type, service| file.copy_file("#{BASE_TEMPLATE_DIR}/#{service}/Dockerfile", [@variables.dockerfile_dir, service, "/Dockerfile"].join) inject_driver_config(service) append_erb_to_compose_file(service) file.inject_into_file('./docker-compose.yml', "\n #{service}:", after: "\nvolumes:") if type == :database copy_db_yml("#{BASE_TEMPLATE_DIR}/#{service}/database.yml.erb") inject_db_script_into_entrypoint(service) end end cmd.run('chmod +x ./docker/ruby/entrypoint.sh') output.puts POST_INSTALL_MESSAGE end |