Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read dockerignore in dev and deploy commands #757

Merged
merged 3 commits into from
Feb 6, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion commands/provider/service_deployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ package provider
import (
"context"
"errors"
"fmt"
"io"

"github.com/asaskevich/govalidator"
"github.com/docker/cli/cli/command/image/build"
"github.com/docker/docker/pkg/archive"
"github.com/mesg-foundation/core/protobuf/coreapi"
)
Expand Down Expand Up @@ -73,8 +75,27 @@ func (p *ServiceProvider) ServiceDeploy(path string, env map[string]string, stat
}

func deployServiceSendServiceContext(path string, env map[string]string, stream coreapi.Core_DeployServiceClient) error {
contextDir, relDockerfile, err := build.GetContextFromLocalDir(path, build.DefaultDockerfileName)
if err != nil {
return err
}

excludes, err := build.ReadDockerignore(contextDir)
if err != nil {
return err
}

if err := build.ValidateContextDirectory(contextDir, excludes); err != nil {
return fmt.Errorf("error checking context: %s", err)
}

// And canonicalize dockerfile name to a platform-independent one
relDockerfile = archive.CanonicalTarNameForPath(relDockerfile)
excludes = build.TrimBuildFilesFromExcludes(excludes, relDockerfile, false)

archive, err := archive.TarWithOptions(path, &archive.TarOptions{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about xarchive package?

Should we refacto most of the content of deployServiceSendServiceContext or simply delete xarchive package?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some other packages like service (or container) can use it, but it needs refactoring first. And here is small PR to add this to dev/deploy command

Compression: archive.Gzip,
Compression: archive.Gzip,
ExcludePatterns: excludes,
})
if err != nil {
return err
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ require (
github.com/briandowns/spinner v0.0.0-20180822135157-9f016caa1359
github.com/cnf/structhash v0.0.0-20180104161610-62a607eb0224
github.com/containerd/continuity v0.0.0-20180712174259-0377f7d76720 // indirect
github.com/docker/cli v0.0.0-20190129171106-b258f458cc8d
github.com/docker/distribution v0.0.0-20180720172123-0dae0957e5fe // indirect
github.com/docker/docker v0.0.0-20180803200506-eeea12db7a65
github.com/docker/go-connections v0.0.0-20180212134524-7beb39f0b969 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/docker/cli v0.0.0-20190129171106-b258f458cc8d h1:n+Le3bCrmzFqx0uw8xOmQr4ZkDfRftw+8DuprUbKfps=
github.com/docker/cli v0.0.0-20190129171106-b258f458cc8d/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
github.com/docker/distribution v0.0.0-20180720172123-0dae0957e5fe h1:ZRQNMB7Sw5jf9g/0imDbI+vTFNk4J7qBdtFI5/zf1kg=
github.com/docker/distribution v0.0.0-20180720172123-0dae0957e5fe/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
github.com/docker/docker v0.0.0-20180803200506-eeea12db7a65 h1:WeqSIzsb30/sarqEph9RS+6xw8rmRpCACwV8+cJ1Rkc=
Expand Down