simple-rails-deploy 0.0.1 → 0.3
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.
- data/CHANGELOG +3 -0
- data/README.md +34 -26
- data/lib/deploy/rvm.rb +0 -2
- data/lib/deploy/sharing-files.rb +3 -3
- data/lib/deploy/stage/USAGE +7 -0
- data/lib/deploy/stage/stage_generator.rb +19 -0
- data/lib/deploy/stage/templates/stage.rb.erb +22 -0
- data/lib/simple-rails-deploy/common.rb +5 -0
- data/lib/simple-rails-deploy/railtie.rb +4 -0
- data/simple-rails-deploy.gemspec +2 -2
- metadata +36 -12
data/CHANGELOG
ADDED
data/README.md
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
Simple rails deploy
|
2
2
|
===================
|
3
3
|
|
4
|
-
This gem is made to get everything I need for deploy in one place
|
4
|
+
This gem is made to get everything I need for deploy in one place:
|
5
5
|
* capistrano configuration
|
6
|
-
* unicorn configuration
|
7
|
-
* unicorn startup rake task
|
6
|
+
* unicorn configuration and startup rake task
|
8
7
|
* nginx configuration
|
9
8
|
* all stuff and magic to use this all together
|
10
9
|
|
@@ -14,8 +13,7 @@ Assumptions
|
|
14
13
|
* Project uses asset pipeline for asset packing.
|
15
14
|
* Project uses bundler to handle dependencies.
|
16
15
|
* Project uses git.
|
17
|
-
* Each project has its own user
|
18
|
-
* Nobody likes setting up ruby web servers.
|
16
|
+
* Each project has its own user.
|
19
17
|
|
20
18
|
What does it provide
|
21
19
|
=======
|
@@ -24,7 +22,7 @@ Small common capistrano recipes.
|
|
24
22
|
|
25
23
|
Limitations
|
26
24
|
========
|
27
|
-
|
25
|
+
Unicorn can be less flexibly configured
|
28
26
|
|
29
27
|
Step by step instruction
|
30
28
|
======
|
@@ -34,7 +32,7 @@ Server-side:
|
|
34
32
|
```bash
|
35
33
|
# Server initial setup
|
36
34
|
apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion
|
37
|
-
#Use other package if using
|
35
|
+
#Use other package if not using PostgreSQL
|
38
36
|
apt-get install postgresql libpq-dev
|
39
37
|
|
40
38
|
# Creating new ssh user
|
@@ -46,8 +44,6 @@ nano .ssh/authorized_keys
|
|
46
44
|
chmod -R 700 .ssh
|
47
45
|
chown -R <project-name>:<project-name> .ssh
|
48
46
|
|
49
|
-
# Workaround to add
|
50
|
-
|
51
47
|
# Database credentials
|
52
48
|
su postgres
|
53
49
|
createuser <project-name>
|
@@ -62,15 +58,15 @@ server {
|
|
62
58
|
root /home/<projectname>/app/current/public;
|
63
59
|
try_files $uri/index.html $uri.html $uri @app;
|
64
60
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
61
|
+
location @app {
|
62
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
63
|
+
proxy_set_header Host $http_host;
|
64
|
+
proxy_redirect off;
|
65
|
+
|
66
|
+
# If you don't find the filename in the static files
|
67
|
+
# Then request it from the unicorn server
|
68
|
+
proxy_pass http://unix:/home/<projectname>/app/shared/tmp/unicorn.sock:;
|
69
|
+
}
|
74
70
|
}
|
75
71
|
```
|
76
72
|
|
@@ -85,7 +81,7 @@ require 'simple-rails-deploy/common'
|
|
85
81
|
load 'deploy/rvm'
|
86
82
|
#Use unicorn as web server
|
87
83
|
load 'deploy/unicorn'
|
88
|
-
#Uncomment if you want to add 'deny all' robots.txt
|
84
|
+
#Uncomment if you want to add 'deny all' robots.txt on deploy
|
89
85
|
#load 'deploy/robots-deny-all'
|
90
86
|
|
91
87
|
#multistaging
|
@@ -102,7 +98,9 @@ set :repository, "<repo name>"
|
|
102
98
|
create file config/deploy/[stage-name].rb with contents:
|
103
99
|
```ruby
|
104
100
|
# Path to deploy folder is calculated based on appication name:
|
105
|
-
# "/home/#{application}/app/"
|
101
|
+
# set :deploy_to, "/home/#{application}/app/"
|
102
|
+
# Username is the same as application name:
|
103
|
+
# set :user, application
|
106
104
|
|
107
105
|
#set rails environment here
|
108
106
|
set :rails_env, "production"
|
@@ -111,7 +109,7 @@ set :rails_env, "production"
|
|
111
109
|
set :branch, "master"
|
112
110
|
|
113
111
|
#set server address here
|
114
|
-
set :domain, "<
|
112
|
+
set :domain, "<server-hostname>" # Required for ssh deploy
|
115
113
|
|
116
114
|
#Server roles
|
117
115
|
role :web, domain
|
@@ -121,11 +119,21 @@ role :db, domain, :primary => true
|
|
121
119
|
|
122
120
|
And run:
|
123
121
|
```bash
|
124
|
-
|
125
|
-
|
126
|
-
cap <stagename> deploy:cold
|
127
|
-
|
128
|
-
|
122
|
+
#Remove deploy:create_database if you do not need to setup database and/or create database.yml file
|
123
|
+
#Set up rvm, install ruby, initial project deploy
|
124
|
+
cap <stagename> rvm:install_rvm rvm:install_ruby deploy:create_database deploy:setup deploy:cold deploy:migrate deploy
|
125
|
+
```
|
126
|
+
Adding custom config files
|
127
|
+
======
|
128
|
+
|
129
|
+
Put them into '/home/youruser/app/shared/' folder and add to delpoy.rb:
|
130
|
+
```ruby
|
131
|
+
set :normal_symlinks, %w(
|
132
|
+
config/database.yml
|
133
|
+
tmp
|
134
|
+
config/first_custom_config.yml
|
135
|
+
config/second_custom_config.yml
|
136
|
+
)
|
129
137
|
```
|
130
138
|
|
131
139
|
License
|
data/lib/deploy/rvm.rb
CHANGED
data/lib/deploy/sharing-files.rb
CHANGED
@@ -49,6 +49,6 @@ namespace :deploy do
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
-
|
53
|
-
|
54
|
-
|
52
|
+
after 'deploy:setup', 'deploy:create_database_yml'
|
53
|
+
after 'deploy:setup', 'deploy:create_shared_tmp_folder'
|
54
|
+
after 'deploy:setup', 'deploy:fix_ssh_git'
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Deploy
|
2
|
+
class StageGenerator < Rails::Generators::NamedBase
|
3
|
+
argument :address, :banner => "ip address"
|
4
|
+
|
5
|
+
source_root File.expand_path('../templates', __FILE__)
|
6
|
+
|
7
|
+
def append_stage_to_deploy_rb
|
8
|
+
sentinel = /set :stages,?+\n/
|
9
|
+
|
10
|
+
append_to_file 'config/deploy.rb', "\nset :stages, self.stages.push('#{name}') \n"
|
11
|
+
end
|
12
|
+
|
13
|
+
def create_stagefile
|
14
|
+
@app_name = Rails.application.class.to_s.split("::").first.underscore
|
15
|
+
|
16
|
+
template "stage.rb.erb", "config/deploy/#{name}.rb"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# Path to deploy folder is calculated based on appication name:
|
2
|
+
# set :deploy_to, "/home/<%= @app_name %>/app/"
|
3
|
+
|
4
|
+
#set rails environment here
|
5
|
+
set :rails_env, "production"
|
6
|
+
|
7
|
+
#set git branch here
|
8
|
+
set :branch, "master"
|
9
|
+
|
10
|
+
#set server address here
|
11
|
+
set :domain, "<%= address %>"
|
12
|
+
|
13
|
+
#set port for deployment server connection
|
14
|
+
set :port, 22
|
15
|
+
|
16
|
+
# Username is the same as application name:
|
17
|
+
set :user, "<%= @app_name %>"
|
18
|
+
|
19
|
+
#Server roles
|
20
|
+
role :web, domain
|
21
|
+
role :app, domain
|
22
|
+
role :db, domain, :primary => true
|
data/simple-rails-deploy.gemspec
CHANGED
@@ -5,10 +5,10 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "simple-rails-deploy"
|
8
|
-
s.version = '0.
|
8
|
+
s.version = '0.3'
|
9
9
|
|
10
10
|
s.authors = ["Alex Rozumey"]
|
11
|
-
s.description = "
|
11
|
+
s.description = "Simple rails deploy makes rails deployment process fun!"
|
12
12
|
s.email = "brain-geek@yandex.ua"
|
13
13
|
|
14
14
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple-rails-deploy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.3'
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-11-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,15 @@ dependencies:
|
|
21
21
|
version: 3.0.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 3.0.0
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: capistrano
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ! '>='
|
@@ -32,10 +37,15 @@ dependencies:
|
|
32
37
|
version: '0'
|
33
38
|
type: :runtime
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: rvm-capistrano
|
38
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
51
|
- - ! '>='
|
@@ -43,10 +53,15 @@ dependencies:
|
|
43
53
|
version: '0'
|
44
54
|
type: :runtime
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
47
62
|
- !ruby/object:Gem::Dependency
|
48
63
|
name: capistrano_colors
|
49
|
-
requirement:
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
50
65
|
none: false
|
51
66
|
requirements:
|
52
67
|
- - ! '>='
|
@@ -54,8 +69,13 @@ dependencies:
|
|
54
69
|
version: '0'
|
55
70
|
type: :runtime
|
56
71
|
prerelease: false
|
57
|
-
version_requirements:
|
58
|
-
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
description: Simple rails deploy makes rails deployment process fun!
|
59
79
|
email: brain-geek@yandex.ua
|
60
80
|
executables: []
|
61
81
|
extensions: []
|
@@ -64,6 +84,7 @@ extra_rdoc_files:
|
|
64
84
|
- README.md
|
65
85
|
files:
|
66
86
|
- .gitignore
|
87
|
+
- CHANGELOG
|
67
88
|
- LICENSE.txt
|
68
89
|
- README.md
|
69
90
|
- Rakefile
|
@@ -72,6 +93,9 @@ files:
|
|
72
93
|
- lib/deploy/robots-deny-all.rb
|
73
94
|
- lib/deploy/rvm.rb
|
74
95
|
- lib/deploy/sharing-files.rb
|
96
|
+
- lib/deploy/stage/USAGE
|
97
|
+
- lib/deploy/stage/stage_generator.rb
|
98
|
+
- lib/deploy/stage/templates/stage.rb.erb
|
75
99
|
- lib/deploy/unicorn.rb
|
76
100
|
- lib/simple-rails-deploy.rb
|
77
101
|
- lib/simple-rails-deploy/common.rb
|
@@ -99,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
99
123
|
version: '0'
|
100
124
|
requirements: []
|
101
125
|
rubyforge_project:
|
102
|
-
rubygems_version: 1.8.
|
126
|
+
rubygems_version: 1.8.22
|
103
127
|
signing_key:
|
104
128
|
specification_version: 3
|
105
129
|
summary: ''
|