phase 0.0.11 → 0.0.12

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: efb7ef15efc3d89bc0e365884c2aade6a215cf70
4
- data.tar.gz: a352b3bfd0a672d6ce01062263b758251df76023
3
+ metadata.gz: ff87524fd331aa1846e689747bc4775a3df69f7d
4
+ data.tar.gz: ac049168017802c12ae6ed6b62c202b6c683704f
5
5
  SHA512:
6
- metadata.gz: 08044e4ea70d6421c0005306de605bdcd7c03b10d6e3b2723db3a5cd1db463094f11a6b785850d170495279b1aa43c5d6832563d00c725f4bf34f66a8b12cd77
7
- data.tar.gz: 217a1d8005beb9e7aeedfd00be6e51b022f3c483534826f8dcb5957056038e5d7f7ae527513d085379ab66bdef9045e8b815199edd9b0e77133c62c7f0a22b35
6
+ metadata.gz: 2358fef15cabba6491fae0977b28790efa8b4e1a16d308c8483951d046ec78a4d038da7291fde10c061acf96e1cfec3047f8f76e396b88e5928135afaf26ed8e
7
+ data.tar.gz: 12d985acdbd1f5624517270a12314d55c9a3335bc8945965b3b52a6fdfd40c36f89fdc9062b1ede3951cc94807625251496a24d2db0b3616d6464a585474e353
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.11
1
+ 0.0.12
@@ -23,12 +23,13 @@ module Phase
23
23
  end
24
24
 
25
25
  def run
26
- # load_environment_config
27
- # create_build_dir
28
- # shallow_clone_repository
29
- # build_docker_image
30
- # push_docker_image
31
- # trigger_remote_deployment
26
+ if environment == "sandbox"
27
+ deployment = ::Phase::Deploy::SandboxDeployment.new
28
+ else
29
+ deployment = ::Phase::Deploy::Deployment.new(environment)
30
+ end
31
+
32
+ deployment.execute!
32
33
  end
33
34
 
34
35
  end
@@ -23,12 +23,18 @@ module Phase
23
23
  end
24
24
 
25
25
  # Available options:
26
- # * bundle_id_prefix
27
- # * directory_prefix
28
- # * bucket_name
29
- # * company_name
30
- # * full_image_url
31
- # * icon_image_url
26
+ # * docker_repository [String]
27
+ def deploy
28
+ @deploy ||= ::ActiveSupport::OrderedOptions.new
29
+ end
30
+
31
+ # Available options:
32
+ # * bundle_id_prefix [String]
33
+ # * directory_prefix [String]
34
+ # * bucket_name [String]
35
+ # * company_name [String]
36
+ # * full_image_url [String]
37
+ # * icon_image_url [String]
32
38
  def ipa
33
39
  @ipa ||= ::ActiveSupport::OrderedOptions.new
34
40
  end
@@ -2,15 +2,16 @@ module Phase
2
2
  module Deploy
3
3
 
4
4
  class Build
5
- attr_reader :version_tag
5
+ attr_reader :version_tag, :build_dir
6
6
 
7
- def initialize(version_tag)
7
+ def initialize(version_tag, options = {})
8
8
  @version_tag = version_tag
9
+ @build_dir = options.fetch(:build_dir, "./build")
9
10
  end
10
11
 
11
12
  def execute
12
13
  build_image
13
- tag_latest_image
14
+ tag_image
14
15
  push
15
16
  end
16
17
 
@@ -18,28 +19,48 @@ module Phase
18
19
 
19
20
  def build_image
20
21
  clear_build_dir
21
- clone_clean_repo
22
- system("docker build -t #{repo_name}:#{version_tag} .build/")
22
+ clone_local_repo
23
+ system("docker build -t #{repo_name}:#{version_tag} #{build_dir}")
23
24
  end
24
25
 
25
- def tag_latest_image
26
+ def clear_build_dir
27
+ ::FileUtils.mkdir_p(build_dir)
28
+ end
29
+
30
+ def clone_local_repo
31
+ system("git clone --depth 1 -- file://$(pwd) #{build_dir}")
32
+ end
33
+
34
+ def tag_image
26
35
  system("docker tag #{repo_name}:#{version_tag} #{repo_name}:latest")
27
36
  end
28
37
 
29
38
  def push
30
39
  system("docker push #{repo_name}:#{version_tag}")
40
+ system("docker push #{repo_name}:latest")
31
41
  end
32
42
 
33
43
  def repo_name
34
- ::Phase.config.docker_repository
44
+ ::Phase.config.deploy.docker_repository
35
45
  end
36
46
  end
37
47
 
38
48
 
39
49
  class SandboxBuild < Build
40
- def build
41
- system(build_image_cmd)
50
+ def execute
51
+ build_image
52
+ push
42
53
  end
54
+
55
+ private
56
+
57
+ def build_image
58
+ system("docker build -t #{repo_name}:#{version_tag} .")
59
+ end
60
+
61
+ def push
62
+ system("docker push #{repo_name}:#{version_tag}")
63
+ end
43
64
  end
44
65
 
45
66
  end
@@ -1,26 +1,26 @@
1
1
  module Phase
2
2
  module Deploy
3
- class Deployment
4
-
5
- # environment
6
- # build options
7
- # tag strategy
8
- # server options
9
- # environment name
10
- # role name
11
3
 
12
- attr_reader :build
4
+ class Deployment
5
+ attr_reader :environment, :build
13
6
 
14
7
  def initialize(environment, options = {})
15
- case environment
16
- when :sandbox
17
- self.build = SandboxBuild.new
18
- else
19
- self.build = Build.new
20
- end
8
+ @environment = environment
9
+ @build = Build.new(options[:version_tag])
10
+ end
21
11
 
12
+ def execute!
13
+ @build.execute
14
+ deploy_image
15
+ end
16
+ end
22
17
 
18
+
19
+ class SandboxDeployment < Deployment
20
+ def initialize(options = {})
21
+ @build = SandboxBuild.new(options[:version_tag])
23
22
  end
24
23
  end
24
+
25
25
  end
26
26
  end
data/lib/phase/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Phase
2
- VERSION = "0.0.11"
2
+ VERSION = "0.0.12"
3
3
  end
data/phase.gemspec CHANGED
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
27
27
  spec.add_runtime_dependency 'fog', '~> 1.23'
28
28
  spec.add_runtime_dependency 'capistrano', '~> 3.2'
29
29
  spec.add_runtime_dependency 'colorize', '~> 0.7'
30
- spec.add_runtime_dependency 'dotenv', '~> 0.11'
30
+ spec.add_runtime_dependency 'dotenv', '~> 2.0'
31
31
 
32
32
  spec.add_development_dependency 'bundler', '~> 1.6'
33
33
  spec.add_development_dependency 'rake', '~> 10.1'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phase
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piers Mainwaring
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-04-29 00:00:00.000000000 Z
12
+ date: 2015-04-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: commander
@@ -115,14 +115,14 @@ dependencies:
115
115
  requirements:
116
116
  - - "~>"
117
117
  - !ruby/object:Gem::Version
118
- version: '0.11'
118
+ version: '2.0'
119
119
  type: :runtime
120
120
  prerelease: false
121
121
  version_requirements: !ruby/object:Gem::Requirement
122
122
  requirements:
123
123
  - - "~>"
124
124
  - !ruby/object:Gem::Version
125
- version: '0.11'
125
+ version: '2.0'
126
126
  - !ruby/object:Gem::Dependency
127
127
  name: bundler
128
128
  requirement: !ruby/object:Gem::Requirement