From d29a26fa53d07d37873316da1ea7a79204990dfb Mon Sep 17 00:00:00 2001 From: Brad Rydzewski Date: Fri, 4 Sep 2015 00:28:10 -0700 Subject: [PATCH] first attempt at rancher/docker --- Dockerfile | 14 +------------- main.go | 21 ++++++++++++--------- 2 files changed, 13 insertions(+), 22 deletions(-) diff --git a/Dockerfile b/Dockerfile index b737abb..389a2c8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,20 +2,8 @@ # # docker build --rm=true -t plugins/drone-docker . -FROM ubuntu:14.04 - -RUN apt-get update -qq \ - && apt-get -y install curl \ - apt-transport-https \ - ca-certificates \ - curl \ - lxc \ - iptables \ - && curl -sSL https://get.docker.com/ubuntu/ | sh \ - && rm -rf /var/lib/apt/lists/* +FROM rancher/docker ADD drone-docker /go/bin/ -ADD wrapdocker /bin/ -VOLUME /var/lib/docker ENTRYPOINT ["/go/bin/drone-docker"] diff --git a/main.go b/main.go index 1317f9d..d60afc6 100644 --- a/main.go +++ b/main.go @@ -51,12 +51,8 @@ func main() { // Starts the Docker daemon go func() { - cmd := exec.Command("/bin/bash", "/bin/wrapdocker") - cmd.Stdout = ioutil.Discard - cmd.Stderr = ioutil.Discard - cmd.Run() - args := []string{"daemon", "-s", vargs.Storage} + args := []string{"/usr/bin/docker", "-d", "-s", vargs.Storage} if vargs.Insecure && len(vargs.Registry) != 0 { args = append(args, "--insecure-registry", vargs.Registry) @@ -66,15 +62,22 @@ func main() { args = append(args, "--dns", value) } - cmd = exec.Command("docker", args...) - cmd.Stdout = ioutil.Discard - cmd.Stderr = ioutil.Discard + cmd := exec.Command("/usr/bin/dockerlaunch", args...) + if os.Getenv("DOCKER_LAUNCH_DEBUG") == "true" { + cmd.Env = os.Environ() + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + } else { + cmd.Stdout = ioutil.Discard + cmd.Stderr = ioutil.Discard + } + trace(cmd) cmd.Run() }() // Sleep for a few seconds - time.Sleep(5 * time.Second) + time.Sleep(35 * time.Second) // Set the Registry value if len(vargs.Registry) == 0 {