phase 1.0.1 → 1.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: 8b98166c521639cc9a17b9c261d187ce338115b0
4
- data.tar.gz: 12531f8dcc6ce6107df04dbe395727b90ab95310
3
+ metadata.gz: 831f02bdb22a9315a749be3d9d68047dd4a68d2e
4
+ data.tar.gz: 4bdeb2e3e904abc8617dddb1f47f07be1c781638
5
5
  SHA512:
6
- metadata.gz: 83fdd520be80187641bd67d6d2ff972d5fc12a0b71641dadc97ae26a68efa7d215f189501ed57e4996e9c7bad0a69d7dbd51b8f5973da79437a22a360ecd5864
7
- data.tar.gz: 7f660c96a4f6dcb297b4b6e7647ab3cbd5ccab1f45c340534c099387bd3c69d4c44dffcc6e7b5d664d75e478ae9bc31a1fd150264814b5c82ee4dd5eeb3749bd
6
+ metadata.gz: e8029008bd5d8b99f32fee336b68f63ffb329b57cf20f3dc38ca528d60a8d576ec6bb390b4e4066fe207328ce6984bdc74db7ed1219d978b10d78e90e8e1a8ad
7
+ data.tar.gz: 9ac574ca17979e278f47db24ddb5a71d012ffc064db4180c3bcbd5000964842f33753259ae7d07c4f3b765b65097effbb4fb9201361b581697702ce164068c37
data/README.md CHANGED
@@ -18,7 +18,28 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- TODO: Write usage instructions here
21
+ ### Phasefile
22
+
23
+ In order to configure Phase, you'll need to create a `Phasefile` at the
24
+ root of your project.
25
+
26
+ **Phasefile**
27
+ ```ruby
28
+ Phase.configure do |config|
29
+ # config.deploy.docker_repository = "mycompany/myrepo"
30
+ # config.deploy.docker_repository = "https://docker.mycompany.com/myrepo"
31
+ # config.deploy.asset_bucket = "static-assets"
32
+ end
33
+ ```
34
+
35
+ #### Docker Repository - Required
36
+ This is where you tell phase where to push your built image to. Accepts
37
+ Docker Hub naming convention of "user/reponame" or your own container
38
+ host.
39
+
40
+ #### S3 Assets
41
+ Provide a bucket name and Phase will push your compiled assets to that S3
42
+ Bucket.
22
43
 
23
44
  ## Contributing
24
45
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.1
1
+ 1.0.2
@@ -7,8 +7,6 @@ require 'progressbar'
7
7
  require 'sshkit'
8
8
  require 'terminal-table'
9
9
 
10
- require 'pry'
11
-
12
10
 
13
11
  require 'phase/adapter'
14
12
  require 'phase/adapters/abstract'
@@ -6,6 +6,7 @@ module Phase
6
6
  c.syntax = "phase build [-s]"
7
7
 
8
8
  c.option "-s", "--sandbox", String, "Build in sandbox mode: uses current directory's possibly dirty git tree as build context."
9
+ c.option "-n", "--version-number", String, "Build number to create."
9
10
 
10
11
  c.description = <<-EOS.strip_heredoc
11
12
  Builds a new Docker image of the latest committed code on the current branch. Tags the
@@ -23,17 +24,20 @@ module Phase
23
24
  def initialize(args, options)
24
25
  super
25
26
  @clean_build = !options.sandbox
27
+ @version_number = options.version_number
26
28
  end
27
29
 
28
30
  def run
29
- version_number = get_next_version_number
30
-
31
31
  build = ::Phase::Deploy::Build.new(version_number, clean_build: clean_build)
32
32
  build.execute!
33
33
  end
34
34
 
35
35
  private
36
36
 
37
+ def version_number
38
+ @version_number ||= get_next_version_number
39
+ end
40
+
37
41
  def get_next_version_number
38
42
  current_version = ::Phase::Deploy::Version.current
39
43
 
@@ -3,37 +3,37 @@ module Phase
3
3
  class Deploy < Command
4
4
 
5
5
  command :deploy do |c|
6
- c.syntax = "phase deploy <instance_role> [-n version_number]"
7
-
8
- c.option "-n", "--number", String, "Specific version number to deploy."
6
+ c.syntax = "phase deploy <environment_name> <version_number>"
9
7
 
10
8
  c.description = <<-EOS.strip_heredoc
11
- Builds and deploys code to instance with the specified <instance_role> in their
12
- "Role" tags. Deploys the current version (in the file set via
13
- `config.deploy.version_lockfile`) unless an alternate version is provided with the
14
- -n option.
9
+ Builds and deploys code to the specified <environment_name>, which may be
10
+ any environment configured in the Phasefile.
15
11
  EOS
16
12
 
17
13
  c.action do |args, options|
18
- options.default(number: ::Phase::Deploy::Version.current)
19
14
  new(args, options).run
20
15
  end
21
16
  end
22
17
 
23
- attr_reader :instance_role
18
+ attr_reader :env_name, :version_number
24
19
 
25
20
  def initialize(args, options)
26
21
  super
27
22
 
28
- fail "Must specify 'instance_role' name" if args.first.blank?
29
- @instance_role = args.first
23
+ fail "must specify both environment and version number" unless args.count >= 2
24
+
25
+ @env_name = args[0]
26
+ @version_number = args[1]
27
+
28
+ fail "must specify environment" unless env_name
29
+ fail "must specify version number" unless version_number
30
30
  end
31
31
 
32
32
  def run
