Sha256: f07c5ffe3e090d92067ea37374fbcbaec60c3a18c4e5b9e50288e9beac991957

Contents?: true

Size: 1.45 KB

Versions: 58

Compression:

Stored size: 1.45 KB

Contents

module MobileWorkflow::Cli
  class DokkuBackend
    def initialize(dokku_host:, app_name:)
      @dokku_host = dokku_host
      @dokku_app_name = app_name.gsub("_", "-")
    end
  
    def create
      remote_command "dokku apps:create #{@dokku_app_name}"
      remote_command "dokku postgres:create #{@dokku_app_name}"
      remote_command "dokku postgres:link #{@dokku_app_name} #{@dokku_app_name}"
      remote_command "dokku domains:enable #{@dokku_app_name}"
      remote_command "dokku letsencrypt #{@dokku_app_name}"
    
      local_command "git remote add dokku dokku@#{@dokku_host}:#{@dokku_app_name}"
    end
  
    def configure_activestorage
 
    end
  
    def deploy
      local_command "git push dokku master"
    end
  
    def sync_dotenv
      env = File.read(".env").split.join(" ")
      puts "Setting env: #{env}"
      local_command "dokku config:set #{env}"
    end
  
    def destroy
      remote_command "dokku apps:destroy #{@dokku_app_name}"
    end
  
    def dokku_app_host
      remote_command "dokku url #{@dokku_app_name}"
    end
  
    def notifications_endpoint
      "https://#{dokku_app_host}/sns_notifications"
    end
  
    private
    def remote_command(command)
      command = "ssh -t ubuntu@#{@dokku_host} '#{command}'"
      local_command(command)
    end
  
    def local_command(command)
      puts "Running: #{command}"
      output = `#{command}`
      puts "Output: #{output}" unless output.blank?
      return output
    end
  end
end

Version data entries

58 entries across 58 versions & 1 rubygems

Version Path
mobile_workflow-0.10.2 lib/mobile_workflow/cli/dokku_backend.rb
mobile_workflow-0.10.1 lib/mobile_workflow/cli/dokku_backend.rb
mobile_workflow-0.10.0 lib/mobile_workflow/cli/dokku_backend.rb
mobile_workflow-0.9.0 lib/mobile_workflow/cli/dokku_backend.rb
mobile_workflow-0.8.9 lib/mobile_workflow/cli/dokku_backend.rb
mobile_workflow-0.7.9 lib/mobile_workflow/cli/dokku_backend.rb
mobile_workflow-0.7.8 lib/mobile_workflow/cli/dokku_backend.rb
mobile_workflow-0.7.7 lib/mobile_workflow/cli/dokku_backend.rb
mobile_workflow-0.7.6 lib/mobile_workflow/cli/dokku_backend.rb
mobile_workflow-0.7.5 lib/mobile_workflow/cli/dokku_backend.rb
mobile_workflow-0.7.4 lib/mobile_workflow/cli/dokku_backend.rb
mobile_workflow-0.7.3 lib/mobile_workflow/cli/dokku_backend.rb
mobile_workflow-0.7.2 lib/mobile_workflow/cli/dokku_backend.rb
mobile_workflow-0.7.1 lib/mobile_workflow/cli/dokku_backend.rb
mobile_workflow-0.7.0 lib/mobile_workflow/cli/dokku_backend.rb
mobile_workflow-0.6.31 lib/mobile_workflow/cli/dokku_backend.rb
mobile_workflow-0.6.30 lib/mobile_workflow/cli/dokku_backend.rb
mobile_workflow-0.6.29 lib/mobile_workflow/cli/dokku_backend.rb
mobile_workflow-0.6.28 lib/mobile_workflow/cli/dokku_backend.rb
mobile_workflow-0.6.27 lib/mobile_workflow/cli/dokku_backend.rb