Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1459 from hashicorp/backport/bug/pack-docker-host…
Browse files Browse the repository at this point in the history
…/violently-pro-quetzal

Backport of Bump pack to v0.18.1 to pick up DOCKER_HOST fix into release/0.3.x
  • Loading branch information
evanphx authored May 12, 2021
2 parents e841042 + 1ee83d0 commit 3178558
Show file tree
Hide file tree
Showing 7 changed files with 278 additions and 172 deletions.
3 changes: 3 additions & 0 deletions .changelog/1457.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
builtin/pack: Honor DOCKER_HOST properly
```
2 changes: 1 addition & 1 deletion builtin/docker/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ func (p *Platform) Deploy(

name := src.App + "-" + id

cr, err := cli.ContainerCreate(ctx, &cfg, &hostconfig, &netconfig, name)
cr, err := cli.ContainerCreate(ctx, &cfg, &hostconfig, &netconfig, nil, name)
if err != nil {
return nil, status.Errorf(codes.Internal, "unable to create Docker container: %s", err)
}
Expand Down
41 changes: 8 additions & 33 deletions builtin/pack/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import (

"github.com/buildpacks/pack"
"github.com/buildpacks/pack/logging"
"github.com/buildpacks/pack/project"
"github.com/docker/docker/client"
"github.com/hashicorp/go-hclog"
"github.com/hashicorp/waypoint-plugin-sdk/component"
"github.com/hashicorp/waypoint-plugin-sdk/docs"
"github.com/hashicorp/waypoint-plugin-sdk/terminal"
ignore "github.com/sabhiram/go-gitignore"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"

Expand Down Expand Up @@ -78,19 +78,13 @@ func (b *Builder) Build(
builder = DefaultBuilder
}

dockerClient, err := wpdockerclient.NewClientWithOpts(
client.FromEnv,
// If we don't specify a version, the client will use too new an API, and users
// will get and error of the form shown below. Note that when you don't pass a
// client 'pack' does the same thing we're doing here:
//
// client version X.XX is too new. Maximum supported API
client.WithVersion("1.38"),
)
dockerClient, err := wpdockerclient.NewClientWithOpts(client.FromEnv)
if err != nil {
return nil, err
}

dockerClient.NegotiateAPIVersion(ctx)

// We now test if Docker is actually functional. Pack requires a Docker
// daemon and we can't fallback to "img" or any other Dockerless solution.
log.Debug("testing if Docker is available")
Expand Down Expand Up @@ -139,33 +133,14 @@ func (b *Builder) Build(
AppPath: src.Path,
Env: b.config.StaticEnvVars,
Buildpacks: b.config.Buildpacks,
FileFilter: func(file string) bool {
// Do not include the bolt.db or bolt.db.lock
// These files hold the local state when Waypoint is running without a server
// on Windows it will not be possible to copy these files due to a file lock.
if jobInfo.Local {
if strings.HasSuffix(file, "data.db") || strings.HasSuffix(file, "data.db.lock") {
return false
}
}

return true
ProjectDescriptor: project.Descriptor{
Build: project.Build{
Exclude: b.config.Ignore,
},
},
}

if len(b.config.Ignore) > 0 {
excludes := ignore.CompileIgnoreLines(b.config.Ignore...)

old := bo.FileFilter
bo.FileFilter = func(path string) bool {
if !old(path) {
return false
}

return !excludes.MatchesPath(path)
}
}

err = client.Build(ctx, bo)
if err != nil {
return nil, err
Expand Down
35 changes: 15 additions & 20 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@ go 1.13
require (
github.com/Azure/azure-sdk-for-go v42.3.0+incompatible
github.com/Azure/go-autorest/autorest v0.10.2
github.com/Azure/go-autorest/autorest/adal v0.8.3 // indirect
github.com/Azure/go-autorest/autorest/azure/auth v0.4.2
github.com/Azure/go-autorest/autorest/to v0.3.0
github.com/Azure/go-autorest/autorest/validation v0.2.0 // indirect
github.com/adrg/xdg v0.2.1
github.com/armon/circbuf v0.0.0-20190214190532-5111143e8da2
github.com/aws/aws-sdk-go v1.36.31
github.com/bmatcuk/doublestar v1.1.5
github.com/boltdb/bolt v1.3.1
github.com/buildpacks/pack v0.11.1
github.com/buildpacks/pack v0.18.1
github.com/cenkalti/backoff/v4 v4.0.2
github.com/certifi/gocertifi v0.0.0-20200922220541-2c3bb06c6054
github.com/containerd/console v1.0.1
Expand All @@ -23,7 +21,7 @@ require (
github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect
github.com/docker/cli v0.0.0-20200312141509-ef2f64abbd37
github.com/docker/distribution v2.7.1+incompatible
github.com/docker/docker v1.4.2-0.20200319182547-c7ad2b866182
github.com/docker/docker v20.10.0-beta1.0.20201110211921-af34b94a78a1+incompatible
github.com/docker/go-connections v0.4.0
github.com/docker/go-metrics v0.0.1 // indirect
github.com/docker/go-units v0.4.0
Expand All @@ -40,7 +38,7 @@ require (
github.com/go-playground/universal-translator v0.17.0 // indirect
github.com/go-playground/validator v9.31.0+incompatible
github.com/gofrs/flock v0.8.0
github.com/golang/protobuf v1.4.2
github.com/golang/protobuf v1.4.3
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
github.com/gorilla/handlers v1.4.2
github.com/hashicorp/aws-sdk-go-base v0.7.0
Expand Down Expand Up @@ -80,6 +78,8 @@ require (
github.com/mitchellh/pointerstructure v1.0.0
github.com/mitchellh/protoc-gen-go-json v0.0.0-20200917194518-364b693410ae
github.com/mitchellh/reflectwalk v1.0.1 // indirect
github.com/moby/sys/mountinfo v0.4.1 // indirect
github.com/moby/sys/symlink v0.1.0 // indirect
github.com/mr-tron/base58 v1.2.0
github.com/natefinch/atomic v0.0.0-20200526193002-18c0533a5b09
github.com/netlify/open-api v0.15.0
Expand All @@ -92,7 +92,7 @@ require (
github.com/posener/complete v1.2.3
github.com/r3labs/diff v1.1.0
github.com/rs/cors v1.7.0 // indirect
github.com/sabhiram/go-gitignore v0.0.0-20201211210132-54b8a0bf510f
github.com/sabhiram/go-gitignore v0.0.0-20201211210132-54b8a0bf510f // indirect
github.com/sebdah/goldie/v2 v2.5.3
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966
github.com/slack-go/slack v0.6.5
Expand All @@ -101,16 +101,16 @@ require (
github.com/zclconf/go-cty v1.5.1
github.com/zclconf/go-cty-yaml v1.0.2
go.uber.org/goleak v1.1.10
golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0
golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f
golang.org/x/tools v0.0.0-20200410194907-79a7a3126eef // indirect
google.golang.org/api v0.20.0
google.golang.org/genproto v0.0.0-20201002142447-3860012362da
google.golang.org/grpc v1.32.0
golang.org/x/sys v0.0.0-20210511113859-b0526f3d8744
golang.org/x/text v0.3.6 // indirect
google.golang.org/api v0.22.0
google.golang.org/genproto v0.0.0-20201022181438-0ff5f38871d5
google.golang.org/grpc v1.33.1
google.golang.org/protobuf v1.25.0
gopkg.in/go-playground/assert.v1 v1.2.1 // indirect
gopkg.in/yaml.v2 v2.3.0 // indirect
honnef.co/go/tools v0.0.1-2020.1.5 // indirect
k8s.io/api v0.19.4
k8s.io/apimachinery v0.19.4
k8s.io/client-go v0.19.4
Expand All @@ -122,10 +122,5 @@ require (
// replace github.com/hashicorp/horizon => ../horizon
// replace github.com/hashicorp/waypoint-plugin-sdk => ../waypoint-plugin-sdk

replace (
// v0.3.11 panics for some reason on our tests
github.com/imdario/mergo => github.com/imdario/mergo v0.3.9

// https://github.com/ory/dockertest/issues/208
golang.org/x/sys => golang.org/x/sys v0.0.0-20200826173525-f9321e4c35a6
)
// v0.3.11 panics for some reason on our tests
replace github.com/imdario/mergo => github.com/imdario/mergo v0.3.9
Loading

0 comments on commit 3178558

Please sign in to comment.