docker-publish 0.0.1 → 0.0.2

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: 603e9552a43527a5befd9f7dd8077cab7693615b
4
- data.tar.gz: 11cbe4ff2ee9a4e46fe7a0484fc41a2388d04b01
3
+ metadata.gz: ece2c1e991dbe762ca4d4c492fded71a2abed48f
4
+ data.tar.gz: d340a2140194cc2479c36aaf11dcc711480e8b30
5
5
  SHA512:
6
- metadata.gz: ae492d4d47e98671a6e645aa6af0150f303e4d7892a6474a0bb98fabeac3e510c1120d1d0efcfe5cbc4d6552bba2b04c338936f2f08bc5e931a836b9a3d784e1
7
- data.tar.gz: bad2e64239a7808f90baea8813fe1274dbbebc1765fca7fba22ce27cc8c42b5e07c9ea7116e9f11ec3c40df503801dcb3e0824a9b64e449c4165dc6142c6e903
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
- def generate_compose_yaml(dist_file_path, duty, port, image_tag)
14
- branch = `git rev-parse --abbrev-ref HEAD`.strip
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}/#{@app_name}-#{branch}-#{commit}_#{duty}.yaml"
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} \n Contents: #{dist}"
27
+ puts "Generated: #{file_path}"
29
28
 
30
- file_path
29
+ out_file
31
30
  end
32
31
 
33
32
 
@@ -5,7 +5,7 @@ class DockerPublish
5
5
  end
6
6
 
7
7
  def self.deploy
8
-
8
+ Deploy
9
9
  end
10
10
 
11
11
  def self.infrastructure
@@ -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
- branch = `git rev-parse --abbrev-ref HEAD`.strip
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
- # @return [string]
29
- def generate_startup_script
30
- branch = `git rev-parse --abbrev-ref HEAD`.strip
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
- dist = File.read('infrastructure/google_cloud_platform/startup.sh.dist')
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>', self.get_yaml_filename('primary', true))
37
- dist = dist.gsub('<backup_yaml>', self.get_yaml_filename('backup', true))
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} \n Contents: #{dist}"
55
+ puts "Generated: #{filename}"
45
56
 
46
- filename
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 #{filename} on Google Cloud Storage"
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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docker-publish
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - VJ Patel