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

Support custom dockerignore files #753

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion pkg/cli/builds.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,15 @@ func build(rack sdk.Interface, c *stdcli.Context, development bool) (*structs.Bu

c.Startf("Packaging source")

data, err := common.Tarball(dir)
var ignorefile string

if c.String("ignore") == "" {
ignorefile = ".dockerignore"
} else {
ignorefile = c.String("ignore")
}

data, err := common.Tarball(dir, ignorefile)
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/common/tar.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func RebaseArchive(r io.Reader, src, dst string) (io.Reader, error) {
return &buf, nil
}

func Tarball(dir string) ([]byte, error) {
func Tarball(dir string, ignorefile string) ([]byte, error) {
abs, err := filepath.Abs(dir)
if err != nil {
return nil, err
Expand All @@ -76,7 +76,7 @@ func Tarball(dir string) ([]byte, error) {
return nil, err
}

data, err := ioutil.ReadFile(filepath.Join(sym, ".dockerignore"))
data, err := ioutil.ReadFile(filepath.Join(sym, ignorefile))
if err != nil && !os.IsNotExist(err) {
return nil, err
}
Expand Down
1 change: 1 addition & 0 deletions pkg/structs/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type BuildCreateOptions struct {
Description *string `flag:"description,d" param:"description"`
Development *bool `flag:"development" param:"development"`
External *bool `flag:"external" param:"external"`
Ignore *string `flag:"ignore" param:"ignore"`
Manifest *string `flag:"manifest,m" param:"manifest"`
NoCache *bool `flag:"no-cache" param:"no-cache"`
WildcardDomain *bool `flag:"wildcard-domain" param:"wildcard-domain"`
Expand Down