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 +4 -4
- data/README.md +22 -1
- data/VERSION +1 -1
- data/lib/phase.rb +0 -2
- data/lib/phase/cli/build.rb +6 -2
- data/lib/phase/cli/deploy.rb +14 -14
- data/lib/phase/config/deploy.rb +1 -7
- data/lib/phase/configuration.rb +1 -1
- data/lib/phase/kit/deploy/deployment.rb +11 -56
- data/lib/phase/version.rb +1 -1
- data/phase.gemspec +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 831f02bdb22a9315a749be3d9d68047dd4a68d2e
|
4
|
+
data.tar.gz: 4bdeb2e3e904abc8617dddb1f47f07be1c781638
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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.0.2
|
data/lib/phase.rb
CHANGED
data/lib/phase/cli/build.rb
CHANGED
@@ -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
|
|
data/lib/phase/cli/deploy.rb
CHANGED
@@ -3,37 +3,37 @@ module Phase
|
|
3
3
|
class Deploy < Command
|
4
4
|
|
5
5
|
command :deploy do |c|
|
6
|
-
c.syntax = "phase deploy <
|
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
|
12
|
-
|
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 :
|
18
|
+
attr_reader :env_name, :version_number
|
24
19
|
|
25
20
|
def initialize(args, options)
|
26
21
|
super
|
27
22
|
|
28
|
-
fail "
|
29
|
-
|
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
|
-
|
34
|
-
|
33
|
+
environment = config.deploy.environments.find { |e| e.name == env_name }
|
34
|
+
fail "unknown environment: '#{env_name}'" unless environment
|
35
35
|
|
36
|
-
deployment =
|
36
|
+
deployment = Deploy::Deployment.new(environment, version_tag: version_number)
|
37
37
|
deployment.execute!
|
38
38
|
end
|
39
39
|
|
data/lib/phase/config/deploy.rb
CHANGED
@@ -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.
|
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"
|
data/lib/phase/configuration.rb
CHANGED
@@ -2,70 +2,25 @@ module Phase
|
|
2
2
|
module Deploy
|
3
3
|
|
4
4
|
class Deployment
|
5
|
-
|
6
|
-
include ::Phase::Util::Shell
|
5
|
+
attr_reader :options#, :build
|
7
6
|
|
8
|
-
|
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
|
15
|
-
|
16
|
-
|
17
|
-
end
|
11
|
+
# def build
|
12
|
+
# @build ||= Build.new(options[:version_tag])
|
13
|
+
# end
|
18
14
|
|
19
|
-
|
20
|
-
|
21
|
-
deploy_image
|
15
|
+
def execute!
|
16
|
+
# build.execute!
|
17
|
+
deploy_image
|
22
18
|
end
|
23
19
|
|
24
20
|
private
|
25
21
|
|
26
|
-
def deploy_image
|
27
|
-
|
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
|
|
data/lib/phase/version.rb
CHANGED
data/phase.gemspec
CHANGED
@@ -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"
|
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.
|
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
|
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.
|
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
|