docker-deploy 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0435a79eec7d832534bd04cea705966e574ce363
|
4
|
+
data.tar.gz: a70b934b9c33bc3e0b23189b3ac1cf7eaced8f6a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab66dcafe582866d4a4ecb42daffa23fd8b2e07d8d4c4c2c41f5070aa8b70487f54db577110ad0810cc257e02d75813f71c35ff891ab6fc6c8608522285995e7
|
7
|
+
data.tar.gz: 5915dc05e964e77ba1aadffa0114d50aa7d696c806502bca8c9fc319e05390a67d2a0c6d93ef39074caf3beb6f844a3d9b3b77bf59385bb554ad5f1d8a466c9b
|
@@ -5,36 +5,37 @@ class GoogleCloudPlatform
|
|
5
5
|
def initialize(project_name, app_name, credentials)
|
6
6
|
@project_name = project_name
|
7
7
|
@app_name = app_name
|
8
|
-
|
9
|
-
|
8
|
+
# assume we already logged in (GCE instance or GCloud SDK)
|
9
|
+
puts project_name
|
10
|
+
|
11
|
+
@storage = Gcloud.storage project_name, credentials
|
12
|
+
buckets = @storage.buckets
|
13
|
+
buckets.each do |bucket|
|
14
|
+
if bucket.name == @app_name
|
15
|
+
@bucket = bucket
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
unless @bucket
|
20
|
+
@bucket = @storage.create_bucket @app_name, retries: 3
|
21
|
+
end
|
10
22
|
end
|
11
23
|
|
12
|
-
def
|
24
|
+
def get_yaml_filename(duty, latest=false)
|
13
25
|
branch = `git rev-parse --abbrev-ref HEAD`.strip
|
14
26
|
commit = 'latest'
|
15
27
|
unless latest
|
16
28
|
commit = `git rev-parse --short HEAD`.strip
|
17
29
|
end
|
18
30
|
|
19
|
-
|
31
|
+
"#{@app_name}-#{branch}-#{commit}_#{duty}.yaml"
|
20
32
|
end
|
21
33
|
|
22
|
-
|
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
|
34
|
+
def generate_startup_script
|
35
35
|
branch = `git rev-parse --abbrev-ref HEAD`.strip
|
36
36
|
|
37
|
-
dist =
|
37
|
+
dist = <<-EOF
|
38
|
+
#!/bin/bash
|
38
39
|
|
39
40
|
gsutil cp gs://<app_name>/docker-compose/<primary_yaml> .
|
40
41
|
gsutil cp gs://<app_name>/docker-compose/<backup_yaml> .
|
@@ -46,7 +47,7 @@ docker-compose up -p <app_name> -f <primary_yaml> -d
|
|
46
47
|
# Pull Backup containers and start them
|
47
48
|
docker-compose pull -p <app_name> -f <backup_yaml>
|
48
49
|
docker-compose up -p <app_name> -f <backup_yaml> -d
|
49
|
-
|
50
|
+
EOF
|
50
51
|
|
51
52
|
dist = dist.gsub('<app_name>', @app_name)
|
52
53
|
dist = dist.gsub('<primary_yaml>', self.get_yaml_filename('primary', true))
|
@@ -60,15 +61,16 @@ docker-compose up -p <app_name> -f <backup_yaml> -d
|
|
60
61
|
puts "Generated: #{filename} \n Contents: #{dist}"
|
61
62
|
|
62
63
|
puts "Putting #{filename} on Google Cloud Storage"
|
63
|
-
|
64
|
+
@bucket.create_file filename, "scripts/#{filename}"
|
64
65
|
end
|
65
66
|
|
66
|
-
def
|
67
|
+
def put_production_yaml(filename)
|
67
68
|
puts "Putting #{filename} on Google Cloud Storage"
|
68
|
-
|
69
|
+
|
70
|
+
@bucket.create_file filename, "docker-compose/#{filename}"
|
69
71
|
end
|
70
72
|
|
71
|
-
def
|
73
|
+
def make_latest_production_yaml(duty)
|
72
74
|
existing_file = @bucket.find_file "docker-compose/#{self.get_yaml_filename(duty)}"
|
73
75
|
|
74
76
|
puts "Making #{existing_file} latest"
|
@@ -1,7 +1,12 @@
|
|
1
1
|
class Infrastructure
|
2
2
|
|
3
|
-
def self.google_cloud_platform(project_name, app_name
|
4
|
-
|
3
|
+
def self.google_cloud_platform(project_name, app_name)
|
4
|
+
credentials = ENV['GOOGLE_CLOUD_KEYFILE']
|
5
|
+
unless credentials
|
6
|
+
puts 'Google Cloud credentials file not set. Run export GOOGLE_CLOUD_KEYFILE=<your_keyfile>.json'
|
7
|
+
exit 1
|
8
|
+
end
|
9
|
+
GoogleCloudPlatform.new(project_name, app_name, credentials)
|
5
10
|
end
|
6
11
|
end
|
7
12
|
|