Module: Workarea::Tasks::Services
Instance Method Summary collapse
- #assert_docker_compose_installed! ⇒ Object
- #clean ⇒ Object
- #compose_env ⇒ Object
- #compose_file_path ⇒ Object
- #down ⇒ Object
- #up ⇒ Object
Instance Method Details
#assert_docker_compose_installed! ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/workarea/tasks/services.rb', line 6 def assert_docker_compose_installed! unless system('docker-compose -v > /dev/null 2>&1') STDERR.puts <<~eos ************************************************** ⛔️ ERROR: workarea:services tasks depend on Docker Compose being installed. \ See https://docs.docker.com/compose/install/ for how to install. ************************************************** eos exit end end |
#clean ⇒ Object
60 61 62 63 64 65 66 67 68 |
# File 'lib/workarea/tasks/services.rb', line 60 def clean assert_docker_compose_installed! if system(compose_env, "docker-compose down -v #{ENV['COMPOSE_ARGUMENTS']}") puts '✅ Success! Workarea service volumes have been removed. Run workarea:services:up to start services and recreate volumes.' else STDERR.puts '⛔️ Error! There was an error removing Workarea service volumes.' end end |
#compose_env ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/workarea/tasks/services.rb', line 22 def compose_env require 'workarea/version' { 'COMPOSE_FILE' => compose_file_path, 'COMPOSE_PROJECT_NAME' => File.basename(Dir.pwd), 'MONGODB_VERSION' => Workarea::VERSION::MONGODB::STRING, 'MONGODB_PORT' => ENV['WORKAREA_MONGODB_PORT'] || '27017', 'REDIS_VERSION' => Workarea::VERSION::REDIS::STRING, 'REDIS_PORT' => ENV['WORKAREA_REDIS_PORT'] || '6379', 'ELASTICSEARCH_VERSION' => Workarea::VERSION::ELASTICSEARCH::STRING, 'ELASTICSEARCH_PORT' => ENV['WORKAREA_ELASTICSEARCH_PORT'] || '9200' } end |
#compose_file_path ⇒ Object
18 19 20 |
# File 'lib/workarea/tasks/services.rb', line 18 def compose_file_path File.join(Gem::Specification.find_by_name('workarea').gem_dir, 'docker-compose.yml') end |
#down ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'lib/workarea/tasks/services.rb', line 50 def down assert_docker_compose_installed! if system(compose_env, "docker-compose down #{ENV['COMPOSE_ARGUMENTS']}") puts '✅ Success! Workarea services are stopped. Run workarea:services:up to start them.' else STDERR.puts '⛔️ Error! There was an error stopping Workarea services.' end end |
#up ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/workarea/tasks/services.rb', line 40 def up assert_docker_compose_installed! if system(compose_env, "docker-compose up -d #{ENV['COMPOSE_ARGUMENTS']} #{ENV['WORKAREA_SERVICES']}") puts '✅ Success! Workarea services are running in the background. Run workarea:services:down to stop them.' else STDERR.puts '⛔️ Error! There was an error starting Workarea services.' end end |