diff --git a/README.md b/README.md index 10fb58ab6..1c996fa4f 100644 --- a/README.md +++ b/README.md @@ -109,6 +109,7 @@ _If you are interested in contributing to kaniko, see - [Flag `--skip-default-registry-fallback`](#flag---skip-default-registry-fallback) - [Flag `--reproducible`](#flag---reproducible) - [Flag `--single-snapshot`](#flag---single-snapshot) + - [Flag `--skip-snapshot`](#flag---skip-snapshot) - [Flag `--skip-push-permission-check`](#flag---skip-push-permission-check) - [Flag `--skip-tls-verify`](#flag---skip-tls-verify) - [Flag `--skip-tls-verify-pull`](#flag---skip-tls-verify-pull) @@ -1078,6 +1079,10 @@ reproducible. This flag takes a single snapshot of the filesystem at the end of the build, so only one layer will be appended to the base image. +#### Flag `--skip-snapshot` + +This flag allows users to skip all snapshots during the build process. Enabling this flag ensures that no snapshots are taken, potentially speeding up the build process. + #### Flag `--skip-push-permission-check` Set this flag to skip push permission check. This can be useful to delay Kanikos diff --git a/cmd/executor/cmd/root.go b/cmd/executor/cmd/root.go index 7f0339c5d..a3281ad9e 100644 --- a/cmd/executor/cmd/root.go +++ b/cmd/executor/cmd/root.go @@ -244,6 +244,7 @@ func addKanikoOptionsFlags() { RootCmd.PersistentFlags().StringVarP(&opts.KanikoDir, "kaniko-dir", "", constants.DefaultKanikoPath, "Path to the kaniko directory, this takes precedence over the KANIKO_DIR environment variable.") RootCmd.PersistentFlags().StringVarP(&opts.TarPath, "tar-path", "", "", "Path to save the image in as a tarball instead of pushing") RootCmd.PersistentFlags().BoolVarP(&opts.SingleSnapshot, "single-snapshot", "", false, "Take a single snapshot at the end of the build.") + RootCmd.PersistentFlags().BoolVarP(&opts.SkipSnapshot, "skip-snapshot", "", false, "Skip all snapshots for the duration of the build.") RootCmd.PersistentFlags().BoolVarP(&opts.Reproducible, "reproducible", "", false, "Strip timestamps out of the image to make it reproducible") RootCmd.PersistentFlags().StringVarP(&opts.Target, "target", "", "", "Set the target build stage to build") RootCmd.PersistentFlags().BoolVarP(&opts.NoPush, "no-push", "", false, "Do not push the image to the registry") diff --git a/pkg/config/options.go b/pkg/config/options.go index dbc1e0297..734c232e4 100644 --- a/pkg/config/options.go +++ b/pkg/config/options.go @@ -77,6 +77,7 @@ type KanikoOptions struct { CompressionLevel int ImageFSExtractRetry int SingleSnapshot bool + SkipSnapshot bool Reproducible bool NoPush bool NoPushCache bool diff --git a/pkg/executor/build.go b/pkg/executor/build.go index 73b2f0df2..69b3de09f 100644 --- a/pkg/executor/build.go +++ b/pkg/executor/build.go @@ -456,7 +456,12 @@ func (s *stageBuilder) takeSnapshot(files []string, shdDelete bool) (string, err func (s *stageBuilder) shouldTakeSnapshot(index int, isMetadatCmd bool) bool { isLastCommand := index == len(s.cmds)-1 - + + // Skip snapshot entirely with skip snapshot mode on. + if s.opts.SkipSnapshot { + return false + } + // We only snapshot the very end with single snapshot mode on. if s.opts.SingleSnapshot { return isLastCommand