deployinator 0.0.0
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 +7 -0
- data/lib/deployinator.rb +5 -0
- data/lib/deployinator/config.rb +17 -0
- data/lib/deployinator/deploy.rb +119 -0
- metadata +60 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1118ca9720569f14d4453a2d96561b65395362f8
|
4
|
+
data.tar.gz: 1d9079e7d2e1a79ec2a612f2c47a0d14355a017a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a6fa60095a8adaa33144331cade009a5493def8f046f0d7d49c95bab97c0ecf686fce20c85efca467f67b79372b884ea9017b9e1aeaaab5ffc38b6a2a980457c
|
7
|
+
data.tar.gz: 9b8bf3e88297d083a9ef13de344a5b76455a23cf277a1d07c2a3fc961563eb148fedecd4fd9b0abc9744637fef53d7eca112424d978c51633a73b551e8c4874e
|
data/lib/deployinator.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
namespace :config do
|
2
|
+
set :stage, :staging
|
3
|
+
desc 'Write deploy_example.rb and <stage>_example.rb files'
|
4
|
+
task :write_examples do
|
5
|
+
run_locally do
|
6
|
+
execute "mkdir -p ./config/deploy"
|
7
|
+
|
8
|
+
# example deploy.rb
|
9
|
+
config = "set :application, 'example-app'"
|
10
|
+
File.open('./config/deploy_example.rb', 'w') { |f| f.write(config) }
|
11
|
+
|
12
|
+
# example <stage>.rb
|
13
|
+
config = "set :example_attr, true"
|
14
|
+
File.open('./config/deploy/stage_example.rb', 'w') { |f| f.write(config) }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,119 @@
|
|
1
|
+
# config valid only for Capistrano 3.1
|
2
|
+
lock '3.2.1'
|
3
|
+
|
4
|
+
# Use `from_local=true bundle exec cap <stage> deploy` to deploy your
|
5
|
+
# locally changed code instead of the code in the git repo.
|
6
|
+
# TODO this is not working yet
|
7
|
+
if ENV['from_local']
|
8
|
+
set :repo_url, 'file://.'
|
9
|
+
set :scm, :none
|
10
|
+
else
|
11
|
+
set :repo_url, 'git@github.com:snarlysodboxer/example.git'
|
12
|
+
set :scm, :git
|
13
|
+
end
|
14
|
+
|
15
|
+
# Default branch is :master
|
16
|
+
# ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }.call
|
17
|
+
|
18
|
+
# Default deploy_to directory is /var/www/my_app
|
19
|
+
# set :deploy_to, '/var/www/my_app'
|
20
|
+
|
21
|
+
# Default value for :format is :pretty
|
22
|
+
# set :format, :pretty
|
23
|
+
|
24
|
+
# Default value for :log_level is :debug
|
25
|
+
#set :log_level, :debug
|
26
|
+
set :log_level, :info
|
27
|
+
|
28
|
+
# Default value for :pty is false
|
29
|
+
# set :pty, true
|
30
|
+
|
31
|
+
# Default value for :linked_files is []
|
32
|
+
# set :linked_files, %w{config/nginx.conf}
|
33
|
+
|
34
|
+
# Default value for linked_dirs is []
|
35
|
+
# set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
|
36
|
+
|
37
|
+
# Default value for default_env is {}
|
38
|
+
# set :default_env, { path: "/opt/ruby/bin:$PATH" }
|
39
|
+
|
40
|
+
# Default value for keep_releases is 5
|
41
|
+
# set :keep_releases, 5
|
42
|
+
|
43
|
+
namespace :deploy do
|
44
|
+
|
45
|
+
# :started is the hook before which to set/check your needed environment/settings
|
46
|
+
before :started, :ensure_setup
|
47
|
+
|
48
|
+
task :ensure_setup do
|
49
|
+
on roles(:web), :once => true do
|
50
|
+
raise "You need to use ruby 1.9 or higher where you are running this capistrano command." unless RUBY_VERSION >= "1.9"
|
51
|
+
test "bash", "-l", "-c", "'docker", "ps", "&>", "/dev/null", "||", "sudo", "usermod", "-a", "-G", "docker", "$USER'"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# do this so capistrano has permissions to remove old releases
|
56
|
+
before :updating, :revert_permissions do
|
57
|
+
on roles(:web) do
|
58
|
+
if test "[", "-d", "#{releases_path}", "]"
|
59
|
+
execute "bash", "-l", "-c", "'sudo", "chown", "-R", "deployer.", "#{releases_path}'"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
before :restart, :ensure_permissions do
|
65
|
+
on roles(:web) do
|
66
|
+
execute "bash", "-l", "-c", "'sudo", "mkdir", "-p", "#{current_path}/data/cache'"
|
67
|
+
execute "bash", "-l", "-c", "'sudo", "chown", "-R", "www-data.", "#{current_path}/data'"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
#desc 'Install config files in current_path'
|
72
|
+
before :restart, :install_config_files do
|
73
|
+
on roles(:web) do |host|
|
74
|
+
require 'erb'
|
75
|
+
{ 'config/nginx.conf.erb' => "#{current_path}/config/#{fetch(:application)}-nginx.conf",
|
76
|
+
'config/php-fpm.conf.erb' => "#{current_path}/config/#{fetch(:application)}-php-fpm.conf",
|
77
|
+
'config/php.ini.erb' => "#{current_path}/config/#{fetch(:application)}-php.ini"
|
78
|
+
}.each do |template, upload_path|
|
79
|
+
@worker_processes = fetch(:worker_processes)
|
80
|
+
template_path = File.expand_path(template)
|
81
|
+
host_config = ERB.new(File.new(template_path).read).result(binding)
|
82
|
+
upload! StringIO.new(host_config), upload_path
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
desc 'Restart or start application'
|
88
|
+
task :restart do
|
89
|
+
on roles(:web) do
|
90
|
+
['php5', 'nginx'].each do |name|
|
91
|
+
container = {
|
92
|
+
:name => fetch("#{name}_container_name".to_sym),
|
93
|
+
:run_options => fetch("#{name}_run_options".to_sym).join(' '),
|
94
|
+
:image => fetch("#{name}_image_name".to_sym)
|
95
|
+
}
|
96
|
+
exists = "docker inspect #{container[:name]} &> /dev/null"
|
97
|
+
is_running = "docker inspect --format='{{.State.Running}}' #{container[:name]} 2>&1 | grep -q true"
|
98
|
+
if test(exists)
|
99
|
+
if test(is_running)
|
100
|
+
execute "docker", "stop", container[:name]
|
101
|
+
end
|
102
|
+
execute "docker", "rm", container[:name]
|
103
|
+
end
|
104
|
+
execute(
|
105
|
+
"docker", "run",
|
106
|
+
"--detach", "--tty",
|
107
|
+
"--name", container[:name],
|
108
|
+
container[:run_options],
|
109
|
+
container[:image]
|
110
|
+
)
|
111
|
+
sleep 2
|
112
|
+
error("Container #{container[:name]} did not stay running more than 2 seconds!") unless test(is_running)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
# :publishing is the hook after which to set our service restart commands
|
118
|
+
after :publishing, :restart
|
119
|
+
end
|
metadata
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: deployinator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- david amick
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-09-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: capistrano
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.2.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.2.1
|
27
|
+
description: An Opinionated Deployment gem
|
28
|
+
email: davidamick@ctisolutionsinc.com
|
29
|
+
executables: []
|
30
|
+
extensions: []
|
31
|
+
extra_rdoc_files: []
|
32
|
+
files:
|
33
|
+
- lib/deployinator.rb
|
34
|
+
- lib/deployinator/deploy.rb
|
35
|
+
- lib/deployinator/config.rb
|
36
|
+
homepage: http://rubygems.org/gems/deployinator
|
37
|
+
licenses:
|
38
|
+
- MIT
|
39
|
+
metadata: {}
|
40
|
+
post_install_message:
|
41
|
+
rdoc_options: []
|
42
|
+
require_paths:
|
43
|
+
- lib
|
44
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - '>='
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
requirements: []
|
55
|
+
rubyforge_project:
|
56
|
+
rubygems_version: 2.0.2
|
57
|
+
signing_key:
|
58
|
+
specification_version: 4
|
59
|
+
summary: Deploy Applications
|
60
|
+
test_files: []
|