33
- # environment = config.deploy.environments.find { |e| e.name == instance_role }
34
- # fail "unknown environment: '#{instance_role}'" unless environment
33
+ environment = config.deploy.environments.find { |e| e.name == env_name }
34
+ fail "unknown environment: '#{env_name}'" unless environment
35
35
 
36
- deployment = ::Phase::Deploy::Deployment.new(instance_role, options.number)
36
+ deployment = Deploy::Deployment.new(environment, version_tag: version_number)
37
37
  deployment.execute!
38
38
  end
39
39
 
@@ -21,16 +21,10 @@ module Phase
21
21
 
22
22
  # @return [String] the cloud storage bucket ("directory") for storing compiled assets
23
23
  # @example Sample settings
24
- # config.deploy.docker_repository = "static-assets"
24
+ # config.deploy.asset_bucket = "static-assets"
25
25
  attr_accessor :asset_bucket
26
26
 
27
27
 
28
- # @return [String] any options or switches to be passed to the Docker daemon at runtime
29
- # @example Sample settings
30
- # config.deploy.docker_run_flags = "-v /dir:/dir -e VAR=value --env-file=.environment"
31
- attr_accessor :docker_run_flags
32
-
33
-
34
28
  def initialize
35
29
  @environments = []
36
30
  @version_lockfile = "VERSION"
@@ -13,7 +13,7 @@ module Phase
13
13
  @aws_region = "us-east-1"
14
14
  @adapter = ::Phase::Adapters::AWS
15
15
 
16
- # self.backend = ::Phase::SSH::Backend
16
+ self.backend = ::Phase::SSH::Backend
17
17
  set_aws_credentials!
18
18
  end
19
19
 
@@ -2,70 +2,25 @@ module Phase
2
2
  module Deploy
3
3
 
4
4
  class Deployment
5
- include ::Phase::Util::Console
6
- include ::Phase::Util::Shell
5
+ attr_reader :options#, :build
7
6
 
8
- attr_reader :role_name, :version_tag, :options
9
-
10
- def initialize(role_name, version_tag, options = {})
11
- @role_name, @version_tag, @options = role_name, version_tag, options
7
+ def initialize(options = {})
8
+ @options = options
12
9
  end
13
10
 
14
- def execute!
15
- hosts = ::Phase::Adapters::AWS::Server.where(role: role_name).map do |host|
16
- "deploy@#{host.resource.dns_name}"
17
- end
11
+ # def build
12
+ # @build ||= Build.new(options[:version_tag])
13
+ # end
18
14
 
19
- fail "No instance with role `role_name' found" if hosts.blank?
20
-
21
- deploy_image(hosts)
15
+ def execute!
16
+ # build.execute!
17
+ deploy_image
22
18
  end
23
19
 
24
20
  private
25
21
 
26
- def deploy_image(hosts, options = {})
27
- image_name = docker_image_name
28
- server_count = 2 # FIXME: make this a config var
29
- run_flags = docker_run_flags
30
- delay_seconds = 35 # FIXME: make this a config var
31
-
32
- ::SSHKit::Coordinator.new(hosts).each(options) do
33
- execute(:docker, :pull, image_name)
34
-
35
- # TODO: fail if pending migrations
36
- # execute(:docker, :run, run_flags, "--rm -it", image_name,
37
- # "bundle exec rails runner '::ActiveRecord::Migrator.needs_migration? ? exit(1) : exit(0)'")
38
-
39
- server_count.times do |i|
40
- progress_bar = ::ProgressBar.new("Deploying ##{i}", delay_seconds)
41
-
42
- server_name = "server-#{i}"
43
- port_number = 3000 + i # FIXME: make this a config var
44
-
45
- execute(:docker, :stop, server_name, raise_on_non_zero_exit: false)
46
- execute(:docker, :rm, server_name, raise_on_non_zero_exit: false)
47
-
48
- execute(:docker, :run, run_flags, "-p #{port_number}:3000 --name #{server_name} -d", image_name)
49
-
50
- # TODO: test for server responding correctly
51
- unless i == server_count - 1
52
- delay_seconds.times do
53
- sleep 1
54
- progress_bar.inc
55
- end
56
- end
57
-
58
- progress_bar.finish
59
- end
60
- end
61
- end
62
-
63
- def docker_image_name
64
- @docker_image ||= "#{::Phase.config.deploy.docker_repository}:#{version_tag}"
65
- end
66
-
67
- def docker_run_flags
68
- @docker_run_flags ||= ::Phase.config.deploy.docker_run_flags
22
+ def deploy_image
23
+ system("echo yaaaay")
69
24
  end
70
25
  end
71
26
 
@@ -1,3 +1,3 @@
1
1
  module Phase
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
@@ -6,7 +6,7 @@ require 'phase/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "phase"
8
8
  spec.version = Phase::VERSION
9
- spec.authors = ["Piers Mainwaring", "Orca Health, Inc."]
9
+ spec.authors = ["Piers Mainwaring"]
10
10
  spec.email = ["piers@impossibly.org"]
11
11
  spec.summary = "A simple way to manage cloud instances within a multi-subnet network, like an AWS VPC."
12
12
  spec.description = ""
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phase
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piers Mainwaring
8
- - Orca Health, Inc.
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2016-01-15 00:00:00.000000000 Z
11
+ date: 2016-04-01 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: commander
@@ -261,7 +260,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
261
260
  version: '0'
262
261
  requirements: []
263
262
  rubyforge_project:
264
- rubygems_version: 2.4.5
263
+ rubygems_version: 2.5.1
265
264
  signing_key:
266
265
  specification_version: 4
267
266
  summary: A simple way to manage cloud instances within a multi-subnet network, like