building 1.0.0 → 1.1.0
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 +4 -4
- data/lib/building.rb +70 -24
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3744e78cd0ca432f9d2fda9ecb230627a264f96f
|
4
|
+
data.tar.gz: 2c29701e06a4767e68521b8a5a6caba511b7a289
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aaaab250877fe69b264a65ff26f0b1506d04b812fead145b4734203353d4fa8bfba31bce34bf6ac1edac0594ee1b953ec6621dfb9271976f3eafbf3030818fe5
|
7
|
+
data.tar.gz: 8ac316c49e0fe3b3c49956a47d6818106f05fd6a2467fd95b747e2caeb7996f91c37e6e140e074050ef01d051a70f71e5442398dcc7f2e4f98e281949951f963
|
data/lib/building.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
require 'yaml'
|
2
2
|
require 'fileutils'
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'highline/import'
|
3
5
|
|
4
6
|
class Building
|
5
7
|
def self.convert(app_name, tag, options={})
|
@@ -19,57 +21,71 @@ class Building
|
|
19
21
|
create_dockerfile
|
20
22
|
build_container
|
21
23
|
|
24
|
+
build_fig if @fig
|
25
|
+
|
22
26
|
if @port
|
23
27
|
run_container(@port)
|
24
28
|
else
|
25
29
|
explain_container(8080)
|
26
30
|
end
|
27
31
|
|
28
|
-
if @fig
|
29
|
-
build_fig
|
30
|
-
end
|
31
|
-
|
32
32
|
exit 0
|
33
33
|
end
|
34
34
|
|
35
35
|
def create_dockerfile
|
36
|
-
|
37
|
-
|
38
|
-
end
|
36
|
+
dockerfile = []
|
37
|
+
dockerfile << "FROM #{@from || "ctlc/buildstep:ubuntu13.10"}\n"
|
39
38
|
|
40
39
|
if @buildpack_url
|
41
|
-
|
42
|
-
file << <<-eof
|
40
|
+
dockerfile << <<-eof
|
43
41
|
RUN git clone --depth 1 #{@buildpack_url} /build/buildpacks/#{@buildpack_url.split("/").last.sub(".git","")}
|
44
42
|
RUN echo #{@buildpack_url} >> /build/buildpacks.txt
|
45
43
|
eof
|
46
|
-
end
|
47
44
|
end
|
48
45
|
|
49
46
|
if @includes
|
50
|
-
|
51
|
-
file << "RUN #{@includes}\n"
|
52
|
-
end
|
47
|
+
dockerfile << "RUN #{@includes}\n"
|
53
48
|
end
|
54
49
|
|
55
50
|
if @file
|
56
|
-
|
57
|
-
file << IO.read(@file)
|
58
|
-
end
|
51
|
+
dockerfile << IO.read(@file)
|
59
52
|
end
|
60
53
|
|
61
|
-
|
62
|
-
file << <<-eof
|
54
|
+
dockerfile << <<-eof
|
63
55
|
ADD . /app
|
64
56
|
RUN /build/builder
|
65
57
|
CMD /start web
|
66
58
|
eof
|
59
|
+
|
60
|
+
skip = false
|
61
|
+
|
62
|
+
if File.exists?("Dockerfile")
|
63
|
+
if IO.read("Dockerfile") == dockerfile.join("\n")
|
64
|
+
skip = true
|
65
|
+
say %{ <%= color('identical', [BLUE, BOLD]) %> Dockerfile}
|
66
|
+
else
|
67
|
+
say %{ <%= color('conflict', [RED, BOLD]) %> Dockerfile}
|
68
|
+
choice = ask("Overwrite Dockerfile? [Yn] ")
|
69
|
+
if choice.downcase == "n"
|
70
|
+
say("Aborting...")
|
71
|
+
exit 1
|
72
|
+
else
|
73
|
+
say %{ <%= color('force', [YELLOW, BOLD]) %> Dockerfile}
|
74
|
+
end
|
75
|
+
end
|
76
|
+
else
|
77
|
+
say %{ <%= color('create', [GREEN, BOLD]) %> Dockerfile}
|
78
|
+
end
|
79
|
+
|
80
|
+
if !skip
|
81
|
+
File.open("Dockerfile" , "w") do |file|
|
82
|
+
file << dockerfile.join("\n")
|
83
|
+
end
|
67
84
|
end
|
68
85
|
end
|
69
86
|
|
70
87
|
def build_fig
|
71
|
-
|
72
|
-
file << <<-eof
|
88
|
+
figfile = <<-eof
|
73
89
|
web:
|
74
90
|
image: #{@app_name}:#{@tag}
|
75
91
|
command: /start web
|
@@ -78,22 +94,52 @@ web:
|
|
78
94
|
ports:
|
79
95
|
- #{@port || 8080}
|
80
96
|
eof
|
97
|
+
|
98
|
+
skip = false
|
99
|
+
|
100
|
+
if File.exists?(@fig)
|
101
|
+
if IO.read(@fig) == figfile
|
102
|
+
skip = true
|
103
|
+
say %{ <%= color('identical', [BLUE, BOLD]) %> #{@fig}}
|
104
|
+
else
|
105
|
+
say %{ <%= color('conflict', [RED, BOLD]) %> #{@fig}}
|
106
|
+
choice = ask("Overwrite #{File.expand_path(@fig)}? [Yn] ")
|
107
|
+
if choice.downcase == "n"
|
108
|
+
say("Aborting...")
|
109
|
+
exit 1
|
110
|
+
else
|
111
|
+
say %{ <%= color('force', [YELLOW, BOLD]) %> #{@fig}}
|
112
|
+
end
|
113
|
+
end
|
114
|
+
else
|
115
|
+
say %{ <%= color('create', [GREEN, BOLD]) %> #{@fig}}
|
116
|
+
end
|
117
|
+
|
118
|
+
if !skip
|
119
|
+
File.open(@fig , "w") do |file|
|
120
|
+
file << figfile
|
121
|
+
end
|
81
122
|
end
|
82
123
|
end
|
83
124
|
|
84
125
|
def build_container
|
85
|
-
|
126
|
+
build_cmd = "docker build -t #{@app_name}:#{@tag} ."
|
127
|
+
say %{ <%= color('building', [BLUE, BOLD]) %> #{build_cmd}}
|
128
|
+
pid = fork { exec build_cmd }
|
86
129
|
Process.waitpid(pid)
|
87
130
|
end
|
88
131
|
|
89
132
|
def explain_container(port)
|
90
133
|
run = "docker run -d -p #{port} -e \"PORT=#{port}\" #{@app_name}:#{@tag}"
|
91
|
-
|
134
|
+
rebuild = "docker build -t #{@app_name} ."
|
135
|
+
|
136
|
+
say " <%= color('hint', [YELLOW, BOLD]) %> To run your app, try: <%= color('#{run}', [BOLD]) %>"
|
137
|
+
say " <%= color('hint', [YELLOW, BOLD]) %> To re-build your app, try: <%= color('#{rebuild}', [BOLD]) %>"
|
92
138
|
end
|
93
139
|
|
94
140
|
def run_container(port)
|
95
|
-
run = "
|
96
|
-
|
141
|
+
run = "docker run -d -p #{port} -e \"PORT=#{port}\" #{@app_name}:#{@tag}"
|
142
|
+
say " <%= color('running', [BLUE, BOLD]) %> #{run}"
|
97
143
|
exec run
|
98
144
|
end
|
99
145
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: building
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lucas Carlson
|
@@ -17,8 +17,8 @@ executables:
|
|
17
17
|
extensions: []
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
|
-
- bin/building
|
21
20
|
- lib/building.rb
|
21
|
+
- bin/building
|
22
22
|
homepage: http://github.com/CenturyLinkLabs/building
|
23
23
|
licenses:
|
24
24
|
- MIT
|
@@ -29,18 +29,19 @@ require_paths:
|
|
29
29
|
- lib
|
30
30
|
required_ruby_version: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- -
|
32
|
+
- - '>='
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '0'
|
35
35
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
|
-
- -
|
37
|
+
- - '>='
|
38
38
|
- !ruby/object:Gem::Version
|
39
39
|
version: '0'
|
40
40
|
requirements:
|
41
41
|
- bundler
|
42
|
+
- highline
|
42
43
|
rubyforge_project:
|
43
|
-
rubygems_version: 2.
|
44
|
+
rubygems_version: 2.0.3
|
44
45
|
signing_key:
|
45
46
|
specification_version: 4
|
46
47
|
summary: Build a Docker container for any app using Heroku Buildpacks
|