dokku-cli 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 49fff4f7f596e8abe3d6952838c3b8e05882d9f1
4
+ data.tar.gz: 46f771d59e47669ff39bd8f04f7e7a29cad63b9b
5
+ SHA512:
6
+ metadata.gz: f16831197e9855aa8c04e37b5f262d5ddd70d41cfd99b8a4b7de5b7657cb2208258783ad12251743b03dd0d6e785c0b7f04a32855ba3f359ed2b82ca2fb50db1
7
+ data.tar.gz: a237acbc1f7ade9de87b2334ec806afc7c7ca958c1060701ffa3ebc081f803dfab8a8963016454ee48902218408bc3c4cbcc30aa97eafbda14e7715617638f0c
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in dokku-cli.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Sebastian Szturo
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,50 @@
1
+ # Dokku CLI :anchor:
2
+
3
+ Dokku CLI is a zero config command line tool for the official version of [Dokku](https://github.com/progrium/dokku).
4
+
5
+ The newest version of Dokku CLI is fully compatible with ```Dokku 0.3.x```
6
+
7
+ This project is a fork of [brianpattison/dokku-installer-cli](https://github.com/brianpattison/dokku-installer-cli). All credits for the amazing idea goes to @brianpattison.
8
+
9
+ ## Installation
10
+ ```
11
+ $ gem install dokku-cli
12
+ ```
13
+
14
+ ## Usage
15
+
16
+ Dokku CLI reads the domain of your Dokku server from your git configuration file and requires no configuration. Change in your application directory and run
17
+
18
+ ```
19
+ $ dokku help
20
+ Commands:
21
+ dokku config # Display the app's environment variables
22
+ dokku config:get KEY # Display an environment variable value
23
+ dokku config:set KEY1=VALUE1 [KEY2=VALUE2 ...] # Set one or more environment variables
24
+ dokku config:unset KEY1 [KEY2 ...] # Unset one or more environment variables
25
+ dokku domains # List custom domains for the app
26
+ dokku domains:add DOMAIN # Add a custom domain to the app
27
+ dokku domains:clear # Clear all custom domains for app
28
+ dokku domains:remove DOMAIN # Remove a custom domain from the app
29
+ dokku help [COMMAND] # Describe available commands or one specific command
30
+ dokku logs [-t] # Display logs for the app (-t follows)
31
+ dokku nginx:build # (Re)builds nginx config for the app
32
+ dokku open # Open the app in your default browser
33
+ dokku ps # List processes running in app container(s)
34
+ dokku ps:rebuild # Rebuild the app
35
+ dokku ps:restart # Restart the app container
36
+ dokku ps:start # Start the app container
37
+ dokku run <cmd> # Run a one-off command in the environment of the app
38
+ dokku ssh # Start an SSH session as root user
39
+ dokku url # Show the first URL for the app
40
+ dokku urls # Show all URLs for the app
41
+
42
+ ```
43
+
44
+ ## Contributing
45
+
46
+ 1. Fork it ( https://github.com/[my-github-username]/dokku-cli/fork )
47
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
48
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
49
+ 4. Push to the branch (`git push origin my-new-feature`)
50
+ 5. Create a new Pull Request
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ require "rubygems" # ruby1.9 doesn't "require" it though
3
+ require 'dokku_cli'
4
+
5
+ DokkuCli::Cli.start(ARGV)
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'dokku_cli/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "dokku-cli"
8
+ spec.version = DokkuCli::VERSION
9
+ spec.authors = ["Sebastian Szturo"]
10
+ spec.email = ["s.szturo@me.com"]
11
+ spec.description = "Command line tool for Dokku."
12
+ spec.summary = "Command line tool for Dokku."
13
+ spec.homepage = "http://github.com/SebastianSzturo/dokku-cli"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "thor", "~> 0.19"
22
+ spec.add_development_dependency "bundler", "~> 1.7"
23
+ end
@@ -0,0 +1,103 @@
1
+ require 'thor'
2
+
3
+ require "dokku_cli/version"
4
+ require "dokku_cli/config"
5
+ require "dokku_cli/domains"
6
+ require "dokku_cli/nginx"
7
+ require "dokku_cli/ps"
8
+
9
+ module DokkuCli
10
+ class Cli < Thor
11
+ desc "logs [-t]", "Display logs for the app (-t follows)"
12
+ def logs(*args)
13
+ if args.first && args.first.strip == "-t"
14
+ command = "ssh dokku@#{domain} logs #{app_name} -t"
15
+ puts "Running #{command}..."
16
+ exec(command)
17
+ else
18
+ run_command "logs #{app_name}"
19
+ end
20
+ end
21
+
22
+ desc "open", "Open the app in your default browser"
23
+ def open
24
+ # TODO: get domain from 'dokku domains'
25
+ exec("open http://#{app_name}.#{domain}")
26
+ end
27
+
28
+ desc "run <cmd>", "Run a one-off command in the environment of the app"
29
+ def walk(*args)
30
+ command = "#{args.join(' ')}"
31
+ case command.gsub(" ", "")
32
+ when "rakedb:drop"
33
+ puts "You cannot use `rake db:drop`. Use Dokku directly to delete the database."
34
+ when "rakedb:create"
35
+ puts "You cannot use `rake db:create`. Use Dokku directly to create the database."
36
+ else
37
+ run_command "run #{app_name} #{command}"
38
+ end
39
+ end
40
+
41
+ desc "ssh", "Start an SSH session as root user"
42
+ def ssh
43
+ command = "ssh root@#{domain}"
44
+ puts "Running #{command}..."
45
+ exec(command)
46
+ end
47
+
48
+ desc "url", "Show the first URL for the app"
49
+ def url
50
+ run_command "url #{app_name}"
51
+ end
52
+
53
+ desc "urls", "Show all URLs for the app"
54
+ def urls
55
+ run_command "urls #{app_name}"
56
+ end
57
+
58
+ def help(method = nil)
59
+ method = "walk" if method == "run"
60
+ super
61
+ end
62
+
63
+ def method_missing(method, *args, &block)
64
+ if method.to_s.split(":").length >= 2
65
+ self.send(method.to_s.gsub(":", "_"), *args)
66
+ elsif method == :run
67
+ self.walk(*args)
68
+ else
69
+ super
70
+ end
71
+ end
72
+
73
+ private
74
+
75
+ def app_name
76
+ @app_name ||= git_config_match[2]
77
+ end
78
+
79
+ def domain
80
+ @domain ||= git_config_match[1]
81
+ end
82
+
83
+ def git_config_match
84
+ @git_config_match ||= begin
85
+ git_config = File.join(Dir.pwd, ".git", "config")
86
+ exit unless File.exist?(git_config)
87
+
88
+ git_config = File.read(git_config)
89
+ match = git_config.match(/url \= dokku@(.*):(.*)\n/).to_a
90
+ exit unless match
91
+
92
+ match
93
+ end
94
+ end
95
+
96
+ def run_command(command)
97
+ dokku_command = "ssh -t dokku@#{domain} #{command}"
98
+
99
+ puts "Running #{dokku_command}..."
100
+ exec(dokku_command)
101
+ end
102
+ end
103
+ end
@@ -0,0 +1,51 @@
1
+ module DokkuCli
2
+ class Cli < Thor
3
+
4
+ desc "config", "Display the app's environment variables"
5
+ def config
6
+ run_command "config #{app_name}"
7
+ end
8
+
9
+ desc "config:get KEY", "Display an environment variable value"
10
+ def config_get(key)
11
+ run_command "config:get #{app_name} #{key}"
12
+ end
13
+
14
+ desc "config:set KEY1=VALUE1 [KEY2=VALUE2 ...]", "Set one or more environment variables"
15
+ def config_set(*args)
16
+ # FIXME: Requires root to send config values with spaces
17
+ user = "dokku"
18
+
19
+ args = args.map{|arg|
20
+ key_value = arg.split("=")
21
+ if key_value.length == 2
22
+ if key_value[1].index(" ")
23
+ user = "root"
24
+ return_value = "#{key_value[0]}="
25
+ return_value += '\"'
26
+ return_value += key_value[1].gsub(/"|'/, "")
27
+ return_value += '\"'
28
+ return_value
29
+ else
30
+ "#{key_value[0]}=#{key_value[1].gsub(/"|'/, "")}"
31
+ end
32
+ else
33
+ arg
34
+ end
35
+ }
36
+
37
+ command = "ssh #{user}@#{domain} "
38
+ command += user == "root" ? "dokku " : ""
39
+ command += "config:set #{app_name} #{args.join(' ')}"
40
+
41
+ puts "Running #{command}..."
42
+ exec(command)
43
+ end
44
+
45
+ desc "config:unset KEY1 [KEY2 ...] ", "Unset one or more environment variables"
46
+ def config_unset(*args)
47
+ run_command "config:unset #{app_name} #{args.join(' ')}"
48
+ end
49
+
50
+ end
51
+ end
@@ -0,0 +1,24 @@
1
+ module DokkuCli
2
+ class Cli < Thor
3
+
4
+ desc "domains", "List custom domains for the app"
5
+ def domains
6
+ run_command "domains #{app_name}"
7
+ end
8
+
9
+ desc "domains:add DOMAIN", "Add a custom domain to the app"
10
+ def domains_set(custom_domain)
11
+ run_command "domains:set #{app_name} #{custom_domain}"
12
+ end
13
+
14
+ desc "domains:clear","Clear all custom domains for app"
15
+ def domains_clear
16
+ run_command "domains:clear #{app_name}"
17
+ end
18
+
19
+ desc "domains:remove DOMAIN", "Remove a custom domain from the app"
20
+ def domains_remove(custom_domain)
21
+ run_command "domains:remove #{app_name} #{custom_domain}"
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,9 @@
1
+ module DokkuCli
2
+ class Cli < Thor
3
+
4
+ desc "nginx:build", "(Re)builds nginx config for the app"
5
+ def nginx_build
6
+ run_command "nginx:build-config #{app_name}"
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,24 @@
1
+ module DokkuCli
2
+ class Cli < Thor
3
+
4
+ desc "ps", "List processes running in app container(s)"
5
+ def ps
6
+ run_command "ps #{app_name}"
7
+ end
8
+
9
+ desc "ps:rebuild", "Rebuild the app"
10
+ def ps_rebuild
11
+ run_command "ps:rebuild #{app_name}"
12
+ end
13
+
14
+ desc "ps:restart", "Restart the app container"
15
+ def ps_restart
16
+ run_command "ps:restart #{app_name}"
17
+ end
18
+
19
+ desc "ps:start", "Start the app container"
20
+ def ps_start
21
+ run_command "ps:start #{app_name}"
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,3 @@
1
+ module DokkuCli
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dokku-cli
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Sebastian Szturo
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.19'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.19'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.7'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.7'
41
+ description: Command line tool for Dokku.
42
+ email:
43
+ - s.szturo@me.com
44
+ executables:
45
+ - dokku
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".gitignore"
50
+ - Gemfile
51
+ - LICENSE.txt
52
+ - README.md
53
+ - Rakefile
54
+ - bin/dokku
55
+ - dokku-cli.gemspec
56
+ - lib/dokku_cli.rb
57
+ - lib/dokku_cli/config.rb
58
+ - lib/dokku_cli/domains.rb
59
+ - lib/dokku_cli/nginx.rb
60
+ - lib/dokku_cli/ps.rb
61
+ - lib/dokku_cli/version.rb
62
+ homepage: http://github.com/SebastianSzturo/dokku-cli
63
+ licenses:
64
+ - MIT
65
+ metadata: {}
66
+ post_install_message:
67
+ rdoc_options: []
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ requirements: []
81
+ rubyforge_project:
82
+ rubygems_version: 2.4.5
83
+ signing_key:
84
+ specification_version: 4
85
+ summary: Command line tool for Dokku.
86
+ test_files: []