-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Phew! This took some figuring out. Details in README-images.md.
- Loading branch information
Showing
12 changed files
with
134 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
error: could not import bar from '<exec>' etc. | ||
error: could not import bar from '<exec>' etc. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,15 @@ | ||
# Makefile for the images used in automated tests | ||
|
||
.PHONY: all | ||
|
||
all: foolib.tar barlib.tar | ||
|
||
foolib.tar: src/foolib/jk/modules/foolib.js | ||
tar -C src/foolib --exclude='*~' -c jk | docker import - foolib:v1 | ||
docker save -o foolib.tar foolib:v1 | ||
|
||
barlib.tar: src/barlib/Dockerfile.base-foo src/barlib/Dockerfile.alpine-foo src/barlib/Dockerfile.alpine-bar | ||
for image in base-foo alpine-foo alpine-bar; do \ | ||
docker build -f "src/barlib/Dockerfile.$$image" -t "$$image" ./src/barlib; \ | ||
done | ||
go run rebase.go --old "alpine-foo" --new "base-foo" --original "alpine-bar" --out "barlib.tar" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package main | ||
|
||
import ( | ||
"flag" | ||
"fmt" | ||
"log" | ||
"os" | ||
|
||
"github.com/google/go-containerregistry/pkg/name" | ||
"github.com/google/go-containerregistry/pkg/v1/daemon" | ||
"github.com/google/go-containerregistry/pkg/v1/mutate" | ||
"github.com/google/go-containerregistry/pkg/v1/tarball" | ||
) | ||
|
||
func mustParseRef(img string) name.Reference { | ||
ref, err := name.ParseReference(img) | ||
if err != nil { | ||
log.Fatalf("could not parse reference from %q: %w", img, err) | ||
} | ||
return ref | ||
} | ||
|
||
func main() { | ||
old := flag.String("old", "", "old base") | ||
nu := flag.String("new", "", "new base") | ||
orig := flag.String("original", "", "image to rebase") | ||
out := flag.String("out", "", "result tarball") | ||
|
||
flag.Parse() | ||
|
||
origImg, err := daemon.Image(mustParseRef(*orig)) | ||
if err != nil { | ||
log.Fatalf("pulling %s: %v", *orig, err) | ||
} | ||
|
||
oldBaseImg, err := daemon.Image(mustParseRef(*old)) | ||
if err != nil { | ||
log.Fatalf("pulling %s: %v", *old, err) | ||
} | ||
|
||
newBaseImg, err := daemon.Image(mustParseRef(*nu)) | ||
if err != nil { | ||
log.Fatalf("pulling %s: %v", *nu, err) | ||
} | ||
|
||
img, err := mutate.Rebase(origImg, oldBaseImg, newBaseImg) | ||
if err != nil { | ||
log.Fatalf("rebasing: %v", err) | ||
} | ||
|
||
image := (*out)[:len(*out)-4] + ":latest" | ||
newTag, err := name.NewTag(image) | ||
if err != nil { | ||
log.Fatalf("could not create image ref %q: %w", image, err) | ||
} | ||
f, err := os.Create(*out) | ||
if err != nil { | ||
log.Fatalf("could not create file %q: %w", *out, err) | ||
} | ||
defer f.Close() | ||
|
||
if err := tarball.Write(newTag, img, f); err != nil { | ||
log.Fatalf("could not write image to %v: %w", *out, err) | ||
} | ||
|
||
digest, err := img.Digest() | ||
if err != nil { | ||
log.Fatalf("digesting rebased: %v", err) | ||
} | ||
fmt.Printf("Wrote image %s@%s to file %s\n", image, digest.String(), *out) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FROM alpine-foo | ||
|
||
WORKDIR /jk/modules | ||
|
||
COPY baz.js ./baz/index.js | ||
RUN rm bar.js | ||
COPY baz.js foo.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
FROM alpine:3.9 | ||
|
||
WORKDIR /jk/modules | ||
|
||
COPY foo.js bar.js ./ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FROM scratch | ||
|
||
WORKDIR /jk/modules | ||
|
||
COPY foo.js bar.js ./ | ||
COPY baz.js ./baz/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default 'bar'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default 'baz'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default 'foo'; |