railman-deployment 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fb7bf2d79b0a2c2ba10510ca5b23fc2344554cf5
4
+ data.tar.gz: aef307682daf675a527806056c51fd8f2df19a80
5
+ SHA512:
6
+ metadata.gz: 6cf6f366a9939003c3899d8f1a94a95514bfde149cb5001a5e533791b0b5fb3b5e43f4dbdcaef7f051f04fe3449dd514929929a885e04dc39ccf2ba99ae3cce7
7
+ data.tar.gz: 07f325aea5d45f113eeb77748fb6370657df7d0bad635041ae3bd45dd2442732c4cda8856dfb9341c889f690f192dd57efa684e0610584ab9fd0c8ce27f24e48
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.3.0
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.5
4
+ - 2.2.3
5
+ - 2.3.0
6
+ before_install: gem install bundler -v 1.11.2
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in railman-deployment.gemspec
4
+ gemspec
data/LICENCE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Igor Jancev
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,56 @@
1
+ # Railman Deployment
2
+
3
+ [![Gem Version](http://img.shields.io/gem/v/railman-deployment.svg)][gem]
4
+ [![Build Status](http://img.shields.io/travis/igorj/railman-deployment.svg)][travis]
5
+ [![Dependency Status](http://img.shields.io/gemnasium/igorj/railman-deployment.svg)][gemnasium]
6
+ [![Code Climate](http://img.shields.io/codeclimate/github/igorj/railman-deployment.svg)][codeclimate]
7
+ [![Coverage Status](http://img.shields.io/coveralls/igorj/railman-deployment.svg)][coveralls]
8
+
9
+ [gem]: https://rubygems.org/gems/railman-deployment
10
+ [travis]: http://travis-ci.org/igorj/railman-deployment
11
+ [gemnasium]: https://gemnasium.com/igorj/railman-deployment
12
+ [codeclimate]: https://codeclimate.com/github/igorj/railman-deployment
13
+ [coveralls]: https://coveralls.io/r/igorj/railman-deployment
14
+
15
+
16
+ railman-deployment gem adds capistrano tasks for automated deployment of rails applications generated by railman
17
+
18
+ ## Installation
19
+
20
+ Add this line to your application's Gemfile:
21
+
22
+ ```ruby
23
+ gem 'railman-deployment'
24
+ ```
25
+
26
+ And then execute:
27
+
28
+ $ bundle
29
+
30
+
31
+ ## Usage
32
+
33
+ Add `require 'railman/deployment'` to Capfile and you'll get following capistrano tasks:
34
+
35
+ - `cap ENV setup` => Setup rails application for the first time on a server
36
+ - `cap ENV deploy` => Deploy rails application
37
+ - `cap ENV remove` => Remove the application completely from the server
38
+ - `cap ENV reset_server` => Recreate server database from db/<application_name>.sql
39
+ - `cap ENV sync_local` => Synchronize local database with the production database
40
+
41
+
42
+ ## Development
43
+
44
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
45
+
46
+ To install this gem onto your local machine, run `bundle exec rake install`.
47
+
48
+ To release a new version, run `bundle exec rake release_patch`, `bundle exec rake release_minor`, oder `bundle exec rake release_major`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to https://rubygems.org.
49
+
50
+ ## Contributing
51
+
52
+ Bug reports and pull requests are welcome on github at https://github.com/igorj/railman-deployment.
53
+
54
+ ## License
55
+
56
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,38 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ end
9
+
10
+ task :patch do
11
+ system "gem bump --tag"
12
+ end
13
+
14
+ task :minor do
15
+ system "gem bump --version minor --tag"
16
+ end
17
+
18
+ task :major do
19
+ system "gem bump --version major --tag"
20
+ end
21
+
22
+ task :publish => [:build] do
23
+ $VERBOSE = nil
24
+ load 'railman-deployment/version.rb'
25
+ system "gem push pkg/railman-deployment-#{RailmanDeployment::VERSION}.gem"
26
+ end
27
+
28
+ desc "Bump patch version, create git tag, build the gem and release to geminabox (default)"
29
+ task :release_patch => [:test, :patch, :publish]
30
+
31
+ desc "Bump minor version, create git tag, build the gem and release to geminabox"
32
+ task :release_minor => [:test, :minor, :publish]
33
+
34
+ desc "Bump major version, create git tag, build the gem and release to geminabox"
35
+ task :release_major => [:test, :major, :publish]
36
+
37
+
38
+ task :default => :test
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "<%= @gem_name %>"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,4 @@
1
+ require 'railman-deployment/version'
2
+
3
+ module RailmanDeployment
4
+ end
@@ -0,0 +1,3 @@
1
+ module RailmanDeployment
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1 @@
1
+ require_relative 'deployment/tasks'
@@ -0,0 +1 @@
1
+ load File.expand_path('../../tasks/deployment.rake', __FILE__)
@@ -0,0 +1,121 @@
1
+ set :deploy_to, "/home/deploy/apps/#{fetch(:application)}"
2
+ set :rbenv_home, '/home/deploy/.rbenv'
3
+ set :environment, {path: "#{fetch(:rbenv_home)}/shims:#{fetch(:rbenv_home)}/bin:$PATH", rails_env: 'production'}
4
+
5
+ SSHKit.config.command_map[:rake] = "#{fetch(:deploy_to)}/bin/rake"
6
+ %w(ln service start restart stop status).each do |cmd|
7
+ SSHKit.config.command_map[cmd.to_sym] = "sudo #{cmd}"
8
+ end
9
+ SSHKit.config.command_map[:eye] = "#{fetch(:rbenv_home)}/shims/eye"
10
+ SSHKit.config.command_map[:su_rm] = "sudo rm"
11
+
12
+ desc "Setup rails application for the first time on a server"
13
+ task :setup do
14
+ on roles(:all) do
15
+ with fetch(:environment) do
16
+ if test "[ -d #{fetch(:deploy_to)} ]"
17
+ within fetch(:deploy_to) do
18
+ execute :git, :fetch, 'origin'
19
+ execute :git, :reset, '--hard origin/master'
20
+ end
21
+ else
22
+ execute :git, :clone, fetch(:repo_url), fetch(:deploy_to)
23
+ end
24
+ server_conf_dir = "#{fetch(:deploy_to)}/config/server"
25
+ execute :ln, "-s -f #{server_conf_dir}/nginx.conf /etc/nginx/conf.d/#{fetch(:application)}.conf"
26
+ execute :ln, "-s -f #{server_conf_dir}/letsencrypt.conf /etc/nginx/letsencrypt/#{fetch(:application)}.conf"
27
+ execute :ln, "-s -f #{server_conf_dir}/logrotate.conf /etc/logrotate.d/#{fetch(:application)}"
28
+ within fetch(:deploy_to) do
29
+ execute :bundle, :install, "--without development test"
30
+ execute :mkdir, "-p #{fetch(:deploy_to)}/tmp/pids"
31
+ if test "[ -f #{fetch(:deploy_to)}/.env ]"
32
+ execute :rake, 'db:create'
33
+ if test "[ -f #{fetch(:deploy_to)}/db/#{fetch(:application)}.sql ]"
34
+ execute :psql, "-d #{fetch(:application)}_production", "-f db/#{fetch(:application)}.sql"
35
+ end
36
+ execute :rake, 'db:migrate'
37
+ execute :rake, 'assets:precompile'
38
+ execute :eye, :load, 'Eyefile'
39
+ execute :eye, :start, fetch(:application)
40
+ execute :service, "nginx restart"
41
+ else
42
+ warn "TODO: Create .env on the server by copying from .env.example.production and modify your database and smtp settings."
43
+ warn "TODO: Create rails secret token with 'rake secret' and insert it into .env"
44
+ warn "TODO: Create ssl certificates by running the following command as root: /etc/letsencrypt/generate_letsencrypt.sh"
45
+ warn "TODO: Run 'cap ENV setup' again!"
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+
52
+ desc "Remove the application completely from the server"
53
+ task :remove do
54
+ on roles(:all) do
55
+ with fetch(:environment) do
56
+ within fetch(:deploy_to) do
57
+ execute :eye, :load, 'Eyefile'
58
+ execute :eye, :stop, fetch(:application)
59
+ execute :rake, 'db:drop'
60
+ execute :su_rm, "-rf #{fetch(:deploy_to)}"
61
+ end if test "[ -d #{fetch(:deploy_to)} ]"
62
+ execute :su_rm, "-f /etc/nginx/conf.d/#{fetch(:application)}.conf"
63
+ execute :su_rm, "-f /etc/nginx/letsencrypt/#{fetch(:application)}.conf"
64
+ execute :su_rm, "-f /etc/logrotate.d/#{fetch(:application)}"
65
+ execute :service, "nginx restart"
66
+ end
67
+ end
68
+ end
69
+
70
+ desc "Deploy rails application"
71
+ task :deploy do
72
+ on roles(:all) do
73
+ with fetch(:environment) do
74
+ within fetch(:deploy_to) do
75
+ execute :git, :fetch, 'origin'
76
+ execute :git, :reset, '--hard origin/master'
77
+ execute :bundle, :install
78
+ execute :rake, 'db:migrate'
79
+ execute :rake, 'assets:precompile'
80
+ execute :eye, :load, 'Eyefile'
81
+ execute :eye, :restart, fetch(:application)
82
+ execute :service, "nginx restart"
83
+ end
84
+ end
85
+ end
86
+ end
87
+
88
+ desc "Copy database from the server to the local machine"
89
+ task :sync_local do
90
+ on roles(:all) do
91
+ within fetch(:deploy_to) do
92
+ execute :pg_dump, "-U deploy --clean #{fetch(:application)}_production > db/#{fetch(:application)}.sql"
93
+ download! "#{fetch(:deploy_to)}/db/#{fetch(:application)}.sql", 'db'
94
+ end
95
+ end
96
+ run_locally do
97
+ execute "psql -d #{fetch(:application)}_development -f db/#{fetch(:application)}.sql"
98
+ end
99
+ end
100
+
101
+ desc "Recreate server database from db/#{fetch(:application)}.sql"
102
+ task :reset_server do
103
+ on roles(:all) do
104
+ with fetch(:environment) do
105
+ within fetch(:deploy_to) do
106
+ execute :eye, :load, 'Eyefile'
107
+ execute :eye, :stop, fetch(:application)
108
+ execute :git, :fetch, 'origin'
109
+ execute :git, :reset, '--hard origin/master'
110
+ execute :rake, 'db:drop'
111
+ execute :rake, 'db:create'
112
+ if test "[ -f #{fetch(:deploy_to)}/db/#{fetch(:application)}.sql ]"
113
+ execute :psql, "-d #{fetch(:application)}_production", "-f db/#{fetch(:application)}.sql"
114
+ end
115
+ execute :rake, 'db:migrate'
116
+ execute :eye, :start, fetch(:application)
117
+ execute :service, "nginx restart"
118
+ end
119
+ end
120
+ end
121
+ end
@@ -0,0 +1,27 @@
1
+ $LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
2
+ require 'railman-deployment/version'
3
+
4
+ Gem::Specification.new do |spec|
5
+ spec.name = "railman-deployment"
6
+ spec.version = RailmanDeployment::VERSION
7
+ spec.authors = ["Igor Jancev"]
8
+ spec.email = ["igor@masterybits.com"]
9
+ spec.summary = %q{Capistrano tasks for railman-generated rails applications}
10
+ spec.description = %q{railman-deployment gem adds capistrano tasks for automated deployment of rails applications generated by railman}
11
+ spec.homepage = "https://github.com/igorj/railman-deployment"
12
+ spec.license = "MIT"
13
+
14
+
15
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^test/}) }
16
+ spec.require_paths = ["lib"]
17
+
18
+ spec.add_development_dependency "bundler", "~> 1.11"
19
+ spec.add_development_dependency "rake", "~> 10.0"
20
+ spec.add_development_dependency "minitest", "~> 5.8"
21
+ spec.add_development_dependency "minitest-reporters", "~> 1.1"
22
+ spec.add_development_dependency "gem-release", "~> 0.7"
23
+ spec.add_development_dependency "geminabox", "~> 0.13"
24
+ spec.add_development_dependency "coveralls"
25
+
26
+ spec.add_dependency "capistrano", "~> 3.4"
27
+ end
metadata ADDED
@@ -0,0 +1,172 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: railman-deployment
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Igor Jancev
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-05-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.11'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.11'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '5.8'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.8'
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest-reporters
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.1'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.1'
69
+ - !ruby/object:Gem::Dependency
70
+ name: gem-release
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.7'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.7'
83
+ - !ruby/object:Gem::Dependency
84
+ name: geminabox
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.13'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.13'
97
+ - !ruby/object:Gem::Dependency
98
+ name: coveralls
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: capistrano
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '3.4'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '3.4'
125
+ description: railman-deployment gem adds capistrano tasks for automated deployment
126
+ of rails applications generated by railman
127
+ email:
128
+ - igor@masterybits.com
129
+ executables: []
130
+ extensions: []
131
+ extra_rdoc_files: []
132
+ files:
133
+ - ".gitignore"
134
+ - ".ruby-version"
135
+ - ".travis.yml"
136
+ - Gemfile
137
+ - LICENCE.txt
138
+ - README.md
139
+ - Rakefile
140
+ - bin/console
141
+ - bin/setup
142
+ - lib/railman-deployment.rb
143
+ - lib/railman-deployment/version.rb
144
+ - lib/railman/deployment.rb
145
+ - lib/railman/deployment/tasks.rb
146
+ - lib/railman/tasks/deployment.rake
147
+ - railman-deployment.gemspec
148
+ homepage: https://github.com/igorj/railman-deployment
149
+ licenses:
150
+ - MIT
151
+ metadata: {}
152
+ post_install_message:
153
+ rdoc_options: []
154
+ require_paths:
155
+ - lib
156
+ required_ruby_version: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - ">="
159
+ - !ruby/object:Gem::Version
160
+ version: '0'
161
+ required_rubygems_version: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - ">="
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ requirements: []
167
+ rubyforge_project:
168
+ rubygems_version: 2.5.1
169
+ signing_key:
170
+ specification_version: 4
171
+ summary: Capistrano tasks for railman-generated rails applications
172
+ test_files: []