capistrano-bolt 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6dc82010cdfbbe60dfc1ac1fa897b096298bea39
4
- data.tar.gz: 26e247c7189aa4b34bdb821d36049c93d80f8563
3
+ metadata.gz: f4d814bf5da8a37d191d20fc319eeabb88253f99
4
+ data.tar.gz: 3a74262c6856e9bcfa2234741472e8552cd8f11f
5
5
  SHA512:
6
- metadata.gz: 062cee3c5bbb675ed06487e6f1a4d1ef006eeee7ffd124247bf4a04b85732329d8aeb73df8a7ab7f72d9b3b738c9d48fc11a7f292f924b6c11639ab9e1a01ae0
7
- data.tar.gz: f819c70367a14f331cbaf12e67034bf4eda040b959e82c520e647ee9582105b867157dc39988be3c891a395c3bd394548b5f86d20f118c41099feb774d230212
6
+ metadata.gz: 9aef67b9509cdf405610b00b1453fa333c0a5f789e61f14a9bfc5bef2b140ed00f5077f8242dceb7062596dac2776feacd1db48e672c98fb7ca810d13e80b293
7
+ data.tar.gz: 1029f1c25dfe1d9fef51a81d1995108578b5825c90fab381cf020b23c3e9a213f8595a24cc7c074dba1467f9a6f8783d159983849e9862ae8bb6d4b29b8b8e92
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Heroku-like easy deployment for Rails 4 with Capistrano 3, Puma, Nginx and Postgresql.
2
2
 
3
+ **UPDATE:** A very brief documentation is updated at the end of this readme after noticing that many people are trying this gem within few hours of publishing. Thanks for the support guy but sorry for publising the gem without getting the documentation ready at first place.
4
+
3
5
  As the title says, this gem provides a super simple way to deploy your rails app.
4
6
  I created this after I got tired of trying numerous capistrano receipes and gem. While I learned a lot from these gems and respect their authors for the knowledge shared with the community to the core of my heart, none of the existing gems that I tried simplified the deployment process as I wanted. Here is the workflow that I ever wanted.
5
7
 
@@ -18,6 +20,8 @@ Install a gem on my rails app and issue a command like below
18
20
 
19
21
  NO Step 2. No need to login to the server to create nginx vhost file or postgres database or to create environment variables. All these are already taken care by Step 1.
20
22
 
23
+ Note: currently the gem requires a few configuration task in your rails app which will be automated in future.
24
+
21
25
  ---
22
26
 
23
27
  If you are like me and want a simple deployment process like above then this gem is for you.
@@ -29,5 +33,111 @@ If you are like me and want a simple deployment process like above then this gem
29
33
  3. configuring puma app server with the created Nginx vhost file
30
34
 
31
35
  ---
