commit
eb071419d4
@ -16,7 +16,7 @@ pipeline:
|
|||||||
publish:
|
publish:
|
||||||
image: plugins/docker
|
image: plugins/docker
|
||||||
repo: plugins/docker
|
repo: plugins/docker
|
||||||
tags: [ "latest", "1.12", "1" ]
|
tags: [ "latest", "1.13", "1" ]
|
||||||
when:
|
when:
|
||||||
branch: master
|
branch: master
|
||||||
event: push
|
event: push
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
FROM docker:1.12-dind
|
FROM docker:1.13-dind
|
||||||
|
|
||||||
ADD drone-docker /bin/
|
ADD drone-docker /bin/
|
||||||
ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh", "/bin/drone-docker"]
|
ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh", "/bin/drone-docker"]
|
||||||
|
12
main.go
12
main.go
@ -75,6 +75,11 @@ func main() {
|
|||||||
Usage: "docker daemon IPv6 networking",
|
Usage: "docker daemon IPv6 networking",
|
||||||
EnvVar: "PLUGIN_IPV6",
|
EnvVar: "PLUGIN_IPV6",
|
||||||
},
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "daemon.experimental",
|
||||||
|
Usage: "docker daemon Experimental mode",
|
||||||
|
EnvVar: "PLUGIN_EXPERIMENTAL",
|
||||||
|
},
|
||||||
cli.BoolFlag{
|
cli.BoolFlag{
|
||||||
Name: "daemon.debug",
|
Name: "daemon.debug",
|
||||||
Usage: "docker daemon executes in debug mode",
|
Usage: "docker daemon executes in debug mode",
|
||||||
@ -108,6 +113,11 @@ func main() {
|
|||||||
Usage: "build args",
|
Usage: "build args",
|
||||||
EnvVar: "PLUGIN_BUILD_ARGS",
|
EnvVar: "PLUGIN_BUILD_ARGS",
|
||||||
},
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "squash",
|
||||||
|
Usage: "squash the layers at build time",
|
||||||
|
EnvVar: "PLUGIN_SQUASH",
|
||||||
|
},
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "repo",
|
Name: "repo",
|
||||||
Usage: "docker repository",
|
Usage: "docker repository",
|
||||||
@ -156,6 +166,7 @@ func run(c *cli.Context) error {
|
|||||||
Context: c.String("context"),
|
Context: c.String("context"),
|
||||||
Tags: c.StringSlice("tags"),
|
Tags: c.StringSlice("tags"),
|
||||||
Args: c.StringSlice("args"),
|
Args: c.StringSlice("args"),
|
||||||
|
Squash: c.Bool("squash"),
|
||||||
Repo: c.String("repo"),
|
Repo: c.String("repo"),
|
||||||
},
|
},
|
||||||
Daemon: Daemon{
|
Daemon: Daemon{
|
||||||
@ -170,6 +181,7 @@ func run(c *cli.Context) error {
|
|||||||
Bip: c.String("daemon.bip"),
|
Bip: c.String("daemon.bip"),
|
||||||
DNS: c.StringSlice("daemon.dns"),
|
DNS: c.StringSlice("daemon.dns"),
|
||||||
MTU: c.String("daemon.mtu"),
|
MTU: c.String("daemon.mtu"),
|
||||||
|
Experimental: c.Bool("daemon.experimental"),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
30
plugin.go
30
plugin.go
@ -28,6 +28,7 @@ type (
|
|||||||
DNS []string // Docker daemon dns server
|
DNS []string // Docker daemon dns server
|
||||||
MTU string // Docker daemon mtu setting
|
MTU string // Docker daemon mtu setting
|
||||||
IPv6 bool // Docker daemon IPv6 networking
|
IPv6 bool // Docker daemon IPv6 networking
|
||||||
|
Experimental bool // Docker daemon enable experimental mode
|
||||||
}
|
}
|
||||||
|
|
||||||
// Login defines Docker login parameters.
|
// Login defines Docker login parameters.
|
||||||
@ -45,6 +46,7 @@ type (
|
|||||||
Context string // Docker build context
|
Context string // Docker build context
|
||||||
Tags []string // Docker build tags
|
Tags []string // Docker build tags
|
||||||
Args []string // Docker build args
|
Args []string // Docker build args
|
||||||
|
Squash bool // Docker build squash
|
||||||
Repo string // Docker build repository
|
Repo string // Docker build repository
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,6 +110,11 @@ func (p Plugin) Exec() error {
|
|||||||
fmt.Println("Registry credentials not provided. Guest mode enabled.")
|
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
|
// add proxy build args
|
||||||
addProxyBuildArgs(&p.Build)
|
addProxyBuildArgs(&p.Build)
|
||||||
|
|
||||||
@ -176,19 +183,23 @@ func commandInfo() *exec.Cmd {
|
|||||||
|
|
||||||
// helper function to create the docker build command.
|
// helper function to create the docker build command.
|
||||||
func commandBuild(build Build) *exec.Cmd {
|
func commandBuild(build Build) *exec.Cmd {
|
||||||
cmd := exec.Command(
|
args := []string {
|
||||||
dockerExe, "build",
|
"build",
|
||||||
"--pull=true",
|
"--pull=true",
|
||||||
"--rm=true",
|
"--rm=true",
|
||||||
"-f", build.Dockerfile,
|
"-f", build.Dockerfile,
|
||||||
"-t", build.Name,
|
"-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
|
// helper function to add proxy values from the environment
|
||||||
@ -276,6 +287,9 @@ func commandDaemon(daemon Daemon) *exec.Cmd {
|
|||||||
if len(daemon.MTU) != 0 {
|
if len(daemon.MTU) != 0 {
|
||||||
args = append(args, "--mtu", daemon.MTU)
|
args = append(args, "--mtu", daemon.MTU)
|
||||||
}
|
}
|
||||||
|
if daemon.Experimental {
|
||||||
|
args = append(args, "--experimental")
|
||||||
|
}
|
||||||
return exec.Command(dockerExe, args...)
|
return exec.Command(dockerExe, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user