docker-publish 0.0.1 → 0.0.2
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ece2c1e991dbe762ca4d4c492fded71a2abed48f
|
4
|
+
data.tar.gz: d340a2140194cc2479c36aaf11dcc711480e8b30
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79d878520d704d43758b431c6bb16b50d5e3aee6721a850933ad703637d57b385c1297a57fb9a0aa7453778759252884e02732dd1156bd1cb27ea3550deedf77
|
7
|
+
data.tar.gz: 49af2e42a9c0dc1fa9a59d9df38683f20a5015f5a049495829cc1cf39d505f32fd14a2bccd5ddc6864a0b3999a020ba90e4aa6119920969e1c0e65682373dd44
|
@@ -10,11 +10,10 @@ class DockerCompose
|
|
10
10
|
# @param [string] duty
|
11
11
|
# @param [int] port
|
12
12
|
# @param [string] image_tag
|
13
|
-
|
14
|
-
|
15
|
-
commit = `git rev-parse --short HEAD`.strip
|
13
|
+
# @return [File]
|
14
|
+
def generate_compose_yaml(dist_file_path, duty, port, image_tag, out_filename)
|
16
15
|
path = File.dirname(dist_file_path)
|
17
|
-
file_path = "#{path}/#{
|
16
|
+
file_path = "#{path}/#{out_filename}"
|
18
17
|
|
19
18
|
dist = File.read(dist_file_path)
|
20
19
|
|
@@ -25,9 +24,9 @@ class DockerCompose
|
|
25
24
|
out_file.puts(dist)
|
26
25
|
out_file.close
|
27
26
|
|
28
|
-
puts "Generated: #{file_path}
|
27
|
+
puts "Generated: #{file_path}"
|
29
28
|
|
30
|
-
|
29
|
+
out_file
|
31
30
|
end
|
32
31
|
|
33
32
|
|
data/lib/docker_publish.rb
CHANGED
@@ -6,44 +6,55 @@ class GoogleCloudPlatform
|
|
6
6
|
@project_name = project_name
|
7
7
|
@app_name = app_name
|
8
8
|
@credentials = ENV['GOOGLE_CLOUD_KEYFILE']
|
9
|
-
unless credentials
|
9
|
+
unless @credentials
|
10
10
|
puts 'Google Cloud credentials file not set. Run export GOOGLE_CLOUD_KEYFILE=<your_keyfile>.json'
|
11
11
|
exit 1
|
12
12
|
end
|
13
13
|
@google_cloud_storage = GoogleCloudStorage.new(@project_name, @app_name, @credentials)
|
14
|
+
|
15
|
+
@branch = `git rev-parse --abbrev-ref HEAD`.strip
|
16
|
+
@commit = `git rev-parse --short HEAD`.strip
|
14
17
|
end
|
15
18
|
|
16
19
|
# @return [string]
|
17
20
|
def get_container_tag
|
18
|
-
|
19
|
-
commit = `git rev-parse --short HEAD`.strip
|
20
|
-
|
21
|
-
tag = "gcr.io/#{@project_name}/#{@app_name}:#{branch}-#{commit}"
|
21
|
+
tag = "gcr.io/#{@project_name}/#{@app_name}:#{@branch}-#{@commit}"
|
22
22
|
|
23
23
|
puts tag
|
24
24
|
|
25
25
|
tag
|
26
26
|
end
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
28
|
+
def get_compose_filename(duty, latest=false)
|
29
|
+
filename = "#{@branch}-"
|
30
|
+
if latest
|
31
|
+
filename << 'latest'
|
32
|
+
else
|
33
|
+
filename << "#{@commit}"
|
34
|
+
end
|
35
|
+
filename << "_#{duty}.yaml"
|
31
36
|
|
32
|
-
|
37
|
+
filename
|
38
|
+
end
|
39
|
+
|
40
|
+
# @return [File]
|
41
|
+
def generate_startup_script
|
42
|
+
dist_file_path = File.join(File.dirname(__FILE__), 'startup.sh.dist')
|
43
|
+
dist = File.read(dist_file_path)
|
33
44
|
|
34
45
|
dist = dist.gsub('<bucket_name>', @app_name)
|
35
46
|
dist = dist.gsub('<app_name>', @app_name)
|
36
|
-
dist = dist.gsub('<primary_yaml>',
|
37
|
-
dist = dist.gsub('<backup_yaml>',
|
47
|
+
dist = dist.gsub('<primary_yaml>', get_compose_filename('primary', true))
|
48
|
+
dist = dist.gsub('<backup_yaml>', get_compose_filename('backup', true))
|
38
49
|
|
39
|
-
filename = "#{branch}-startup.sh"
|
50
|
+
filename = "#{@branch}-startup.sh"
|
40
51
|
out_file = File.new(filename, 'w')
|
41
52
|
out_file.puts(dist)
|
42
53
|
out_file.close
|
43
54
|
|
44
|
-
puts "Generated: #{filename}
|
55
|
+
puts "Generated: #{filename}"
|
45
56
|
|
46
|
-
|
57
|
+
out_file
|
47
58
|
end
|
48
59
|
|
49
60
|
# @return [GoogleCloudStorage]
|
@@ -26,21 +26,23 @@ class GoogleCloudStorage
|
|
26
26
|
@storage.create_bucket @app_name, retries: 3
|
27
27
|
end
|
28
28
|
|
29
|
+
public
|
29
30
|
# @param [string] filepath
|
30
31
|
# @param [string] storage_path
|
31
32
|
# @return [File]
|
32
33
|
def put_file(filepath, storage_path)
|
33
|
-
puts "Putting #{
|
34
|
+
puts "Putting #{filepath} to #{storage_path} on Google Cloud Storage"
|
34
35
|
@bucket.create_file filepath, storage_path
|
35
36
|
end
|
36
37
|
|
38
|
+
public
|
37
39
|
# @param [string] existing_filepath
|
38
40
|
# @param [string] new_filepath
|
39
41
|
# @return [File]
|
40
42
|
def copy_file(existing_filepath, new_filepath)
|
41
43
|
existing_file = @bucket.find_file existing_filepath
|
42
44
|
|
43
|
-
puts "Copying #{existing_filepath} to #{new_filepath}"
|
45
|
+
puts "Copying #{existing_filepath} to #{new_filepath} on Google Cloud Storage"
|
44
46
|
existing_file.copy new_filepath
|
45
47
|
end
|
46
48
|
|