32
- Documentation for using this gem will be shortly updated.
36
+ This gem is currently under active development but can be used for deploying as of now. The pending tasks as of now is to further simplify the installation and setup process and to make this gem truly a one step deploy gem.
37
+
38
+ <strike>Documentation for using this gem will be shortly updated.</strike>
39
+ ## A very brief documentation for the early adopters.
40
+ (I will get a detailed documetation in the next two days.)
41
+
42
+ ### Prerequisites
43
+ Bolt assumes that you have nginx, postgresql and ruby installed on your server. If not, you can install all these with the following command
44
+
45
+ Nginx
46
+ ```
47
+ sudo apt-get install nginx
48
+ ```
49
+
50
+ Postgresql
51
+ ```
52
+ sudo apt-get install postgresql postgresql-develop
53
+ ```
54
+
55
+ Ruby
56
+
57
+ ```
58
+ sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties
59
+ wget http://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.2.tar.gz
60
+ tar -zxvf ruby-2.1.2.tar.gz
61
+ cd ruby-2.1.2/
62
+ ./configure
63
+ make
64
+ sudo make install
65
+ ```
66
+
67
+ Check if your postgres database has been configured for password authentication.
68
+ Open `/etc/postgresq/9.3/main/pg_hba.conf` [the value 9.3 could be different on your server based on your postgres version]
69
+
70
+ and change the following
71
+ ```
72
+ # "local" is for Unix domain socket connections only
73
+ local all all peer
74
+ ```
75
+ to
76
+ ```
77
+ # "local" is for Unix domain socket connections only
78
+ local all all md5
79
+ ```
80
+
81
+ Then restart the postgres server to load the new configuration
82
+ ```
83
+ sudo /etc/init.d/postgresql restart
84
+ ```
85
+
86
+ Bolt requires an user on the server that can use `sudo` without password.
87
+ ```
88
+ adduser deployer
89
+ echo "deployer ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
90
+ ```
91
+
92
+ With the above setup, the server setup for Bolt is complete. If your server is already setup like above there is no need to do all these steps.
93
+
94
+ ## Using Bolt
95
+
96
+ ### Installing gem
97
+ in your gemfile add
98
+ ```
99
+ # Gemfile
100
+ gem 'dotenv-rails'
101
+ ```
102
+ as the first gem. This is a requirement for Bolt setup to work currently. In near future, this requirement will be eliminated.
103
+
104
+ then add
105
+ ```
106
+ # Gemfile
107
+ gem 'puma'
108
+ gem 'capistrano-bolt', group: :development
109
+ ```
110
+
111
+ and run
112
+ ```
113
+ bundle install
114
+ ```
115
+
116
+ ### Configuring
117
+ run
118
+ ```
119
+ cap install
120
+ ```
121
+ and change the contents of`Capfile`, `deploy.rb` and `production.rb` file with contents as given in https://github.com/opendrops/capistrano-bolt/tree/master/lib/capistrano/templates/capistrano
122
+
123
+ This step will be automated in future. For now, just use the given templates as reference to modify the values.
124
+
125
+ If you use rbenv or rvm or chruby, be sure to add these gems in your gemfile and uncomment the require statements for these gems in `Capfile`.
126
+
127
+ ### Deploying
128
+ Run the following command for the first time when you deploy the app
129
+ ```
130
+ cap production setup:all
131
+ ```
132
+ The above command configures your nginx, postgresql, dotenv file.
133
+
134
+ Now deploy your app using
135
+ ```
136
+ cap production deploy
137
+ ```
138
+
139
+ wait for the task to complete and visit the url for your app domain. You should now see your app fully deployed on your server without you having to login to the server and do many of the repetitive boring tasks.
140
+
141
+ ---
142
+ **Note:** I have written this quick install document seeing that many people have tried to download this gem without any documentation. So this document is prepared in a hurry to fill this gap. If you are getting errors or if the information in this document is inadequate, contact me @ shankar AT opendrops DOT com and I shall be able to guide you as soon as possible.
33
143
 
@@ -1,5 +1,5 @@
1
1
  module Capistrano
2
2
  module Bolt
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
@@ -1,4 +1,14 @@
1
+ # Override Capistrano install task
2
+ load File.expand_path('../tasks/setup.rake', __FILE__)
3
+
4
+ # Load nginx task
1
5
  load File.expand_path('../tasks/nginx/nginx.rake', __FILE__)
6
+
7
+ # Load puma task
2
8
  load File.expand_path('../tasks/puma/puma.rake', __FILE__)
9
+
10
+ # Load postgresql task
3
11
  load File.expand_path('../tasks/postgresql/postgresql.rake', __FILE__)
12
+
13
+ # Load server setup task
4
14
  load File.expand_path('../tasks/setup.rake', __FILE__)
@@ -8,9 +8,9 @@ task :install do
8
8
  config_dir = Pathname.new('config')
9
9
  deploy_dir = config_dir.join('deploy')
10
10
 
11
- deploy_rb = File.expand_path("../../templates/deploy.rb.erb", __FILE__)
12
- stage_rb = File.expand_path("../../templates/stage.rb.erb", __FILE__)
13
- capfile = File.expand_path("../../templates/Capfile", __FILE__)
11
+ deploy_rb = File.expand_path("../../templates/capistrano/deploy.rb.erb", __FILE__)
12
+ stage_rb = File.expand_path("../../templates/capistrano/stage.rb.erb", __FILE__)
13
+ capfile = File.expand_path("../../templates/capistrano/Capfile", __FILE__)
14
14
 
15
15
  mkdir_p deploy_dir
16
16
 
@@ -6,6 +6,9 @@ namespace :setup do
6
6
  task :postgresql do
7
7
  invoke "postgresql:create_role"
8
8
  invoke "postgresql:create_db"
9
+ from = File.expand_path("../../templates/postgresql/database.yml.erb", __FILE__)
10
+ to = File.join(shared_path, 'config/database.yml')
11
+ upload_template(from, to)
9
12
  end
10
13
 
11
14
  desc 'add site, enable and reload nginx'
