Skip to content

Commit

Permalink
allowing docker to use cached base image in build
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffDownie committed Feb 17, 2017
1 parent 0d98008 commit 5d96ed0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ _testmain.go

coverage.out
drone-docker

# IDE/Editor related files
**.swp
6 changes: 6 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ func main() {
Usage: "squash the layers at build time",
EnvVar: "PLUGIN_SQUASH",
},
cli.BoolTFlag{
Name: "cache",
Usage: "don't attempt to re-build layers of the image that already exist",
EnvVar: "PLUGIN_USE_CACHE",
},
cli.BoolFlag{
Name: "compress",
Usage: "compress the build context using gzip",
Expand Down Expand Up @@ -172,6 +177,7 @@ func run(c *cli.Context) error {
Tags: c.StringSlice("tags"),
Args: c.StringSlice("args"),
Squash: c.Bool("squash"),
Cache: c.Bool("cache"),
Compress: c.Bool("compress"),
Repo: c.String("repo"),
},
Expand Down
7 changes: 6 additions & 1 deletion plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ type (
Tags []string // Docker build tags
Args []string // Docker build args
Squash bool // Docker build squash
Cache bool // Docker build without pulling
Compress bool // Docker build compress
Repo string // Docker build repository
}
Expand Down Expand Up @@ -187,7 +188,6 @@ func commandInfo() *exec.Cmd {
func commandBuild(build Build) *exec.Cmd {
args := []string {
"build",
"--pull=true",
"--rm=true",
"-f", build.Dockerfile,
"-t", build.Name,
Expand All @@ -200,6 +200,11 @@ func commandBuild(build Build) *exec.Cmd {
if build.Compress {
args = append(args, "--compress")
}
if build.Cache {
args = append(args, "--pull=false")
} else {
args = append(args, "--pull=true")

This comment has been minimized.

Copy link
@ozbillwang

ozbillwang Sep 7, 2017

this commit mixed docker options --pull=true and --no-cache. It is bad naming.

--no-cache | false | Do not use cache when building the image

--pull | false | Always attempt to pull a newer version of the image

If need to add a new feature to enalbe --no-cache, what name can be used?

}
for _, arg := range build.Args {
args = append(args, "--build-arg", arg)
}
Expand Down

0 comments on commit 5d96ed0

Please sign in to comment.