Sha256: 5b800ee84918f5007f80e60ccf46cdffdbdc95bf171d2b153698e75f7720c5d8

Contents?: true

Size: 1.43 KB

Versions: 1

Compression:

Stored size: 1.43 KB

Contents

module Cluster
  class Runner

    @@dc = system("which docker-compose") ? 'docker-compose' : 'docker compose'

    def run command, options = {}
      begin
        if !system command, options
          raise command.red
        end
      rescue Interrupt
        # user pressed Ctrl+C, do nothing
      end
    end

    def dc command, options = {}
      run "#{@@dc} -f ~/development/spend-cloud/docker-compose.yml #{command}", options
    end

    def start args, options
      if options.pull
        dc "pull"
      end

      if options.build
        dc "build #{options.pull ? "--pull" : ""}"
      end

      run "docker container prune -f"

      dc "up --detach --remove-orphans --force-recreate --always-recreate-deps"

      if options.pull or options.build
        system "docker image prune -f"
      end

      UI.success("\nāœ”ļø You can visit your environment at šŸ‘‰ https://spend-cloud.dev.spend.cloud šŸ‘Œ")
    end

    def stop
      dc "down --remove-orphans"
    end

    def delete
      dc "down --remove-orphans -v"
    end

    def reset args, options
      delete
      start args, options
    end

    def status
      dc "ps"
    end

    def logs args, options
      command = "logs"

      command << " --follow" if options.f or options.follow
      command << " --timestamps" if options.t or options.timestamps
      command << " --tail #{options.tail}" if options.tail

      dc "#{command} #{args.join " "}"
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sct-1.7.0 cluster/lib/cluster/runner.rb