diff --git a/deploy/executor-release.yaml b/deploy/executor-release.yaml new file mode 100644 index 000000000..e6de9e5cf --- /dev/null +++ b/deploy/executor-release.yaml @@ -0,0 +1,25 @@ +steps: + # First, install make + - name: "gcr.io/google-appengine/debian9" + args: ["sh", "-c", "apt-get update && apt-get install -y make"] + volumes: + - name: "make" + path: "/usr/bin" + - name: "gcr.io/google-appengine/debian9" + args: ["sh", "-c", "cp -r . /kaniko/ && mkdir -p /workspace/go/src/github.com/GoogleCloudPlatform/ && cp -r /kaniko/ /workspace/go/src/github.com/GoogleCloudPlatform/"] + volumes: + - name: "make" + path: "/usr/bin" + # Then, build the binary + - name: "gcr.io/google-appengine/golang" + args: ["sh", "-c", "make"] + volumes: + - name: "make" + path: "/usr/bin" + dir: go/src/github.com/GoogleCloudPlatform/kaniko + env: ["GOPATH=/workspace/go/"] + # Then, build kaniko with kaniko + - name: "gcr.io/kaniko-project/executor:latest" + args: ["--dockerfile=/workspace/deploy/Dockerfile", + "--context=/workspace/go/src/github.com/GoogleCloudPlatform/kaniko/", + "--destination=gcr.io/kaniko-project/executor:${COMMIT_SHA}"] diff --git a/pkg/constants/constants.go b/pkg/constants/constants.go index a98dee17a..93bb37e0d 100644 --- a/pkg/constants/constants.go +++ b/pkg/constants/constants.go @@ -29,6 +29,9 @@ const ( //KanikoDir is the path to the Kaniko directory KanikoDir = "/kaniko" + // KanikoExecutor is the path to the kaniko executor + KanikoExecutor = "/kaniko/executor" + WhitelistPath = "/proc/self/mountinfo" Author = "kaniko" diff --git a/pkg/snapshot/snapshot.go b/pkg/snapshot/snapshot.go index 32517eaf1..965f6b68b 100644 --- a/pkg/snapshot/snapshot.go +++ b/pkg/snapshot/snapshot.go @@ -81,6 +81,7 @@ func (s *Snapshotter) TakeSnapshotOfFiles(files []string) ([]byte, error) { buf := bytes.NewBuffer([]byte{}) w := tar.NewWriter(buf) defer w.Close() + filesAdded := false for _, file := range files { info, err := os.Lstat(file) if err != nil { @@ -96,9 +97,13 @@ func (s *Snapshotter) TakeSnapshotOfFiles(files []string) ([]byte, error) { return nil, err } if maybeAdd { + filesAdded = true util.AddToTar(file, info, w) } } + if !filesAdded { + return nil, nil + } return ioutil.ReadAll(buf) } diff --git a/pkg/util/fs_util.go b/pkg/util/fs_util.go index 3edefacd2..7bdd6a6e1 100644 --- a/pkg/util/fs_util.go +++ b/pkg/util/fs_util.go @@ -57,6 +57,9 @@ func ExtractFileSystemFromImage(img string) error { // PathInWhitelist returns true if the path is whitelisted func PathInWhitelist(path, directory string) bool { + if path == constants.KanikoExecutor { + return false + } for _, d := range whitelist { dirPath := filepath.Join(directory, d) if pkgutil.HasFilepathPrefix(path, dirPath) {