| ... | ... |
@@ -116,10 +116,39 @@ func (builder *Builder) Build(dockerfile io.Reader, stdout io.Writer) error {
|
| 116 | 116 |
} |
| 117 | 117 |
tmpImages[base.Id] = struct{}{}
|
| 118 | 118 |
|
| 119 |
- fmt.Fprintf(stdout, "===> %s\n", base.Id) |
|
| 119 |
+ fmt.Fprintf(stdout, "===> %s\n", base.ShortId()) |
|
| 120 | 120 |
break |
| 121 | 121 |
case "copy": |
| 122 |
- return fmt.Errorf("The copy operator has not yet been implemented")
|
|
| 122 |
+ if image == nil {
|
|
| 123 |
+ return fmt.Errorf("Please provide a source image with `from` prior to copy")
|
|
| 124 |
+ } |
|
| 125 |
+ tmp2 := strings.SplitN(tmp[1], " ", 2) |
|
| 126 |
+ if len(tmp) != 2 {
|
|
| 127 |
+ return fmt.Errorf("Invalid COPY format")
|
|
| 128 |
+ } |
|
| 129 |
+ fmt.Fprintf(stdout, "COPY %s to %s in %s\n", tmp2[0], tmp2[1], base.ShortId()) |
|
| 130 |
+ |
|
| 131 |
+ file, err := Download(tmp2[0], stdout) |
|
| 132 |
+ if err != nil {
|
|
| 133 |
+ return err |
|
| 134 |
+ } |
|
| 135 |
+ defer file.Body.Close() |
|
| 136 |
+ |
|
| 137 |
+ c, err := builder.Run(base, "echo", "insert", tmp2[0], tmp2[1]) |
|
| 138 |
+ if err != nil {
|
|
| 139 |
+ return err |
|
| 140 |
+ } |
|
| 141 |
+ |
|
| 142 |
+ if err := c.Inject(file.Body, tmp2[1]); err != nil {
|
|
| 143 |
+ return err |
|
| 144 |
+ } |
|
| 145 |
+ |
|
| 146 |
+ base, err = builder.Commit(c, "", "", "", "") |
|
| 147 |
+ if err != nil {
|
|
| 148 |
+ return err |
|
| 149 |
+ } |
|
| 150 |
+ fmt.Fprintf(stdout, "===> %s\n", base.ShortId()) |
|
| 151 |
+ break |
|
| 123 | 152 |
default: |
| 124 | 153 |
fmt.Fprintf(stdout, "Skipping unknown op %s\n", tmp[0]) |
| 125 | 154 |
} |
| ... | ... |
@@ -132,7 +161,7 @@ func (builder *Builder) Build(dockerfile io.Reader, stdout io.Writer) error {
|
| 132 | 132 |
for i := range tmpContainers {
|
| 133 | 133 |
delete(tmpContainers, i) |
| 134 | 134 |
} |
| 135 |
- fmt.Fprintf(stdout, "Build finished. image id: %s\n", base.Id) |
|
| 135 |
+ fmt.Fprintf(stdout, "Build finished. image id: %s\n", base.ShortId()) |
|
| 136 | 136 |
} else {
|
| 137 | 137 |
fmt.Fprintf(stdout, "An error occured during the build\n") |
| 138 | 138 |
} |