Skip to content

Commit

Permalink
Support custom dockerignore files
Browse files Browse the repository at this point in the history
  • Loading branch information
beastawakens committed Mar 6, 2024
1 parent 9879e7a commit f7c5904
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
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

0 comments on commit f7c5904

Please sign in to comment.