require 'yaml' module Sct class DevCommand def error message UI.error message exit 1 end def execute args, options file = "docker-compose.dev.yml" if !File.exist? file error "Could not find file '#{file}'." end manifest = YAML.load File.read file services = manifest["services"].to_a if services.length != 1 error "Currently sct only supports a single service declaration in '#{file}'. Contact the infra guild if you consider this a limitation." end service, service_spec = services.first container = service_spec["container_name"] command = service_spec["command"] || "" if options.build return unless system "docker-compose -f #{file} build #{options.pull ? "--pull" : ""}" end return unless system "docker-compose -f ~/development/spend-cloud/docker-compose.yml rm --stop --force #{service}" system "docker-compose -f #{file} run --rm --service-ports --name #{container} #{service} #{command}" system "docker-compose -f ~/development/spend-cloud/docker-compose.yml up --detach #{service}" end end end