...
|
...
|
@@ -31,7 +31,7 @@ type builderClient struct {
|
31
|
31
|
needCommit bool
|
32
|
32
|
}
|
33
|
33
|
|
34
|
|
-func (b builderClient) clearTmp(containers, images map[string]struct{}) {
|
|
34
|
+func (b *builderClient) clearTmp(containers, images map[string]struct{}) {
|
35
|
35
|
for c := range containers {
|
36
|
36
|
if _, _, err := b.cli.call("DELETE", "/containers/"+c, nil); err != nil {
|
37
|
37
|
utils.Debugf("%s", err)
|
...
|
...
|
@@ -46,7 +46,7 @@ func (b builderClient) clearTmp(containers, images map[string]struct{}) {
|
46
|
46
|
}
|
47
|
47
|
}
|
48
|
48
|
|
49
|
|
-func (b builderClient) CmdFrom(name string) error {
|
|
49
|
+func (b *builderClient) CmdFrom(name string) error {
|
50
|
50
|
obj, statusCode, err := b.cli.call("GET", "/images/"+name+"/json", nil)
|
51
|
51
|
if statusCode == 404 {
|
52
|
52
|
if err := b.cli.hijack("POST", "/images/create?fromImage="+name, false); err != nil {
|
...
|
...
|
@@ -66,16 +66,17 @@ func (b builderClient) CmdFrom(name string) error {
|
66
|
66
|
return err
|
67
|
67
|
}
|
68
|
68
|
b.image = img.Id
|
|
69
|
+ utils.Debugf("Using image %s", b.image)
|
69
|
70
|
return nil
|
70
|
71
|
}
|
71
|
72
|
|
72
|
|
-func (b builderClient) CmdMaintainer(name string) error {
|
|
73
|
+func (b *builderClient) CmdMaintainer(name string) error {
|
73
|
74
|
b.needCommit = true
|
74
|
75
|
b.maintainer = name
|
75
|
76
|
return nil
|
76
|
77
|
}
|
77
|
78
|
|
78
|
|
-func (b builderClient) CmdRun(args string) error {
|
|
79
|
+func (b *builderClient) CmdRun(args string) error {
|
79
|
80
|
if b.image == "" {
|
80
|
81
|
return fmt.Errorf("Please provide a source image with `from` prior to run")
|
81
|
82
|
}
|
...
|
...
|
@@ -111,7 +112,7 @@ func (b builderClient) CmdRun(args string) error {
|
111
|
111
|
return b.commit(cid)
|
112
|
112
|
}
|
113
|
113
|
|
114
|
|
-func (b builderClient) CmdEnv(args string) error {
|
|
114
|
+func (b *builderClient) CmdEnv(args string) error {
|
115
|
115
|
b.needCommit = true
|
116
|
116
|
tmp := strings.SplitN(args, " ", 2)
|
117
|
117
|
if len(tmp) != 2 {
|
...
|
...
|
@@ -130,10 +131,11 @@ func (b builderClient) CmdEnv(args string) error {
|
130
|
130
|
return nil
|
131
|
131
|
}
|
132
|
132
|
|
133
|
|
-func (b builderClient) CmdCmd(args string) error {
|
|
133
|
+func (b *builderClient) CmdCmd(args string) error {
|
134
|
134
|
b.needCommit = true
|
135
|
135
|
var cmd []string
|
136
|
136
|
if err := json.Unmarshal([]byte(args), &cmd); err != nil {
|
|
137
|
+ utils.Debugf("Error unmarshalling: %s, using /bin/sh -c", err)
|
137
|
138
|
b.config.Cmd = []string{"/bin/sh", "-c", args}
|
138
|
139
|
} else {
|
139
|
140
|
b.config.Cmd = cmd
|
...
|
...
|
@@ -141,19 +143,19 @@ func (b builderClient) CmdCmd(args string) error {
|
141
|
141
|
return nil
|
142
|
142
|
}
|
143
|
143
|
|
144
|
|
-func (b builderClient) CmdExpose(args string) error {
|
|
144
|
+func (b *builderClient) CmdExpose(args string) error {
|
145
|
145
|
ports := strings.Split(args, " ")
|
146
|
146
|
b.config.PortSpecs = append(ports, b.config.PortSpecs...)
|
147
|
147
|
return nil
|
148
|
148
|
}
|
149
|
149
|
|
150
|
|
-func (b builderClient) CmdInsert(args string) error {
|
|
150
|
+func (b *builderClient) CmdInsert(args string) error {
|
151
|
151
|
// FIXME: Reimplement this once the remove_hijack branch gets merged.
|
152
|
152
|
// We need to retrieve the resulting Id
|
153
|
153
|
return fmt.Errorf("INSERT not implemented")
|
154
|
154
|
}
|
155
|
155
|
|
156
|
|
-func (b builderClient) run() (string, error) {
|
|
156
|
+func (b *builderClient) run() (string, error) {
|
157
|
157
|
if b.image == "" {
|
158
|
158
|
return "", fmt.Errorf("Please provide a source image with `from` prior to run")
|
159
|
159
|
}
|
...
|
...
|
@@ -194,7 +196,7 @@ func (b builderClient) run() (string, error) {
|
194
|
194
|
return apiRun.Id, nil
|
195
|
195
|
}
|
196
|
196
|
|
197
|
|
-func (b builderClient) commit(id string) error {
|
|
197
|
+func (b *builderClient) commit(id string) error {
|
198
|
198
|
if b.image == "" {
|
199
|
199
|
return fmt.Errorf("Please provide a source image with `from` prior to run")
|
200
|
200
|
}
|
...
|
...
|
@@ -230,7 +232,7 @@ func (b builderClient) commit(id string) error {
|
230
|
230
|
return nil
|
231
|
231
|
}
|
232
|
232
|
|
233
|
|
-func (b builderClient) Build(dockerfile io.Reader) (string, error) {
|
|
233
|
+func (b *builderClient) Build(dockerfile io.Reader) (string, error) {
|
234
|
234
|
// defer b.clearTmp(tmpContainers, tmpImages)
|
235
|
235
|
file := bufio.NewReader(dockerfile)
|
236
|
236
|
for {
|
...
|
...
|
@@ -253,7 +255,7 @@ func (b builderClient) Build(dockerfile io.Reader) (string, error) {
|
253
|
253
|
instruction := strings.ToLower(strings.Trim(tmp[0], " "))
|
254
|
254
|
arguments := strings.Trim(tmp[1], " ")
|
255
|
255
|
|
256
|
|
- fmt.Printf("%s %s\n", strings.ToUpper(instruction), arguments)
|
|
256
|
+ fmt.Printf("%s %s (%s)\n", strings.ToUpper(instruction), arguments, b.image)
|
257
|
257
|
|
258
|
258
|
method, exists := reflect.TypeOf(b).MethodByName("Cmd" + strings.ToUpper(instruction[:1]) + strings.ToLower(instruction[1:]))
|
259
|
259
|
if !exists {
|