deployless 0.0.1 → 0.0.2
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.
- checksums.yaml +4 -4
- data/bin/dpls +23 -1
- data/lib/deployless/dokku.rb +104 -0
- data/lib/deployless/version.rb +1 -1
- data/lib/deployless.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aab6d3d445d5d9e5cff066a80cbdfb755223a78213501c7c8d5298a6de4ca770
|
4
|
+
data.tar.gz: c8cd0548721f23df5816c120d2c4aa5e9f7d04181efced5e2eb51fde483e5687
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b230388676174384f56d044272b83eaa32b0bd2600224a2997ea3d632aa2fcd7b2265dcfe6318682812772612a7aacc923a991f944646a2242cdaf2a3f60ff80
|
7
|
+
data.tar.gz: e1d73bacec3fa78d4494a96a616f1dac3d8e84c663bf1b5926f5168a7a893109176b11cfa310a8451305dd2df24474318ad01963ceb9885355cf4494b7b14a31
|
data/bin/dpls
CHANGED
@@ -5,6 +5,8 @@ require 'tty-prompt'
|
|
5
5
|
require 'tty-file'
|
6
6
|
require 'yaml'
|
7
7
|
|
8
|
+
require_relative '../lib/deployless'
|
9
|
+
|
8
10
|
class Command
|
9
11
|
include TTY::Option
|
10
12
|
|
@@ -27,13 +29,33 @@ when 'init'
|
|
27
29
|
key(:ssh_key_path).ask("SSH key path:", required: true, default: '~/.ssh/id_rsa')
|
28
30
|
key(:email).ask("Email:", required: true)
|
29
31
|
key(:app_name).ask("Application name:", required: true)
|
32
|
+
key(:domain).ask("Domain:", required: true)
|
30
33
|
end
|
31
34
|
|
32
35
|
TTY::File.create_file('.deployless.yml', result.to_yaml)
|
33
36
|
TTY::File.safe_append_to_file(".gitignore", ".deployless.yml")
|
34
37
|
when 'prepare'
|
38
|
+
prompt = TTY::Prompt.new
|
35
39
|
config = YAML.load_file('.deployless.yml')
|
36
|
-
|
40
|
+
dokku = ::Deployless::Dokku.new(config)
|
41
|
+
dokku.configure
|
42
|
+
dokku.install
|
43
|
+
dokku.add_ssh_key
|
44
|
+
dokku.create_app
|
45
|
+
dokku.set_initial_environment_variables
|
46
|
+
dokku.install_postgres
|
47
|
+
result = "No"
|
48
|
+
|
49
|
+
while result == "No"
|
50
|
+
result = prompt.enum_select("Add DNS record for the domain #{config.fetch(:domain)} - type: A, value: #{config.fetch(:production_server_ip)}. Is it done?", ["Yes", "No"], required: true)
|
51
|
+
if result == "No"
|
52
|
+
puts "Please add DNS record for the domain #{config.fetch(:domain)} - type: A, value: #{config.fetch(:production_server_ip)} and confirm when done."
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
dokku.configure_domain
|
57
|
+
dokku.configure_ssl
|
58
|
+
dokku.print_instructions
|
37
59
|
else
|
38
60
|
puts 'Unknown command'
|
39
61
|
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
require 'sshkit'
|
2
|
+
require 'sshkit/dsl'
|
3
|
+
require 'securerandom'
|
4
|
+
|
5
|
+
module Deployless
|
6
|
+
class Dokku
|
7
|
+
include SSHKit::DSL
|
8
|
+
|
9
|
+
def initialize(config)
|
10
|
+
@config = config
|
11
|
+
end
|
12
|
+
|
13
|
+
def configure
|
14
|
+
SSHKit::Backend::Netssh.configure do |ssh|
|
15
|
+
ssh.connection_timeout = 30
|
16
|
+
ssh.ssh_options = {
|
17
|
+
user: @config.fetch(:production_server_username),
|
18
|
+
keys: %w(@config.fetch(:ssh_key_path)),
|
19
|
+
forward_agent: false,
|
20
|
+
auth_methods: %w(publickey)
|
21
|
+
}
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def install
|
26
|
+
on [@config.fetch(:production_server_ip)] do |host|
|
27
|
+
execute :wget, '-NP', '.', 'https://dokku.com/bootstrap.sh'
|
28
|
+
execute :sudo, 'DOKKU_TAG=v0.35.12', 'bash', 'bootstrap.sh'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def add_ssh_key
|
33
|
+
public_key = File.read(File.expand_path(@config.fetch(:ssh_key_path) + '.pub'))
|
34
|
+
|
35
|
+
on [@config.fetch(:production_server_ip)] do |host|
|
36
|
+
execute "echo '#{public_key}' | sudo dokku ssh-keys:add admin"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def create_app
|
41
|
+
app_name = @config.fetch(:app_name)
|
42
|
+
|
43
|
+
on [@config.fetch(:production_server_ip)] do |host|
|
44
|
+
execute :dokku, 'apps:create', app_name
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def set_initial_environment_variables
|
49
|
+
app_name = @config.fetch(:app_name)
|
50
|
+
secret_key_base = SecureRandom.hex(64)
|
51
|
+
|
52
|
+
environment_variables = {
|
53
|
+
'SECRET_KEY_BASE' => secret_key_base,
|
54
|
+
'RAILS_ENV' => 'production',
|
55
|
+
'RAKE_ENV' => 'production',
|
56
|
+
'RAILS_LOG_TO_STDOUT' => 'enabled',
|
57
|
+
'RAILS_SERVE_STATIC_FILES' => 'enabled'
|
58
|
+
}
|
59
|
+
|
60
|
+
on [@config.fetch(:production_server_ip)] do |host|
|
61
|
+
execute :dokku, 'config:set', app_name, environment_variables.map { |key, value| "#{key}=#{value}" }.join(' ')
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def install_postgres
|
66
|
+
app_name = @config.fetch(:app_name)
|
67
|
+
|
68
|
+
on [@config.fetch(:production_server_ip)] do |host|
|
69
|
+
execute :sudo, 'dokku', 'plugin:install', 'https://github.com/dokku/dokku-postgres.git'
|
70
|
+
execute :dokku, 'postgres:create', "#{app_name}-db"
|
71
|
+
execute :dokku, 'postgres:link', "#{app_name}-db", app_name
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def configure_domain
|
76
|
+
domain = @config.fetch(:domain)
|
77
|
+
app_name = @config.fetch(:app_name)
|
78
|
+
|
79
|
+
on [@config.fetch(:production_server_ip)] do |host|
|
80
|
+
execute :dokku, 'domains:clear-global'
|
81
|
+
execute :dokku, 'domains:clear', app_name
|
82
|
+
execute :dokku, 'domains:add', app_name, domain
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def configure_ssl
|
87
|
+
email = @config.fetch(:email)
|
88
|
+
app_name = @config.fetch(:app_name)
|
89
|
+
|
90
|
+
on [@config.fetch(:production_server_ip)] do |host|
|
91
|
+
execute :sudo, 'dokku', 'plugin:install', 'https://github.com/dokku/dokku-letsencrypt.git'
|
92
|
+
execute :dokku, 'letsencrypt:set', app_name, 'email', email
|
93
|
+
execute :dokku, 'letsencrypt:enable', app_name
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def print_instructions
|
98
|
+
puts "Configure deployment by adding git remote:"
|
99
|
+
puts "git remote add dokku dokku@#{@config.fetch(:production_server_ip)}:#{@config.fetch(:app_name)}"
|
100
|
+
puts "Then you can deploy by running:"
|
101
|
+
puts "git push dokku main"
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
data/lib/deployless/version.rb
CHANGED
data/lib/deployless.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
require_relative 'deployless/dokku'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: deployless
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paweł Dąbrowski
|
@@ -109,6 +109,7 @@ extra_rdoc_files: []
|
|
109
109
|
files:
|
110
110
|
- bin/dpls
|
111
111
|
- lib/deployless.rb
|
112
|
+
- lib/deployless/dokku.rb
|
112
113
|
- lib/deployless/version.rb
|
113
114
|
homepage: https://github.com/impactahead/deployless
|
114
115
|
licenses:
|