Skip to content

Commit f0aa063

Browse files
committed
Add a scroll for deployment with AppScrolls
[#27824317] depends on drnic/appscrolls#14 drnic/appscrolls#12
1 parent 6a7a7a7 commit f0aa063

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed

scrolls/shellycloud.rb

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
@name = File.basename(File.expand_path("."))
2+
3+
gem_group :development do
4+
gem 'shelly', '>= 0.0.62'
5+
end
6+
7+
# check if user has account on shelly
8+
`shelly list`
9+
if $? != 0
10+
say_custom "shellycloud", "Please log in or register with Shelly Cloud."
11+
say_custom "shellycloud", "You can do that by running `shelly login` or `shelly register`"
12+
exit 1
13+
end
14+
15+
required_dbs = %w[postgresql mongodb redis]
16+
required_app_servers = %w[thin]
17+
18+
selected_db = required_dbs.find { |db| scroll? db }
19+
unless selected_db
20+
say_custom "shellycloud", "Please include a DB choice from: #{required_dbs.join ", "}"
21+
exit_now = true
22+
end
23+
24+
selected_app_server = required_app_servers.find { |app| scroll? app }
25+
unless selected_app_server
26+
say_custom "shellycloud", "Please include an App Server choice from: #{required_app_servers.join ", "}"
27+
exit_now = true
28+
end
29+
30+
exit 1 if exit_now
31+
32+
after_everything do
33+
framework_env = multiple_choice "Which framework environment?", [
34+
['Production', 'production'],
35+
['Staging', 'staging']
36+
]
37+
38+
app_name = (@repo_name && @repo_name.size > 0) ? @repo_name : @name
39+
app_name.gsub!(/\W/, '') # only letters and numbers
40+
app_name.gsub!("_", "-")
41+
42+
instance_size = "large"
43+
if framework_env == "production"
44+
say_custom "shellycloud", "Using large instances for production environment"
45+
else
46+
say_custom "shellycloud", "Using small instances for staging environment"
47+
instance_size = "small"
48+
end
49+
50+
code_name = "#{app_name}-#{framework_env}"
51+
52+
name = File.basename(".")
53+
command = "bundle exec shelly add --code_name #{code_name} "
54+
command += "--databases=#{selected_db} " if selected_db
55+
command += "--size=#{instance_size}"
56+
57+
run command
58+
59+
say_custom "shellycloud", "Adding Cloudfile to your repo"
60+
run "git add Cloudfile"
61+
run "git commit -m 'Added Cloudfile'"
62+
63+
say_custom "shellycloud", "Pushing code to Shelly Cloud"
64+
sleep(5) # sleep for ssh key to generate on shelly
65+
run "git push #{code_name} master"
66+
67+
say_custom "shellycloud", "Your application in now configured for Shelly Cloud"
68+
say_custom "shellycloud", "You can start it by running `shelly start`."
69+
say_custom "shellycloud", "For more information, check https://shellycloud.com/documentation"
70+
end
71+
72+
__END__
73+
74+
name: Shelly Cloud
75+
description: Ruby Cloud Hosting in Europe
76+
author: grk
77+
78+
category: deployment
79+
exclusive: deployment
80+
81+
requires: [compile_assets, serve_static_assets, git, thin]
82+
run_after: [git]

0 commit comments

Comments
 (0)