|
|
@@ -26,6 +26,7 @@ func cmdBuild(c *cli.Context) error {
|
|
|
default:
|
|
|
return fmt.Errorf(`invalid value for --pull: %q`, pull)
|
|
|
}
|
|
|
+ dryRun := c.Bool("dry-run")
|
|
|
|
|
|
for _, repo := range repos {
|
|
|
r, err := fetch(repo)
|
|
|
@@ -62,7 +63,9 @@ func cmdBuild(c *cli.Context) error {
|
|
|
if doPull {
|
|
|
// TODO detect if "from" is something we've built (ie, "python:3-onbuild" is "FROM python:3" but we don't want to pull "python:3" if we "bashbrew build python")
|
|
|
fmt.Printf("Pulling %s (%s)\n", from, r.EntryIdentifier(entry))
|
|
|
- dockerPull(from)
|
|
|
+ if !dryRun {
|
|
|
+ dockerPull(from)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -75,33 +78,35 @@ func cmdBuild(c *cli.Context) error {
|
|
|
_, err = dockerInspect("{{.Id}}", cacheTag)
|
|
|
if err != nil {
|
|
|
fmt.Printf("Building %s (%s)\n", cacheTag, r.EntryIdentifier(entry))
|
|
|
-
|
|
|
- commit, err := r.fetchGitRepo(arch, &entry)
|
|
|
- if err != nil {
|
|
|
- return cli.NewMultiError(fmt.Errorf(`failed fetching git repo for %q (tags %q)`, r.RepoName, entry.TagsString()), err)
|
|
|
- }
|
|
|
-
|
|
|
- archive, err := gitArchive(commit, entry.ArchDirectory(arch))
|
|
|
- if err != nil {
|
|
|
- return cli.NewMultiError(fmt.Errorf(`failed generating git archive for %q (tags %q)`, r.RepoName, entry.TagsString()), err)
|
|
|
+ if !dryRun {
|
|
|
+ commit, err := r.fetchGitRepo(arch, &entry)
|
|
|
+ if err != nil {
|
|
|
+ return cli.NewMultiError(fmt.Errorf(`failed fetching git repo for %q (tags %q)`, r.RepoName, entry.TagsString()), err)
|
|
|
+ }
|
|
|
+
|
|
|
+ archive, err := gitArchive(commit, entry.ArchDirectory(arch))
|
|
|
+ if err != nil {
|
|
|
+ return cli.NewMultiError(fmt.Errorf(`failed generating git archive for %q (tags %q)`, r.RepoName, entry.TagsString()), err)
|
|
|
+ }
|
|
|
+ defer archive.Close()
|
|
|
+
|
|
|
+ err = dockerBuild(cacheTag, archive)
|
|
|
+ if err != nil {
|
|
|
+ return cli.NewMultiError(fmt.Errorf(`failed building %q (tags %q)`, r.RepoName, entry.TagsString()), err)
|
|
|
+ }
|
|
|
+ archive.Close() // be sure this happens sooner rather than later (defer might take a while, and we want to reap zombies more aggressively)
|
|
|
}
|
|
|
- defer archive.Close()
|
|
|
-
|
|
|
- err = dockerBuild(cacheTag, archive)
|
|
|
- if err != nil {
|
|
|
- return cli.NewMultiError(fmt.Errorf(`failed building %q (tags %q)`, r.RepoName, entry.TagsString()), err)
|
|
|
- }
|
|
|
- archive.Close() // be sure this happens sooner rather than later (defer might take a while, and we want to reap zombies more aggressively)
|
|
|
} else {
|
|
|
fmt.Printf("Using %s (%s)\n", cacheTag, r.EntryIdentifier(entry))
|
|
|
}
|
|
|
|
|
|
for _, tag := range r.Tags(namespace, uniq, entry) {
|
|
|
fmt.Printf("Tagging %s\n", tag)
|
|
|
-
|
|
|
- err := dockerTag(cacheTag, tag)
|
|
|
- if err != nil {
|
|
|
- return cli.NewMultiError(fmt.Errorf(`failed tagging %q as %q`, cacheTag, tag), err)
|
|
|
+ if !dryRun {
|
|
|
+ err := dockerTag(cacheTag, tag)
|
|
|
+ if err != nil {
|
|
|
+ return cli.NewMultiError(fmt.Errorf(`failed tagging %q as %q`, cacheTag, tag), err)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|