deployinator 0.0.2 → 0.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/lib/deployinator/deploy.rb
CHANGED
@@ -12,6 +12,8 @@ namespace :deploy do
|
|
12
12
|
"-e", "PATH=#{fetch(:deploy_to)}/shared/bundle/bin:$PATH",
|
13
13
|
"--entrypoint", "#{fetch(:deploy_to)}/shared/bundle/bin/bundle",
|
14
14
|
"--volume #{fetch(:deploy_to)}:#{fetch(:deploy_to)}:rw",
|
15
|
+
"--volume /etc/passwd:/etc/passwd:ro",
|
16
|
+
"--volume /etc/group:/etc/group:ro",
|
15
17
|
fetch(:ruby_image_name)
|
16
18
|
].join(' ')
|
17
19
|
end
|
@@ -25,58 +27,65 @@ namespace :deploy do
|
|
25
27
|
# Append dependancy to existing cleanup task
|
26
28
|
task :cleanup => :set_rm_command_map
|
27
29
|
|
28
|
-
#
|
29
|
-
Rake::Task
|
30
|
-
|
31
|
-
|
30
|
+
# If defined, overwrite :assets:precompile to use docker
|
31
|
+
if Rake::Task.task_defined?("deploy:assets:precompile")
|
32
|
+
Rake::Task["deploy:assets:precompile"].clear
|
33
|
+
namespace :assets do
|
34
|
+
task :precompile do
|
35
|
+
on roles(fetch(:assets_roles)) do
|
36
|
+
execute(
|
37
|
+
"docker", "run", "--rm", "--tty",
|
38
|
+
"-w", fetch(:release_path, "#{fetch(:deploy_to)}/current"),
|
39
|
+
"--link", "#{fetch(:postgres_container_name)}:postgres",
|
40
|
+
"--entrypoint", "#{fetch(:deploy_to)}/shared/bundle/bin/rake",
|
41
|
+
"--volume", "#{fetch(:deploy_to)}:#{fetch(:deploy_to)}:rw",
|
42
|
+
fetch(:ruby_image_name), "assets:precompile"
|
43
|
+
)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# If defined, overwrite :cleanup_assets to use docker
|
50
|
+
if Rake::Task.task_defined?("deploy:cleanup_assets")
|
51
|
+
Rake::Task["deploy:cleanup_assets"].clear
|
52
|
+
desc 'Cleanup expired assets'
|
53
|
+
task :cleanup_assets => [:set_rails_env] do
|
32
54
|
on roles(fetch(:assets_roles)) do
|
33
55
|
execute(
|
34
56
|
"docker", "run", "--rm", "--tty",
|
57
|
+
"-e", "RAILS_ENV=#{fetch(:rails_env)}",
|
35
58
|
"-w", fetch(:release_path, "#{fetch(:deploy_to)}/current"),
|
36
|
-
"--entrypoint", "#{fetch(:deploy_to)}/shared/bundle/bin/
|
59
|
+
"--entrypoint", "#{fetch(:deploy_to)}/shared/bundle/bin/bundle",
|
37
60
|
"--volume", "#{fetch(:deploy_to)}:#{fetch(:deploy_to)}:rw",
|
38
|
-
fetch(:ruby_image_name), "assets:
|
61
|
+
fetch(:ruby_image_name), "exec", "rake", "assets:clean"
|
39
62
|
)
|
40
63
|
end
|
41
64
|
end
|
42
65
|
end
|
43
66
|
|
44
|
-
#
|
45
|
-
Rake::Task
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
"-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
info '[deploy:migrate] Checking changes in /db/migrate' if conditionally_migrate
|
67
|
-
if conditionally_migrate && test("diff -q #{release_path}/db/migrate #{current_path}/db/migrate")
|
68
|
-
info '[deploy:migrate] Skip `deploy:migrate` (nothing changed in db/migrate)'
|
69
|
-
else
|
70
|
-
info '[deploy:migrate] Run `rake db:migrate`' if conditionally_migrate
|
71
|
-
execute(
|
72
|
-
"docker", "run", "--rm", "--tty",
|
73
|
-
"--link", "#{fetch(:postgres_container_name)}:postgres",
|
74
|
-
"--volume", "#{fetch(:deploy_to)}:#{fetch(:deploy_to)}:rw",
|
75
|
-
"-e", "RAILS_ENV=#{fetch(:rails_env)}",
|
76
|
-
"--entrypoint", "#{fetch(:deploy_to)}/shared/bundle/bin/rake",
|
77
|
-
"-w", fetch(:release_path, "#{fetch(:deploy_to)}/current"),
|
78
|
-
fetch(:ruby_image_name), "db:migrate"
|
79
|
-
)
|
67
|
+
# If defined, overwrite :migrate to use docker
|
68
|
+
if Rake::Task.task_defined?("deploy:migrate")
|
69
|
+
Rake::Task["deploy:migrate"].clear
|
70
|
+
desc 'Runs rake db:migrate if migrations are set'
|
71
|
+
task :migrate => [:set_rails_env, :ensure_running_postgres] do
|
72
|
+
on primary fetch(:migration_role) do
|
73
|
+
conditionally_migrate = fetch(:conditionally_migrate)
|
74
|
+
info '[deploy:migrate] Checking changes in /db/migrate' if conditionally_migrate
|
75
|
+
if conditionally_migrate && test("diff -q #{release_path}/db/migrate #{current_path}/db/migrate")
|
76
|
+
info '[deploy:migrate] Skip `deploy:migrate` (nothing changed in db/migrate)'
|
77
|
+
else
|
78
|
+
info '[deploy:migrate] Run `rake db:migrate`' if conditionally_migrate
|
79
|
+
execute(
|
80
|
+
"docker", "run", "--rm", "--tty",
|
81
|
+
"--link", "#{fetch(:postgres_container_name)}:postgres",
|
82
|
+
"--volume", "#{fetch(:deploy_to)}:#{fetch(:deploy_to)}:rw",
|
83
|
+
"-e", "RAILS_ENV=#{fetch(:rails_env)}",
|
84
|
+
"--entrypoint", "#{fetch(:deploy_to)}/shared/bundle/bin/rake",
|
85
|
+
"-w", fetch(:release_path, "#{fetch(:deploy_to)}/current"),
|
86
|
+
fetch(:ruby_image_name), "db:migrate"
|
87
|
+
)
|
88
|
+
end
|
80
89
|
end
|
81
90
|
end
|
82
91
|
end
|
@@ -257,8 +266,8 @@ namespace :deploy do
|
|
257
266
|
execute "chown", "-R", "#{fetch(:www_data_user_id)}:#{fetch(:www_data_user_id)}", directory
|
258
267
|
end
|
259
268
|
execute "chown", "-R", "#{fetch(:deployer_user_id)}:#{fetch(:deployer_user_id)}", "#{fetch(:deploy_to)}/shared/bundle"
|
269
|
+
execute("rm", "-f", "#{fetch(:external_socket_path)}/unicorn.pid")
|
260
270
|
end
|
261
|
-
execute("rm", "-f", "#{fetch(:external_socket_path)}/unicorn.pid")
|
262
271
|
execute("docker", "run", fetch(:docker_run_bluepill_command))
|
263
272
|
end
|
264
273
|
end
|
@@ -10,7 +10,7 @@ RUN tar -xzvf ruby-install-0.5.0.tar.gz
|
|
10
10
|
RUN cd ruby-install-0.5.0/ && make install && ruby-install --system ruby 1.9.3-p547
|
11
11
|
RUN gem install bundler --no-ri --no-rdoc
|
12
12
|
|
13
|
-
RUN /bin/bash -c "apt-get update -qq && apt-get install -qy libxml2 libxml2-dev libxslt1-dev nodejs postgresql-contrib libpq-dev"
|
13
|
+
RUN /bin/bash -c "apt-get update -qq && apt-get install -qy libxml2 libxml2-dev libxslt1-dev nodejs postgresql-contrib libpq-dev git-core"
|
14
14
|
|
15
15
|
ENTRYPOINT ["/bin/bash"]
|
16
16
|
CMD ["-l"]
|
@@ -4,9 +4,12 @@ lock '3.2.1'
|
|
4
4
|
set :application, 'my_app_name'
|
5
5
|
set :repo_url, 'git@example.com:me/my_repo.git'
|
6
6
|
|
7
|
-
## Don't ask this here, only in staging or other non-production <stage>.rb files.
|
8
7
|
# Default branch is :master
|
9
|
-
#
|
8
|
+
# Always use the master branch in production:
|
9
|
+
set :current_stage, -> { fetch(:stage).to_s.strip }
|
10
|
+
unless fetch(:current_stage) == "production"
|
11
|
+
ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }.call
|
12
|
+
end
|
10
13
|
|
11
14
|
# Default deploy_to directory is /var/www/my_app
|
12
15
|
# set :deploy_to, '/var/www/my_app'
|
@@ -6,12 +6,6 @@ else
|
|
6
6
|
set :scm, :git
|
7
7
|
end
|
8
8
|
|
9
|
-
# Always use the master branch in production:
|
10
|
-
set :current_stage, -> { fetch(:stage).to_s.strip }
|
11
|
-
unless fetch(:current_stage) == "production"
|
12
|
-
ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }.call
|
13
|
-
end
|
14
|
-
|
15
9
|
## The values in this file are not meant to be changed and shouldn't
|
16
10
|
## need to be under the majority of circumstances:
|
17
11
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: deployinator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-11-
|
12
|
+
date: 2014-11-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: capistrano
|