docker-deploy 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 +7 -0
- data/.gitignore +2 -0
- data/LICENSE +22 -0
- data/README.md +2 -0
- data/docker-deploy.gemspec +14 -0
- data/lib/container_management/container_management.rb +9 -0
- data/lib/container_management/docker_compose.rb +34 -0
- data/lib/docker-deploy.rb +14 -0
- data/lib/infrastructure/google_cloud_platform/google_cloud_platform.rb +78 -0
- data/lib/infrastructure/infrastructure.rb +8 -0
- metadata +66 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f76110c145c7771a320bf7796ef7e09c45d38884
|
4
|
+
data.tar.gz: e0b1381d57789bd798f743be38b5584cc5152dac
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 45a3eb41fc8d28a0f0e7df028264a73dd32ef11cd56a32cfbf5f7201f3e762b23f1883297938f6d9655a42d847c84c12bc7b1704e9de8205c39e7181eebd57fb
|
7
|
+
data.tar.gz: 63d41a27bc420cfb8e97aa578b393655a2df229ce6a1477a2e64bff4268dca86cb30d23035bd0869569f7035749dc36127a2aeb88fcf776413e0501e663e45d7
|
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 VJ Patel
|
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 all
|
13
|
+
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 THE
|
21
|
+
SOFTWARE.
|
22
|
+
|
data/README.md
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'docker-deploy'
|
3
|
+
s.version = `git describe --abbrev=0`.strip
|
4
|
+
s.date = `date +"%Y-%m-%d"`.strip
|
5
|
+
s.summary = 'Deployment tasks with Docker'
|
6
|
+
s.description = 'Tasks that can be used when deploying docker applications'
|
7
|
+
s.authors = ['VJ Patel']
|
8
|
+
s.email = 'meetthevj@gmail.com'
|
9
|
+
s.files = `git ls-files`.split("\n")
|
10
|
+
s.homepage = 'http://rubygems.org/gems/docker-deploy'
|
11
|
+
s.license = 'MIT'
|
12
|
+
s.add_runtime_dependency 'gcloud',
|
13
|
+
['= 0.1.0']
|
14
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
class DockerCompose
|
2
|
+
|
3
|
+
def self.generate_yaml(dist_file_path, app_name, duty, port, image)
|
4
|
+
branch = `git rev-parse --abbrev-ref HEAD`.strip
|
5
|
+
commit = `git rev-parse --short HEAD`.strip
|
6
|
+
path = File.dirname(dist_file_path)
|
7
|
+
filename = "#{path}/#{app_name}-#{branch}-#{commit}_#{duty}.yaml"
|
8
|
+
|
9
|
+
dist = File.read(dist_file_path)
|
10
|
+
|
11
|
+
dist = dist.gsub('<port>', port.to_s)
|
12
|
+
dist = dist.gsub('<image>', image)
|
13
|
+
|
14
|
+
out_file = File.new(filename, 'w')
|
15
|
+
out_file.puts(dist)
|
16
|
+
out_file.close
|
17
|
+
|
18
|
+
puts "Generated: #{filename} \n Contents: #{dist}"
|
19
|
+
|
20
|
+
return out_file
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.pull_containers(project_name, compose_file)
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.stop_containers(project_name, compose_file)
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.start_containers(project_name, compose_file)
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'gcloud/storage'
|
2
|
+
|
3
|
+
class GoogleCloudPlatform
|
4
|
+
|
5
|
+
def initialize(project_name, app_name, credentials)
|
6
|
+
@project_name = project_name
|
7
|
+
@app_name = app_name
|
8
|
+
@storage = Gcloud.storage "#{project_name}" "#{credentials}"
|
9
|
+
@bucket = self.get_bucket
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.get_yaml_filename(duty, latest=false)
|
13
|
+
branch = `git rev-parse --abbrev-ref HEAD`.strip
|
14
|
+
commit = 'latest'
|
15
|
+
unless latest
|
16
|
+
commit = `git rev-parse --short HEAD`.strip
|
17
|
+
end
|
18
|
+
|
19
|
+
return "#{@app_name}-#{branch}-#{commit}_#{duty}.yaml"
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
def self.get_bucket
|
24
|
+
buckets = @storage.buckets
|
25
|
+
buckets.each do |bucket|
|
26
|
+
if bucket.name == @app_name
|
27
|
+
return bucket
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
return @storage.create_bucket @app_name, retries: 3
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.generate_startup_script
|
35
|
+
branch = `git rev-parse --abbrev-ref HEAD`.strip
|
36
|
+
|
37
|
+
dist = %w{#!/bin/bash
|
38
|
+
|
39
|
+
gsutil cp gs://<app_name>/docker-compose/<primary_yaml> .
|
40
|
+
gsutil cp gs://<app_name>/docker-compose/<backup_yaml> .
|
41
|
+
|
42
|
+
# Pull Primary Containers and start them (faster service availability)
|
43
|
+
docker-compose pull -p <app_name> -f <primary_yaml>
|
44
|
+
docker-compose up -p <app_name> -f <primary_yaml> -d
|
45
|
+
|
46
|
+
# Pull Backup containers and start them
|
47
|
+
docker-compose pull -p <app_name> -f <backup_yaml>
|
48
|
+
docker-compose up -p <app_name> -f <backup_yaml> -d
|
49
|
+
}
|
50
|
+
|
51
|
+
dist = dist.gsub('<app_name>', @app_name)
|
52
|
+
dist = dist.gsub('<primary_yaml>', self.get_yaml_filename('primary', true))
|
53
|
+
dist = dist.gsub('<backup_yaml>', self.get_yaml_filename('backup', true))
|
54
|
+
|
55
|
+
filename = "#{branch}-startup.sh"
|
56
|
+
out_file = File.new(filename, 'w')
|
57
|
+
out_file.puts(dist)
|
58
|
+
out_file.close
|
59
|
+
|
60
|
+
puts "Generated: #{filename} \n Contents: #{dist}"
|
61
|
+
|
62
|
+
puts "Putting #{filename} on Google Cloud Storage"
|
63
|
+
return @bucket.create_file filename "scripts/#{filename}"
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.put_production_yaml(filename)
|
67
|
+
puts "Putting #{filename} on Google Cloud Storage"
|
68
|
+
return @bucket.create_file filename "docker-compose/#{filename}"
|
69
|
+
end
|
70
|
+
|
71
|
+
def self.make_latest_production_yaml(duty)
|
72
|
+
existing_file = @bucket.find_file "docker-compose/#{self.get_yaml_filename(duty)}"
|
73
|
+
|
74
|
+
puts "Making #{existing_file} latest"
|
75
|
+
existing_file.copy "docker-compose/#{self.get_yaml_filename(duty, true)}"
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
metadata
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: docker-deploy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- VJ Patel
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-06-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: gcloud
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.1.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.1.0
|
27
|
+
description: Tasks that can be used when deploying docker applications
|
28
|
+
email: meetthevj@gmail.com
|
29
|
+
executables: []
|
30
|
+
extensions: []
|
31
|
+
extra_rdoc_files: []
|
32
|
+
files:
|
33
|
+
- ".gitignore"
|
34
|
+
- LICENSE
|
35
|
+
- README.md
|
36
|
+
- docker-deploy.gemspec
|
37
|
+
- lib/container_management/container_management.rb
|
38
|
+
- lib/container_management/docker_compose.rb
|
39
|
+
- lib/docker-deploy.rb
|
40
|
+
- lib/infrastructure/google_cloud_platform/google_cloud_platform.rb
|
41
|
+
- lib/infrastructure/infrastructure.rb
|
42
|
+
homepage: http://rubygems.org/gems/docker-deploy
|
43
|
+
licenses:
|
44
|
+
- MIT
|
45
|
+
metadata: {}
|
46
|
+
post_install_message:
|
47
|
+
rdoc_options: []
|
48
|
+
require_paths:
|
49
|
+
- lib
|
50
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
requirements: []
|
61
|
+
rubyforge_project:
|
62
|
+
rubygems_version: 2.4.6
|
63
|
+
signing_key:
|
64
|
+
specification_version: 4
|
65
|
+
summary: Deployment tasks with Docker
|
66
|
+
test_files: []
|