@@ -0,0 +1,27 @@
1
+ # Load DSL and set up stages
2
+ require 'capistrano/setup'
3
+
4
+ # Include default deployment tasks
5
+ require 'capistrano/deploy'
6
+
7
+ # Include tasks from other gems included in your Gemfile
8
+ #
9
+ # For documentation on these, see for example:
10
+ #
11
+ # https://github.com/capistrano/rvm
12
+ # https://github.com/capistrano/rbenv
13
+ # https://github.com/capistrano/chruby
14
+ # https://github.com/capistrano/bundler
15
+ # https://github.com/capistrano/rails
16
+ #
17
+ # require 'capistrano/rvm'
18
+ # require 'capistrano/rbenv'
19
+ # require 'capistrano/chruby'
20
+
21
+ require 'capistrano/bundler'
22
+ require 'capistrano/rails/assets'
23
+ require 'capistrano/rails/migrations'
24
+ require 'capistrano/bolt'
25
+
26
+ # Load custom tasks from `lib/capistrano/tasks' if you have any defined
27
+ Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
@@ -0,0 +1,35 @@
1
+ # config valid only for Capistrano 3.1
2
+ lock '<%= Capistrano::VERSION %>'
3
+
4
+ # Configure these values
5
+ set :application, "my_app_name"
6
+ set :repo_url, "git@example.com:me/my_repo.git"
7
+ set :deploy_to, "/var/www/#{fetch(:application)}"
8
+
9
+ # Don't remove the existing values as it's needed for capistrano-bolt to work
10
+ # You may add more files or directories to this list if needed.
11
+ set :linked_files, %w{.env config/database.yml}
12
+ set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
13
+
14
+ ## Changes these default values only if needed
15
+
16
+ # Default branch is :master
17
+ # ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }.call
18
+
19
+ # Default value for :scm is :git
20
+ # set :scm, :git
21
+
22
+ # Default value for :format is :pretty
23
+ # set :format, :pretty
24
+
25
+ # Default value for :log_level is :debug
26
+ # set :log_level, :debug
27
+
28
+ # Default value for :pty is false
29
+ # set :pty, true
30
+
31
+ # Default value for default_env is {}
32
+ # set :default_env, { path: "/opt/ruby/bin:$PATH" }
33
+
34
+ # Default value for keep_releases is 5
35
+ # set :keep_releases, 5
@@ -0,0 +1,7 @@
1
+ # Change example.com to your server hostname and 'deploy' to the user name of your server
2
+ # that you can use to login to the server from your workstation
3
+
4
+ server 'example.com', user: 'deploy', roles: %w{web app db}
5
+
6
+ # Change myapp.com to the domain name intended for accessing your app by public
7
+ set :domain_name, 'myapp.com'
@@ -3,7 +3,7 @@ upstream <%= fetch(:application) %>_puma {
3
3
  }
4
4
 
5
5
  server {
6
- server_name <%= fetch(:server_name) %>;
6
+ server_name <%= fetch(:domain_name) %>;
7
7
  listen 80;
8
8
  root <%= fetch(:deploy_to) %>/current/public;
9
9
 
@@ -28,7 +28,7 @@ server {
28
28
 
29
29
  <% if fetch(:enable_ssl) %>
30
30
  server {
31
- server_name <%= fetch(:server_name) %>;
31
+ server_name <%= fetch(:domain_name) %>;
32
32
  listen 443;
33
33
  root <%= fetch(:deploy_to) %>/current/public;
34
34
 
@@ -54,4 +54,4 @@ server {
54
54
  ssl_certificate <%= fetch(:deploy_to) %>/shared/ssl_cert.crt;
55
55
  ssl_certificate_key <%= fetch(:deploy_to) %>/shared/ssl_private_key.key;
56
56
  }#
57
- <% end %>
57
+ <% end %>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-bolt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shankar Dhanasekaran
@@ -73,6 +73,9 @@ files:
73
73
  - lib/capistrano/tasks/postgresql/postgresql.rake
74
74
  - lib/capistrano/tasks/puma/puma.rake
75
75
  - lib/capistrano/tasks/setup.rake
76
+ - lib/capistrano/templates/capistrano/Capfile
77
+ - lib/capistrano/templates/capistrano/deploy.rb.erb
78
+ - lib/capistrano/templates/capistrano/stage.rb.erb
76
79
  - lib/capistrano/templates/dotenv.erb
77
80
  - lib/capistrano/templates/nginx/nginx.conf.erb
78
81
  - lib/capistrano/templates/postgresql/database.yml.erb