diff --git a/go.mod b/go.mod index 5dc6924..02e3afb 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.12 require ( github.com/buildpack/libbuildpack v1.22.0 - github.com/cloudfoundry/dagger v0.0.0-20190903212040-da6cedf1fbcb + github.com/cloudfoundry/dagger v0.0.0-20190904150052-ccbcb1be08ca github.com/cloudfoundry/libcfbuildpack v1.84.0 github.com/golang/mock v1.3.1 github.com/google/go-cmp v0.3.1 diff --git a/go.sum b/go.sum index cfb1b46..08d2b22 100644 --- a/go.sum +++ b/go.sum @@ -7,8 +7,8 @@ github.com/buildpack/libbuildpack v1.19.0 h1:HUkaIwuGmPbQhujBjYNpd+E4f0NdAgAgHq7 github.com/buildpack/libbuildpack v1.19.0/go.mod h1:oxgSTzPbWscHs27iuYrctEZpSak2m/qPThA+9JM0Boo= github.com/buildpack/libbuildpack v1.22.0 h1:rwavXaBksbJ3K+vvtpUSsmrxwpIkwvEBPTnJYno1/pI= github.com/buildpack/libbuildpack v1.22.0/go.mod h1:ZQhXsfWdbeglOBaeF3Ea5TSppKih/bVVJxNLX5yg2pg= -github.com/cloudfoundry/dagger v0.0.0-20190903212040-da6cedf1fbcb h1:5oAtaOdqr3V+3Q1RUq9zDnomY+i0EydlYshKbBH5aGg= -github.com/cloudfoundry/dagger v0.0.0-20190903212040-da6cedf1fbcb/go.mod h1:PXeUHc4d2vAVO/31jFE6uD09w/yFfzs4kcayAVEvnEI= +github.com/cloudfoundry/dagger v0.0.0-20190904150052-ccbcb1be08ca h1:fiwxfQhQ0z7koDbbjiufwh5igq8zM0VOTfAsEBsfkBo= +github.com/cloudfoundry/dagger v0.0.0-20190904150052-ccbcb1be08ca/go.mod h1:PXeUHc4d2vAVO/31jFE6uD09w/yFfzs4kcayAVEvnEI= github.com/cloudfoundry/libcfbuildpack v1.76.0 h1:oMTv35mjk5Jogzy2sshVXHyolDWnWHMfANQ0UooXJq0= github.com/cloudfoundry/libcfbuildpack v1.76.0/go.mod h1:QGm+nzixn579dvQNlS7ZQET541y2hEpZ0/5uNxkQ04Y= github.com/cloudfoundry/libcfbuildpack v1.84.0 h1:Z94PAXmryUyGRlq0xXmEwxVmpC8sN713H9DR4lwRBVc= diff --git a/vendor/github.com/cloudfoundry/dagger/app.go b/vendor/github.com/cloudfoundry/dagger/app.go index 7abde22..33e6377 100644 --- a/vendor/github.com/cloudfoundry/dagger/app.go +++ b/vendor/github.com/cloudfoundry/dagger/app.go @@ -44,7 +44,7 @@ func (a *App) StartWithCommand(startCmd string) error { a.Env["PORT"] = "8080" } - args := []string{"run", "-d", "-P"} + args := []string{"run", "-d", "-p", a.Env["PORT"], "-P"} if a.Memory != "" { args = append(args, "--memory", a.Memory) } @@ -76,7 +76,7 @@ func (a *App) StartWithCommand(startCmd string) error { cmd.Stdout = buf cmd.Stderr = os.Stderr if err := cmd.Run(); err != nil { - return err + return errors.Wrap(err, fmt.Sprintf("failed to run docker image: %s\n with command: %s", a.ImageName, args)) } a.ContainerID = buf.String()[:12] @@ -86,17 +86,24 @@ docker: for { select { case <-ticker.C: - status, err := exec.Command("docker", "inspect", "-f", "{{.State.Health.Status}}", a.ContainerID).Output() + health, err := exec.Command("docker", "inspect", "-f", "{{.State.Health}}", a.ContainerID).CombinedOutput() if err != nil { - return err + return errors.Wrap(err, fmt.Sprintf("failed to docker inspect health of container: %s\n with health status: %s\n", a.ContainerID, string(health))) + } + + status := strings.TrimSuffix(string(health), "\n") + if status != "" { + // Split string by space and remove curly brace in front + status = strings.Split(string(status), " ")[0][1:] + status = strings.TrimSpace(status) } - if strings.TrimSpace(string(status)) == "unhealthy" { + if status == "unhealthy" { logs, _ := a.Logs() return errors.Errorf("app failed to start: %s\n%s\n", a.fixtureName, logs) } - if strings.TrimSpace(string(status)) == "healthy" { + if status == "healthy" || status == "" { break docker } case <-timeOut: @@ -108,7 +115,7 @@ docker: cmd.Stdout = buf cmd.Stderr = os.Stderr if err := cmd.Run(); err != nil { - return errors.Wrap(err, "docker error: failed to get port") + return errors.Wrap(err, fmt.Sprintf("docker error: failed to get port from container: %s", a.ContainerID)) } a.port = strings.TrimSpace(strings.Split(buf.String(), ":")[1]) diff --git a/vendor/modules.txt b/vendor/modules.txt index 95bf7b9..57ff304 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -15,7 +15,7 @@ github.com/buildpack/libbuildpack/buildpack github.com/buildpack/libbuildpack/platform github.com/buildpack/libbuildpack/services github.com/buildpack/libbuildpack/stack -# github.com/cloudfoundry/dagger v0.0.0-20190903212040-da6cedf1fbcb +# github.com/cloudfoundry/dagger v0.0.0-20190904150052-ccbcb1be08ca github.com/cloudfoundry/dagger # github.com/cloudfoundry/libcfbuildpack v1.84.0 github.com/cloudfoundry/libcfbuildpack/build