From 37baf5e0d06f44fcac7356db0644fb5914dc0493 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ke=CC=81vin=20Darcel?= Date: Thu, 19 Jan 2017 11:05:29 -0600 Subject: [PATCH 1/3] Update to docker 1.13.0 Changelog https://github.com/docker/docker/releases/tag/v1.13.0 --- .drone.yml | 2 +- Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index 0982b42..ba84784 100644 --- a/.drone.yml +++ b/.drone.yml @@ -16,7 +16,7 @@ pipeline: publish: image: plugins/docker repo: plugins/docker - tags: [ "latest", "1.12", "1" ] + tags: [ "latest", "1.13", "1" ] when: branch: master event: push diff --git a/Dockerfile b/Dockerfile index b71469b..34e8227 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM docker:1.12-dind +FROM docker:1.13-dind ADD drone-docker /bin/ ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh", "/bin/drone-docker"] From f55d828a228e9ec9d15998020a877814eaef3844 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ke=CC=81vin=20Darcel?= Date: Thu, 19 Jan 2017 12:17:43 -0600 Subject: [PATCH 2/3] Add support of --experimental flag --- main.go | 6 ++++++ plugin.go | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/main.go b/main.go index f8fe05b..a901757 100644 --- a/main.go +++ b/main.go @@ -75,6 +75,11 @@ func main() { Usage: "docker daemon IPv6 networking", EnvVar: "PLUGIN_IPV6", }, + cli.BoolFlag{ + Name: "daemon.experimental", + Usage: "docker daemon Experimental mode", + EnvVar: "PLUGIN_EXPERIMENTAL", + }, cli.BoolFlag{ Name: "daemon.debug", Usage: "docker daemon executes in debug mode", @@ -170,6 +175,7 @@ func run(c *cli.Context) error { Bip: c.String("daemon.bip"), DNS: c.StringSlice("daemon.dns"), MTU: c.String("daemon.mtu"), + Experimental: c.Bool("daemon.experimental"), }, } diff --git a/plugin.go b/plugin.go index fae943c..af5bbec 100644 --- a/plugin.go +++ b/plugin.go @@ -28,6 +28,7 @@ type ( DNS []string // Docker daemon dns server MTU string // Docker daemon mtu setting IPv6 bool // Docker daemon IPv6 networking + Experimental bool // Docker daemon enable experimental mode } // Login defines Docker login parameters. @@ -276,6 +277,9 @@ func commandDaemon(daemon Daemon) *exec.Cmd { if len(daemon.MTU) != 0 { args = append(args, "--mtu", daemon.MTU) } + if daemon.Experimental { + args = append(args, "--experimental") + } return exec.Command(dockerExe, args...) } From 66f66c1b1c5248acd321ff857fb959999e36ff26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ke=CC=81vin=20Darcel?= Date: Thu, 19 Jan 2017 12:42:33 -0600 Subject: [PATCH 3/3] Add support of --squash flag on build params --- main.go | 6 ++++++ plugin.go | 26 ++++++++++++++++++-------- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/main.go b/main.go index a901757..5969295 100644 --- a/main.go +++ b/main.go @@ -113,6 +113,11 @@ func main() { Usage: "build args", EnvVar: "PLUGIN_BUILD_ARGS", }, + cli.BoolFlag{ + Name: "squash", + Usage: "squash the layers at build time", + EnvVar: "PLUGIN_SQUASH", + }, cli.StringFlag{ Name: "repo", Usage: "docker repository", @@ -161,6 +166,7 @@ func run(c *cli.Context) error { Context: c.String("context"), Tags: c.StringSlice("tags"), Args: c.StringSlice("args"), + Squash: c.Bool("squash"), Repo: c.String("repo"), }, Daemon: Daemon{ diff --git a/plugin.go b/plugin.go index af5bbec..fbfbc0a 100644 --- a/plugin.go +++ b/plugin.go @@ -46,6 +46,7 @@ type ( Context string // Docker build context Tags []string // Docker build tags Args []string // Docker build args + Squash bool // Docker build squash Repo string // Docker build repository } @@ -109,6 +110,11 @@ func (p Plugin) Exec() error { fmt.Println("Registry credentials not provided. Guest mode enabled.") } + if p.Build.Squash && !p.Daemon.Experimental { + fmt.Println("Squash build flag is only available when Docker deamon is started with experimental flag. Ignoring...") + p.Build.Squash = false + } + // add proxy build args addProxyBuildArgs(&p.Build) @@ -177,19 +183,23 @@ func commandInfo() *exec.Cmd { // helper function to create the docker build command. func commandBuild(build Build) *exec.Cmd { - cmd := exec.Command( - dockerExe, "build", + args := []string { + "build", "--pull=true", "--rm=true", "-f", build.Dockerfile, "-t", build.Name, - ) - - for _, arg := range build.Args { - cmd.Args = append(cmd.Args, "--build-arg", arg) } - cmd.Args = append(cmd.Args, build.Context) - return cmd + + args = append(args, build.Context) + if build.Squash { + args = append(args, "--squash") + } + for _, arg := range build.Args { + args = append(args, "--build-arg", arg) + } + + return exec.Command(dockerExe, args...) } // helper function to add proxy values from the environment