shiplane_deployers_capistrano_docker 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +39 -0
- data/lib/capistrano/shiplane_deployers_capistrano_docker/version.rb +5 -0
- data/lib/capistrano/shiplane_deployers_capistrano_docker.rb +2 -0
- data/lib/capistrano/tasks/deployer.rake +87 -0
- data/lib/capistrano/tasks/dockerhub.rake +25 -0
- data/lib/shiplane/deployers/capistrano_docker/version.rb +9 -0
- metadata +92 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ec84da285f3c55064ca75b5940db4ce55ec78f1412fde601ac66ba01edfdd57a
|
4
|
+
data.tar.gz: 52470871f3b1dd30a4c269e7c917c904e3050b2e0874a194c9382d11b63641dd
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8a136ba2dc5d9bde48ac9db6b0a8837e20c2f24dfe358e691bd204f439626cd1470b7ca5c963bca908f491188ccaa9689e516815a9a5affbb1c096535f0a8161
|
7
|
+
data.tar.gz: d360f3094cf0921fe70a5ec26e66b5f0cfee5f2d8b2818243cb4581003e73c721b39d4973891ea2c88542e18488c87aff5a3a9e8969b58f81888ab4511b3cea8
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
### Settings
|
2
|
+
|
3
|
+
`deploy.rb`:
|
4
|
+
|
5
|
+
```
|
6
|
+
# Docker Registry Authentication
|
7
|
+
set :docker_registry, :dockerhub
|
8
|
+
set :docker_registry_username, ENV["DOCKERHUB_USERNAME"]
|
9
|
+
set :docker_registry_password, ENV["DOCKERHUB_PASSWORD"]
|
10
|
+
|
11
|
+
set :containers, [
|
12
|
+
{
|
13
|
+
name: "podcaster_app_#{fetch(:sha)}",
|
14
|
+
server_role: 'app',
|
15
|
+
command: 'bin/start_web_server',
|
16
|
+
virtual_host_name: 'battlecryforfreedom.com',
|
17
|
+
docker_registry_repo: 'kirillian2/podcaster',
|
18
|
+
port: 3000,
|
19
|
+
mounted_volumes: [
|
20
|
+
[fetch(:sso_cert_file),'/var/www/podcaster/config/app.crt'],
|
21
|
+
[fetch(:sso_cert_private_key_file),'/var/www/podcaster/config/app.key'],
|
22
|
+
],
|
23
|
+
terminate_ssl: false,
|
24
|
+
ssl_cert_file: nil,
|
25
|
+
},
|
26
|
+
{
|
27
|
+
name: "podcaster_sidekiq_#{fetch(:sha)}",
|
28
|
+
server_role: 'app',
|
29
|
+
command: 'bundle exec sidekiq',
|
30
|
+
docker_registry_repo: 'kirillian2/podcaster',
|
31
|
+
mounted_volumes: [
|
32
|
+
[fetch(:sso_cert_file),'/var/www/podcaster/config/app.crt'],
|
33
|
+
[fetch(:sso_cert_private_key_file),'/var/www/podcaster/config/app.key'],
|
34
|
+
],
|
35
|
+
terminate_ssl: false,
|
36
|
+
ssl_cert_file: nil,
|
37
|
+
},
|
38
|
+
]
|
39
|
+
```
|
@@ -0,0 +1,87 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'dotenv'
|
4
|
+
Dotenv.load File.join(Dir.pwd, '.env')
|
5
|
+
|
6
|
+
namespace :deploy do
|
7
|
+
task :starting do
|
8
|
+
invoke "shiplane:instantiate_shiplane_environment"
|
9
|
+
invoke "shiplane:create_networks"
|
10
|
+
end
|
11
|
+
|
12
|
+
task :updating do
|
13
|
+
invoke "shiplane:download_container"
|
14
|
+
end
|
15
|
+
|
16
|
+
task :publishing do
|
17
|
+
invoke "shiplane:stop_old_containers"
|
18
|
+
invoke "shiplane:remove_conflicting_containers"
|
19
|
+
invoke "shiplane:deploy_latest"
|
20
|
+
end
|
21
|
+
|
22
|
+
task :finishing do
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
namespace :shiplane do
|
27
|
+
task :instantiate_shiplane_environment do
|
28
|
+
set :shiplane_container_configurations, Hash[fetch(:shiplane_containers).map do |name, config|
|
29
|
+
[name, Shiplane::Deploy::ContainerConfiguration.new(name, config, env)]
|
30
|
+
end]
|
31
|
+
|
32
|
+
set :shiplane_network_configurations, Hash[fetch(:shiplane_networks).map do |name, config|
|
33
|
+
[name, Shiplane::Deploy::NetworkConfiguration.new(name, config, env)]
|
34
|
+
end]
|
35
|
+
end
|
36
|
+
|
37
|
+
task :create_networks do
|
38
|
+
fetch(:shiplane_network_configurations).each do |name, config|
|
39
|
+
roles = roles(config.fetch(:capistrano_role, :all)).map{|role| Shiplane::Host.new(role, env) }
|
40
|
+
roles.each do |role|
|
41
|
+
on role.capistrano_role do
|
42
|
+
config.create_commands(role).each(&method(:execute))
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
desc "Deploy the current branch to production via its docker container"
|
49
|
+
task deploy_latest: [:instantiate_shiplane_environment, :create_networks, :download_container, :stop_old_containers, :remove_conflicting_containers] do
|
50
|
+
fetch(:shiplane_container_configurations).each do |name, config|
|
51
|
+
roles = roles(config.fetch(:capistrano_role, :all)).map{|role| Shiplane::Host.new(role, env) }
|
52
|
+
roles.each do |role|
|
53
|
+
on role.capistrano_role do
|
54
|
+
config.run_commands(role).each(&method(:execute))
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
task :stop_old_containers do
|
61
|
+
fetch(:shiplane_container_configurations).each do |name, config|
|
62
|
+
roles = roles(config.fetch(:capistrano_role, :all)).map{|role| Shiplane::Host.new(role, env) }
|
63
|
+
roles.each do |role|
|
64
|
+
on role.capistrano_role do
|
65
|
+
old_container_ids = capture("#{config.docker_command(role)} ps --filter name=#{config.container_name} --format \"{{.ID}}\"").split("\n")
|
66
|
+
old_container_ids.each do |container_id|
|
67
|
+
execute "#{config.docker_command(role)} kill #{container_id}"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
task :remove_conflicting_containers do
|
75
|
+
fetch(:shiplane_container_configurations).each do |name, config|
|
76
|
+
roles = roles(config.fetch(:capistrano_role, :all)).map{|role| Shiplane::Host.new(role, env) }
|
77
|
+
roles.each do |role|
|
78
|
+
on role.capistrano_role do
|
79
|
+
old_container_ids = capture("#{config.docker_command(role)} ps -a --filter name=#{fetch(:sha)} --format \"{{.ID}}\"").split("\n")
|
80
|
+
old_container_ids.each do |container_id|
|
81
|
+
execute "#{config.docker_command(role)} rm #{container_id}"
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
namespace :shiplane do
|
2
|
+
task :login_to_dockerhub do
|
3
|
+
fetch(:shiplane_container_configurations).each do |name, config|
|
4
|
+
roles = roles(config.fetch(:capistrano_role, :all)).map{|role| Shiplane::Host.new(role, env) }
|
5
|
+
roles.each do |role|
|
6
|
+
on role.capistrano_role do
|
7
|
+
username = fetch(:shiplane_docker_registry_username)
|
8
|
+
password = fetch(:shiplane_docker_registry_password)
|
9
|
+
execute "echo '#{password}' | #{config.docker_command(role)} login --username #{username} --password-stdin"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
task download_container: [:login_to_dockerhub] do
|
16
|
+
fetch(:shiplane_container_configurations).each do |name, config|
|
17
|
+
roles = roles(config.fetch(:capistrano_role, :all)).map{|role| Shiplane::Host.new(role, env) }
|
18
|
+
roles.each do |role|
|
19
|
+
on role.capistrano_role do
|
20
|
+
execute "#{config.docker_command(role)} pull #{config.image_name}"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: shiplane_deployers_capistrano_docker
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- John Epperson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-04-16 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.7'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 3.7.1
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3.7'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 3.7.1
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: airbrussh
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '1.1'
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 1.1.1
|
43
|
+
type: :runtime
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '1.1'
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 1.1.1
|
53
|
+
description: Converts docker-compose.yml files into images that can be uploaded to
|
54
|
+
any docker image repository.
|
55
|
+
email:
|
56
|
+
- john.epperson@rockagile.io
|
57
|
+
executables: []
|
58
|
+
extensions: []
|
59
|
+
extra_rdoc_files: []
|
60
|
+
files:
|
61
|
+
- README.md
|
62
|
+
- lib/capistrano/shiplane_deployers_capistrano_docker.rb
|
63
|
+
- lib/capistrano/shiplane_deployers_capistrano_docker/version.rb
|
64
|
+
- lib/capistrano/tasks/deployer.rake
|
65
|
+
- lib/capistrano/tasks/dockerhub.rake
|
66
|
+
- lib/shiplane/deployers/capistrano_docker/version.rb
|
67
|
+
homepage: https://github.com/kirillian/shiplane
|
68
|
+
licenses:
|
69
|
+
- MIT
|
70
|
+
metadata: {}
|
71
|
+
post_install_message:
|
72
|
+
rdoc_options: []
|
73
|
+
require_paths:
|
74
|
+
- lib
|
75
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: 2.3.1
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
requirements: []
|
86
|
+
rubyforge_project:
|
87
|
+
rubygems_version: 2.7.7
|
88
|
+
signing_key:
|
89
|
+
specification_version: 4
|
90
|
+
summary: A toolbox for converting developer docker-compose files into production-ready
|
91
|
+
images.
|
92
|
+
test_files: []
|