diff --git a/cmd/kaniko-acr/main.go b/cmd/kaniko-acr/main.go index ef2954a..a4a9802 100644 --- a/cmd/kaniko-acr/main.go +++ b/cmd/kaniko-acr/main.go @@ -207,6 +207,157 @@ func main() { Usage: "build only used stages", EnvVar: "PLUGIN_SKIP_UNUSED_STAGES", }, + cli.StringFlag{ + Name: "cache-dir", + Usage: "Set this flag to specify a local directory cache for base images", + EnvVar: "PLUGIN_CACHE_DIR", + }, + + cli.BoolFlag{ + Name: "cache-copy-layers", + Usage: "Enable or disable copying layers from the cache.", + EnvVar: "PLUGIN_CACHE_COPY_LAYERS", + }, + cli.BoolFlag{ + Name: "cache-run-layers", + Usage: "Enable or disable running layers from the cache.", + EnvVar: "PLUGIN_CACHE_RUN_LAYERS", + }, + cli.BoolFlag{ + Name: "cleanup", + Usage: "Enable or disable cleanup of temporary files.", + EnvVar: "PLUGIN_CLEANUP", + }, + cli.BoolFlag{ + Name: "compressed-caching", + Usage: "Enable or disable compressed caching.", + EnvVar: "PLUGIN_COMPRESSED_CACHING", + }, + cli.StringFlag{ + Name: "context-sub-path", + Usage: "Sub-path within the context to build.", + EnvVar: "PLUGIN_CONTEXT_SUB_PATH", + }, + cli.StringFlag{ + Name: "custom-platform", + Usage: "Platform to use for building.", + EnvVar: "PLUGIN_CUSTOM_PLATFORM", + }, + cli.BoolFlag{ + Name: "force", + Usage: "Force building the image even if it already exists.", + EnvVar: "PLUGIN_FORCE", + }, + cli.StringSliceFlag{ + Name: "image-name-with-digest-file", + Usage: "Write image name with digest to a file.", + EnvVar: "PLUGIN_IMAGE_NAME_WITH_DIGEST_FILE", + }, + cli.StringFlag{ + Name: "image-name-tag-with-digest-file", + Usage: "Write image name with tag and digest to a file.", + EnvVar: "PLUGIN_IMAGE_NAME_TAG_WITH_DIGEST_FILE", + }, + cli.BoolFlag{ + Name: "insecure", + Usage: "Allow connecting to registries without TLS.", + EnvVar: "PLUGIN_INSECURE", + }, + cli.BoolFlag{ + Name: "insecure-pull", + Usage: "Allow insecure pulls from the registry.", + EnvVar: "PLUGIN_INSECURE_PULL", + }, + cli.StringFlag{ + Name: "insecure-registry", + Usage: "Use plain HTTP for registry communication.", + EnvVar: "PLUGIN_INSECURE_REGISTRY", + }, + cli.StringFlag{ + Name: "log-format", + Usage: "Set the log format for build output.", + EnvVar: "PLUGIN_LOG_FORMAT", + }, + cli.BoolFlag{ + Name: "log-timestamp", + Usage: "Show timestamps in build output.", + EnvVar: "PLUGIN_LOG_TIMESTAMP", + }, + cli.StringFlag{ + Name: "oci-layout-path", + Usage: "Directory to store OCI layout.", + EnvVar: "PLUGIN_OCI_LAYOUT_PATH", + }, + cli.IntFlag{ + Name: "push-retry", + Usage: "Number of times to retry pushing an image.", + EnvVar: "PLUGIN_PUSH_RETRY", + }, + cli.StringFlag{ + Name: "registry-certificate", + Usage: "Path to a file containing a registry certificate.", + EnvVar: "PLUGIN_REGISTRY_CERTIFICATE", + }, + cli.StringFlag{ + Name: "registry-client-cert", + Usage: "Path to a file containing a registry client certificate.", + EnvVar: "PLUGIN_REGISTRY_CLIENT_CERT", + }, + cli.BoolFlag{ + Name: "skip-default-registry-fallback", + Usage: "Skip Docker Hub and default registry fallback.", + EnvVar: "PLUGIN_SKIP_DEFAULT_REGISTRY_FALLBACK", + }, + cli.BoolFlag{ + Name: "reproducible", + Usage: "Create a reproducible image.", + EnvVar: "PLUGIN_REPRODUCIBLE", + }, + cli.BoolFlag{ + Name: "single-snapshot", + Usage: "Only create a single snapshot of the image.", + EnvVar: "PLUGIN_SINGLE_SNAPSHOT", + }, + cli.BoolFlag{ + Name: "skip-push-permission-check", + Usage: "Skip permission check when pushing.", + EnvVar: "PLUGIN_SKIP_PUSH_PERMISSION_CHECK", + }, + cli.BoolFlag{ + Name: "skip-tls-verify-pull", + Usage: "Skip TLS verification when pulling.", + EnvVar: "PLUGIN_SKIP_TLS_VERIFY_PULL", + }, + cli.BoolFlag{ + Name: "skip-tls-verify-registry", + Usage: "Skip TLS verification when connecting to a registry.", + EnvVar: "PLUGIN_SKIP_TLS_VERIFY_REGISTRY", + }, + cli.BoolFlag{ + Name: "use-new-run", + Usage: "Skip TLS verification when connecting to a registry.", + EnvVar: "PLUGIN_USE_NEW_RUN", + }, + cli.BoolFlag{ + Name: "ignore-var-run", + Usage: "Ignore the /var/run directory during build.", + EnvVar: "PLUGIN_IGNORE_VAR_RUN", + }, + cli.StringFlag{ + Name: "ignore-path", + Usage: "Path to ignore during the build.", + EnvVar: "PLUGIN_IGNORE_PATH", + }, + cli.IntFlag{ + Name: "image-fs-extract-retry", + Usage: "Number of retries for extracting filesystem layers.", + EnvVar: "PLUGIN_IMAGE_FS_EXTRACT_RETRY", + }, + cli.IntFlag{ + Name: "image-download-retry", + Usage: "Number of retries for downloading base images.", + EnvVar: "PLUGIN_IMAGE_DOWNLOAD_RETRY", + }, } if err := app.Run(os.Args); err != nil { @@ -233,28 +384,60 @@ func run(c *cli.Context) error { plugin := kaniko.Plugin{ Build: kaniko.Build{ - DroneCommitRef: c.String("drone-commit-ref"), - DroneRepoBranch: c.String("drone-repo-branch"), - Dockerfile: c.String("dockerfile"), - Context: c.String("context"), - Tags: c.StringSlice("tags"), - AutoTag: c.Bool("auto-tag"), - AutoTagSuffix: c.String("auto-tag-suffix"), - ExpandTag: c.Bool("expand-tag"), - Args: c.StringSlice("args"), - Target: c.String("target"), - Repo: c.String("repo"), - Mirrors: c.StringSlice("registry-mirrors"), - Labels: c.StringSlice("custom-labels"), - SnapshotMode: c.String("snapshot-mode"), - EnableCache: c.Bool("enable-cache"), - CacheRepo: fmt.Sprintf("%s/%s", c.String("registry"), c.String("cache-repo")), - CacheTTL: c.Int("cache-ttl"), - DigestFile: defaultDigestFile, - NoPush: noPush, - Verbosity: c.String("verbosity"), - Platform: c.String("platform"), - SkipUnusedStages: c.Bool("skip-unused-stages"), + DroneCommitRef: c.String("drone-commit-ref"), + DroneRepoBranch: c.String("drone-repo-branch"), + Dockerfile: c.String("dockerfile"), + Context: c.String("context"), + Tags: c.StringSlice("tags"), + AutoTag: c.Bool("auto-tag"), + AutoTagSuffix: c.String("auto-tag-suffix"), + ExpandTag: c.Bool("expand-tag"), + Args: c.StringSlice("args"), + Target: c.String("target"), + Repo: c.String("repo"), + Mirrors: c.StringSlice("registry-mirrors"), + Labels: c.StringSlice("custom-labels"), + SnapshotMode: c.String("snapshot-mode"), + EnableCache: c.Bool("enable-cache"), + CacheRepo: fmt.Sprintf("%s/%s", c.String("registry"), c.String("cache-repo")), + CacheTTL: c.Int("cache-ttl"), + DigestFile: defaultDigestFile, + NoPush: noPush, + Verbosity: c.String("verbosity"), + Platform: c.String("platform"), + SkipUnusedStages: c.Bool("skip-unused-stages"), + CacheDir: c.String("cache-dir"), + CacheCopyLayers: c.Bool("cache-copy-layers"), + CacheRunLayers: c.Bool("cache-run-layers"), + Cleanup: c.Bool("cleanup"), + CompressedCaching: c.Bool("compressed-caching"), + ContextSubPath: c.String("context-sub-path"), + CustomPlatform: c.String("custom-platform"), + Force: c.Bool("force"), + ImageNameWithDigestFile: c.String("image-name-with-digest-file"), + ImageNameTagWithDigestFile: c.String("image-name-tag-with-digest-file"), + Insecure: c.Bool("insecure"), + InsecurePull: c.Bool("insecure-pull"), + InsecureRegistry: c.String("insecure-registry"), + Label: c.String("label"), + LogFormat: c.String("log-format"), + LogTimestamp: c.Bool("log-timestamp"), + OCILayoutPath: c.String("oci-layout-path"), + PushRetry: c.Int("push-retry"), + RegistryCertificate: c.String("registry-certificate"), + RegistryClientCert: c.String("registry-client-cert"), + SkipDefaultRegistryFallback: c.Bool("skip-default-registry-fallback"), + Reproducible: c.Bool("reproducible"), + SingleSnapshot: c.Bool("single-snapshot"), + SkipTLSVerify: c.Bool("skip-tls-verify"), + SkipPushPermissionCheck: c.Bool("skip-push-permission-check"), + SkipTLSVerifyPull: c.Bool("skip-tls-verify-pull"), + SkipTLSVerifyRegistry: c.Bool("skip-tls-verify-registry"), + UseNewRun: c.Bool("use-new-run"), + IgnoreVarRun: c.Bool("ignore-var-run"), + IgnorePath: c.String("ignore-path"), + ImageFSExtractRetry: c.Int("image-fs-extract-retry"), + ImageDownloadRetry: c.Int("image-download-retry"), }, Artifact: kaniko.Artifact{ Tags: c.StringSlice("tags"), diff --git a/cmd/kaniko-docker/main.go b/cmd/kaniko-docker/main.go index 5036d7c..16e62e2 100644 --- a/cmd/kaniko-docker/main.go +++ b/cmd/kaniko-docker/main.go @@ -242,12 +242,12 @@ func main() { Usage: "Force building the image even if it already exists.", EnvVar: "PLUGIN_FORCE", }, - cli.BoolFlag{ + cli.StringFlag{ Name: "image-name-with-digest-file", Usage: "Write image name with digest to a file.", EnvVar: "PLUGIN_IMAGE_NAME_WITH_DIGEST_FILE", }, - cli.BoolFlag{ + cli.StringFlag{ Name: "image-name-tag-with-digest-file", Usage: "Write image name with tag and digest to a file.", EnvVar: "PLUGIN_IMAGE_NAME_TAG_WITH_DIGEST_FILE", @@ -262,7 +262,7 @@ func main() { Usage: "Allow insecure pulls from the registry.", EnvVar: "PLUGIN_INSECURE_PULL", }, - cli.BoolFlag{ + cli.StringFlag{ Name: "insecure-registry", Usage: "Use plain HTTP for registry communication.", EnvVar: "PLUGIN_INSECURE_REGISTRY", @@ -378,30 +378,62 @@ func run(c *cli.Context) error { plugin := kaniko.Plugin{ Build: kaniko.Build{ - DroneCommitRef: c.String("drone-commit-ref"), - DroneRepoBranch: c.String("drone-repo-branch"), - Dockerfile: c.String("dockerfile"), - Context: c.String("context"), - Tags: c.StringSlice("tags"), - AutoTag: c.Bool("auto-tag"), - AutoTagSuffix: c.String("auto-tag-suffix"), - ExpandTag: c.Bool("expand-tag"), - Args: c.StringSlice("args"), - Target: c.String("target"), - Repo: buildRepo(c.String("registry"), c.String("repo"), c.Bool("expand-repo")), - Mirrors: c.StringSlice("registry-mirrors"), - Labels: c.StringSlice("custom-labels"), - SkipTlsVerify: c.Bool("skip-tls-verify"), - SnapshotMode: c.String("snapshot-mode"), - EnableCache: c.Bool("enable-cache"), - CacheRepo: buildRepo(c.String("registry"), c.String("cache-repo"), c.Bool("expand-repo")), - CacheTTL: c.Int("cache-ttl"), - DigestFile: defaultDigestFile, - NoPush: noPush, - TarPath: c.String("tar-path"), - Verbosity: c.String("verbosity"), - Platform: c.String("platform"), - SkipUnusedStages: c.Bool("skip-unused-stages"), + DroneCommitRef: c.String("drone-commit-ref"), + DroneRepoBranch: c.String("drone-repo-branch"), + Dockerfile: c.String("dockerfile"), + Context: c.String("context"), + Tags: c.StringSlice("tags"), + AutoTag: c.Bool("auto-tag"), + AutoTagSuffix: c.String("auto-tag-suffix"), + ExpandTag: c.Bool("expand-tag"), + Args: c.StringSlice("args"), + Target: c.String("target"), + Repo: buildRepo(c.String("registry"), c.String("repo"), c.Bool("expand-repo")), + Mirrors: c.StringSlice("registry-mirrors"), + Labels: c.StringSlice("custom-labels"), + SkipTlsVerify: c.Bool("skip-tls-verify"), + SnapshotMode: c.String("snapshot-mode"), + EnableCache: c.Bool("enable-cache"), + CacheRepo: buildRepo(c.String("registry"), c.String("cache-repo"), c.Bool("expand-repo")), + CacheTTL: c.Int("cache-ttl"), + DigestFile: defaultDigestFile, + NoPush: noPush, + TarPath: c.String("tar-path"), + Verbosity: c.String("verbosity"), + Platform: c.String("platform"), + SkipUnusedStages: c.Bool("skip-unused-stages"), + CacheDir: c.String("cache-dir"), + CacheCopyLayers: c.Bool("cache-copy-layers"), + CacheRunLayers: c.Bool("cache-run-layers"), + Cleanup: c.Bool("cleanup"), + CompressedCaching: c.Bool("compressed-caching"), + ContextSubPath: c.String("context-sub-path"), + CustomPlatform: c.String("custom-platform"), + Force: c.Bool("force"), + ImageNameWithDigestFile: c.String("image-name-with-digest-file"), + ImageNameTagWithDigestFile: c.String("image-name-tag-with-digest-file"), + Insecure: c.Bool("insecure"), + InsecurePull: c.Bool("insecure-pull"), + InsecureRegistry: c.String("insecure-registry"), + Label: c.String("label"), + LogFormat: c.String("log-format"), + LogTimestamp: c.Bool("log-timestamp"), + OCILayoutPath: c.String("oci-layout-path"), + PushRetry: c.Int("push-retry"), + RegistryCertificate: c.String("registry-certificate"), + RegistryClientCert: c.String("registry-client-cert"), + SkipDefaultRegistryFallback: c.Bool("skip-default-registry-fallback"), + Reproducible: c.Bool("reproducible"), + SingleSnapshot: c.Bool("single-snapshot"), + SkipTLSVerify: c.Bool("skip-tls-verify"), + SkipPushPermissionCheck: c.Bool("skip-push-permission-check"), + SkipTLSVerifyPull: c.Bool("skip-tls-verify-pull"), + SkipTLSVerifyRegistry: c.Bool("skip-tls-verify-registry"), + UseNewRun: c.Bool("use-new-run"), + IgnoreVarRun: c.Bool("ignore-var-run"), + IgnorePath: c.String("ignore-path"), + ImageFSExtractRetry: c.Int("image-fs-extract-retry"), + ImageDownloadRetry: c.Int("image-download-retry"), }, Artifact: kaniko.Artifact{ Tags: c.StringSlice("tags"), diff --git a/cmd/kaniko-ecr/main.go b/cmd/kaniko-ecr/main.go index 1652369..1015dfb 100644 --- a/cmd/kaniko-ecr/main.go +++ b/cmd/kaniko-ecr/main.go @@ -234,6 +234,157 @@ func main() { Usage: "build only used stages", EnvVar: "PLUGIN_SKIP_UNUSED_STAGES", }, + cli.StringFlag{ + Name: "cache-dir", + Usage: "Set this flag to specify a local directory cache for base images", + EnvVar: "PLUGIN_CACHE_DIR", + }, + + cli.BoolFlag{ + Name: "cache-copy-layers", + Usage: "Enable or disable copying layers from the cache.", + EnvVar: "PLUGIN_CACHE_COPY_LAYERS", + }, + cli.BoolFlag{ + Name: "cache-run-layers", + Usage: "Enable or disable running layers from the cache.", + EnvVar: "PLUGIN_CACHE_RUN_LAYERS", + }, + cli.BoolFlag{ + Name: "cleanup", + Usage: "Enable or disable cleanup of temporary files.", + EnvVar: "PLUGIN_CLEANUP", + }, + cli.BoolFlag{ + Name: "compressed-caching", + Usage: "Enable or disable compressed caching.", + EnvVar: "PLUGIN_COMPRESSED_CACHING", + }, + cli.StringFlag{ + Name: "context-sub-path", + Usage: "Sub-path within the context to build.", + EnvVar: "PLUGIN_CONTEXT_SUB_PATH", + }, + cli.StringFlag{ + Name: "custom-platform", + Usage: "Platform to use for building.", + EnvVar: "PLUGIN_CUSTOM_PLATFORM", + }, + cli.BoolFlag{ + Name: "force", + Usage: "Force building the image even if it already exists.", + EnvVar: "PLUGIN_FORCE", + }, + cli.StringFlag{ + Name: "image-name-with-digest-file", + Usage: "Write image name with digest to a file.", + EnvVar: "PLUGIN_IMAGE_NAME_WITH_DIGEST_FILE", + }, + cli.StringFlag{ + Name: "image-name-tag-with-digest-file", + Usage: "Write image name with tag and digest to a file.", + EnvVar: "PLUGIN_IMAGE_NAME_TAG_WITH_DIGEST_FILE", + }, + cli.BoolFlag{ + Name: "insecure", + Usage: "Allow connecting to registries without TLS.", + EnvVar: "PLUGIN_INSECURE", + }, + cli.BoolFlag{ + Name: "insecure-pull", + Usage: "Allow insecure pulls from the registry.", + EnvVar: "PLUGIN_INSECURE_PULL", + }, + cli.StringFlag{ + Name: "insecure-registry", + Usage: "Use plain HTTP for registry communication.", + EnvVar: "PLUGIN_INSECURE_REGISTRY", + }, + cli.StringFlag{ + Name: "log-format", + Usage: "Set the log format for build output.", + EnvVar: "PLUGIN_LOG_FORMAT", + }, + cli.BoolFlag{ + Name: "log-timestamp", + Usage: "Show timestamps in build output.", + EnvVar: "PLUGIN_LOG_TIMESTAMP", + }, + cli.StringFlag{ + Name: "oci-layout-path", + Usage: "Directory to store OCI layout.", + EnvVar: "PLUGIN_OCI_LAYOUT_PATH", + }, + cli.IntFlag{ + Name: "push-retry", + Usage: "Number of times to retry pushing an image.", + EnvVar: "PLUGIN_PUSH_RETRY", + }, + cli.StringFlag{ + Name: "registry-certificate", + Usage: "Path to a file containing a registry certificate.", + EnvVar: "PLUGIN_REGISTRY_CERTIFICATE", + }, + cli.StringFlag{ + Name: "registry-client-cert", + Usage: "Path to a file containing a registry client certificate.", + EnvVar: "PLUGIN_REGISTRY_CLIENT_CERT", + }, + cli.BoolFlag{ + Name: "skip-default-registry-fallback", + Usage: "Skip Docker Hub and default registry fallback.", + EnvVar: "PLUGIN_SKIP_DEFAULT_REGISTRY_FALLBACK", + }, + cli.BoolFlag{ + Name: "reproducible", + Usage: "Create a reproducible image.", + EnvVar: "PLUGIN_REPRODUCIBLE", + }, + cli.BoolFlag{ + Name: "single-snapshot", + Usage: "Only create a single snapshot of the image.", + EnvVar: "PLUGIN_SINGLE_SNAPSHOT", + }, + cli.BoolFlag{ + Name: "skip-push-permission-check", + Usage: "Skip permission check when pushing.", + EnvVar: "PLUGIN_SKIP_PUSH_PERMISSION_CHECK", + }, + cli.BoolFlag{ + Name: "skip-tls-verify-pull", + Usage: "Skip TLS verification when pulling.", + EnvVar: "PLUGIN_SKIP_TLS_VERIFY_PULL", + }, + cli.BoolFlag{ + Name: "skip-tls-verify-registry", + Usage: "Skip TLS verification when connecting to a registry.", + EnvVar: "PLUGIN_SKIP_TLS_VERIFY_REGISTRY", + }, + cli.BoolFlag{ + Name: "use-new-run", + Usage: "Skip TLS verification when connecting to a registry.", + EnvVar: "PLUGIN_USE_NEW_RUN", + }, + cli.BoolFlag{ + Name: "ignore-var-run", + Usage: "Ignore the /var/run directory during build.", + EnvVar: "PLUGIN_IGNORE_VAR_RUN", + }, + cli.StringFlag{ + Name: "ignore-path", + Usage: "Path to ignore during the build.", + EnvVar: "PLUGIN_IGNORE_PATH", + }, + cli.IntFlag{ + Name: "image-fs-extract-retry", + Usage: "Number of retries for extracting filesystem layers.", + EnvVar: "PLUGIN_IMAGE_FS_EXTRACT_RETRY", + }, + cli.IntFlag{ + Name: "image-download-retry", + Usage: "Number of retries for downloading base images.", + EnvVar: "PLUGIN_IMAGE_DOWNLOAD_RETRY", + }, } if err := app.Run(os.Args); err != nil { @@ -303,28 +454,60 @@ func run(c *cli.Context) error { plugin := kaniko.Plugin{ Build: kaniko.Build{ - DroneCommitRef: c.String("drone-commit-ref"), - DroneRepoBranch: c.String("drone-repo-branch"), - Dockerfile: c.String("dockerfile"), - Context: c.String("context"), - Tags: c.StringSlice("tags"), - AutoTag: c.Bool("auto-tag"), - AutoTagSuffix: c.String("auto-tag-suffix"), - ExpandTag: c.Bool("expand-tag"), - Args: c.StringSlice("args"), - Target: c.String("target"), - Repo: fmt.Sprintf("%s/%s", c.String("registry"), c.String("repo")), - Mirrors: c.StringSlice("registry-mirrors"), - Labels: c.StringSlice("custom-labels"), - SnapshotMode: c.String("snapshot-mode"), - EnableCache: c.Bool("enable-cache"), - CacheRepo: fmt.Sprintf("%s/%s", c.String("registry"), c.String("cache-repo")), - CacheTTL: c.Int("cache-ttl"), - DigestFile: defaultDigestFile, - NoPush: noPush, - Verbosity: c.String("verbosity"), - Platform: c.String("platform"), - SkipUnusedStages: c.Bool("skip-unused-stages"), + DroneCommitRef: c.String("drone-commit-ref"), + DroneRepoBranch: c.String("drone-repo-branch"), + Dockerfile: c.String("dockerfile"), + Context: c.String("context"), + Tags: c.StringSlice("tags"), + AutoTag: c.Bool("auto-tag"), + AutoTagSuffix: c.String("auto-tag-suffix"), + ExpandTag: c.Bool("expand-tag"), + Args: c.StringSlice("args"), + Target: c.String("target"), + Repo: fmt.Sprintf("%s/%s", c.String("registry"), c.String("repo")), + Mirrors: c.StringSlice("registry-mirrors"), + Labels: c.StringSlice("custom-labels"), + SnapshotMode: c.String("snapshot-mode"), + EnableCache: c.Bool("enable-cache"), + CacheRepo: fmt.Sprintf("%s/%s", c.String("registry"), c.String("cache-repo")), + CacheTTL: c.Int("cache-ttl"), + DigestFile: defaultDigestFile, + NoPush: noPush, + Verbosity: c.String("verbosity"), + Platform: c.String("platform"), + SkipUnusedStages: c.Bool("skip-unused-stages"), + CacheDir: c.String("cache-dir"), + CacheCopyLayers: c.Bool("cache-copy-layers"), + CacheRunLayers: c.Bool("cache-run-layers"), + Cleanup: c.Bool("cleanup"), + CompressedCaching: c.Bool("compressed-caching"), + ContextSubPath: c.String("context-sub-path"), + CustomPlatform: c.String("custom-platform"), + Force: c.Bool("force"), + ImageNameWithDigestFile: c.String("image-name-with-digest-file"), + ImageNameTagWithDigestFile: c.String("image-name-tag-with-digest-file"), + Insecure: c.Bool("insecure"), + InsecurePull: c.Bool("insecure-pull"), + InsecureRegistry: c.String("insecure-registry"), + Label: c.String("label"), + LogFormat: c.String("log-format"), + LogTimestamp: c.Bool("log-timestamp"), + OCILayoutPath: c.String("oci-layout-path"), + PushRetry: c.Int("push-retry"), + RegistryCertificate: c.String("registry-certificate"), + RegistryClientCert: c.String("registry-client-cert"), + SkipDefaultRegistryFallback: c.Bool("skip-default-registry-fallback"), + Reproducible: c.Bool("reproducible"), + SingleSnapshot: c.Bool("single-snapshot"), + SkipTLSVerify: c.Bool("skip-tls-verify"), + SkipPushPermissionCheck: c.Bool("skip-push-permission-check"), + SkipTLSVerifyPull: c.Bool("skip-tls-verify-pull"), + SkipTLSVerifyRegistry: c.Bool("skip-tls-verify-registry"), + UseNewRun: c.Bool("use-new-run"), + IgnoreVarRun: c.Bool("ignore-var-run"), + IgnorePath: c.String("ignore-path"), + ImageFSExtractRetry: c.Int("image-fs-extract-retry"), + ImageDownloadRetry: c.Int("image-download-retry"), }, Artifact: kaniko.Artifact{ Tags: c.StringSlice("tags"), diff --git a/cmd/kaniko-gar/main.go b/cmd/kaniko-gar/main.go index 93edd84..cf38645 100644 --- a/cmd/kaniko-gar/main.go +++ b/cmd/kaniko-gar/main.go @@ -164,6 +164,157 @@ func main() { Usage: "build only used stages", EnvVar: "PLUGIN_SKIP_UNUSED_STAGES", }, + cli.StringFlag{ + Name: "cache-dir", + Usage: "Set this flag to specify a local directory cache for base images", + EnvVar: "PLUGIN_CACHE_DIR", + }, + + cli.BoolFlag{ + Name: "cache-copy-layers", + Usage: "Enable or disable copying layers from the cache.", + EnvVar: "PLUGIN_CACHE_COPY_LAYERS", + }, + cli.BoolFlag{ + Name: "cache-run-layers", + Usage: "Enable or disable running layers from the cache.", + EnvVar: "PLUGIN_CACHE_RUN_LAYERS", + }, + cli.BoolFlag{ + Name: "cleanup", + Usage: "Enable or disable cleanup of temporary files.", + EnvVar: "PLUGIN_CLEANUP", + }, + cli.BoolFlag{ + Name: "compressed-caching", + Usage: "Enable or disable compressed caching.", + EnvVar: "PLUGIN_COMPRESSED_CACHING", + }, + cli.StringFlag{ + Name: "context-sub-path", + Usage: "Sub-path within the context to build.", + EnvVar: "PLUGIN_CONTEXT_SUB_PATH", + }, + cli.StringFlag{ + Name: "custom-platform", + Usage: "Platform to use for building.", + EnvVar: "PLUGIN_CUSTOM_PLATFORM", + }, + cli.BoolFlag{ + Name: "force", + Usage: "Force building the image even if it already exists.", + EnvVar: "PLUGIN_FORCE", + }, + cli.StringFlag{ + Name: "image-name-with-digest-file", + Usage: "Write image name with digest to a file.", + EnvVar: "PLUGIN_IMAGE_NAME_WITH_DIGEST_FILE", + }, + cli.StringFlag{ + Name: "image-name-tag-with-digest-file", + Usage: "Write image name with tag and digest to a file.", + EnvVar: "PLUGIN_IMAGE_NAME_TAG_WITH_DIGEST_FILE", + }, + cli.BoolFlag{ + Name: "insecure", + Usage: "Allow connecting to registries without TLS.", + EnvVar: "PLUGIN_INSECURE", + }, + cli.BoolFlag{ + Name: "insecure-pull", + Usage: "Allow insecure pulls from the registry.", + EnvVar: "PLUGIN_INSECURE_PULL", + }, + cli.StringFlag{ + Name: "insecure-registry", + Usage: "Use plain HTTP for registry communication.", + EnvVar: "PLUGIN_INSECURE_REGISTRY", + }, + cli.StringFlag{ + Name: "log-format", + Usage: "Set the log format for build output.", + EnvVar: "PLUGIN_LOG_FORMAT", + }, + cli.BoolFlag{ + Name: "log-timestamp", + Usage: "Show timestamps in build output.", + EnvVar: "PLUGIN_LOG_TIMESTAMP", + }, + cli.StringFlag{ + Name: "oci-layout-path", + Usage: "Directory to store OCI layout.", + EnvVar: "PLUGIN_OCI_LAYOUT_PATH", + }, + cli.IntFlag{ + Name: "push-retry", + Usage: "Number of times to retry pushing an image.", + EnvVar: "PLUGIN_PUSH_RETRY", + }, + cli.StringFlag{ + Name: "registry-certificate", + Usage: "Path to a file containing a registry certificate.", + EnvVar: "PLUGIN_REGISTRY_CERTIFICATE", + }, + cli.StringFlag{ + Name: "registry-client-cert", + Usage: "Path to a file containing a registry client certificate.", + EnvVar: "PLUGIN_REGISTRY_CLIENT_CERT", + }, + cli.BoolFlag{ + Name: "skip-default-registry-fallback", + Usage: "Skip Docker Hub and default registry fallback.", + EnvVar: "PLUGIN_SKIP_DEFAULT_REGISTRY_FALLBACK", + }, + cli.BoolFlag{ + Name: "reproducible", + Usage: "Create a reproducible image.", + EnvVar: "PLUGIN_REPRODUCIBLE", + }, + cli.BoolFlag{ + Name: "single-snapshot", + Usage: "Only create a single snapshot of the image.", + EnvVar: "PLUGIN_SINGLE_SNAPSHOT", + }, + cli.BoolFlag{ + Name: "skip-push-permission-check", + Usage: "Skip permission check when pushing.", + EnvVar: "PLUGIN_SKIP_PUSH_PERMISSION_CHECK", + }, + cli.BoolFlag{ + Name: "skip-tls-verify-pull", + Usage: "Skip TLS verification when pulling.", + EnvVar: "PLUGIN_SKIP_TLS_VERIFY_PULL", + }, + cli.BoolFlag{ + Name: "skip-tls-verify-registry", + Usage: "Skip TLS verification when connecting to a registry.", + EnvVar: "PLUGIN_SKIP_TLS_VERIFY_REGISTRY", + }, + cli.BoolFlag{ + Name: "use-new-run", + Usage: "Skip TLS verification when connecting to a registry.", + EnvVar: "PLUGIN_USE_NEW_RUN", + }, + cli.BoolFlag{ + Name: "ignore-var-run", + Usage: "Ignore the /var/run directory during build.", + EnvVar: "PLUGIN_IGNORE_VAR_RUN", + }, + cli.StringFlag{ + Name: "ignore-path", + Usage: "Path to ignore during the build.", + EnvVar: "PLUGIN_IGNORE_PATH", + }, + cli.IntFlag{ + Name: "image-fs-extract-retry", + Usage: "Number of retries for extracting filesystem layers.", + EnvVar: "PLUGIN_IMAGE_FS_EXTRACT_RETRY", + }, + cli.IntFlag{ + Name: "image-download-retry", + Usage: "Number of retries for downloading base images.", + EnvVar: "PLUGIN_IMAGE_DOWNLOAD_RETRY", + }, } if err := app.Run(os.Args); err != nil { @@ -186,28 +337,60 @@ func run(c *cli.Context) error { plugin := kaniko.Plugin{ Build: kaniko.Build{ - DroneCommitRef: c.String("drone-commit-ref"), - DroneRepoBranch: c.String("drone-repo-branch"), - Dockerfile: c.String("dockerfile"), - Context: c.String("context"), - Tags: c.StringSlice("tags"), - AutoTag: c.Bool("auto-tag"), - AutoTagSuffix: c.String("auto-tag-suffix"), - ExpandTag: c.Bool("expand-tag"), - Args: c.StringSlice("args"), - Target: c.String("target"), - Repo: fmt.Sprintf("%s/%s", c.String("registry"), c.String("repo")), - Mirrors: c.StringSlice("registry-mirrors"), - Labels: c.StringSlice("custom-labels"), - SnapshotMode: c.String("snapshot-mode"), - EnableCache: c.Bool("enable-cache"), - CacheRepo: fmt.Sprintf("%s/%s", c.String("registry"), c.String("cache-repo")), - CacheTTL: c.Int("cache-ttl"), - DigestFile: defaultDigestFile, - NoPush: noPush, - Verbosity: c.String("verbosity"), - Platform: c.String("platform"), - SkipUnusedStages: c.Bool("skip-unused-stages"), + DroneCommitRef: c.String("drone-commit-ref"), + DroneRepoBranch: c.String("drone-repo-branch"), + Dockerfile: c.String("dockerfile"), + Context: c.String("context"), + Tags: c.StringSlice("tags"), + AutoTag: c.Bool("auto-tag"), + AutoTagSuffix: c.String("auto-tag-suffix"), + ExpandTag: c.Bool("expand-tag"), + Args: c.StringSlice("args"), + Target: c.String("target"), + Repo: fmt.Sprintf("%s/%s", c.String("registry"), c.String("repo")), + Mirrors: c.StringSlice("registry-mirrors"), + Labels: c.StringSlice("custom-labels"), + SnapshotMode: c.String("snapshot-mode"), + EnableCache: c.Bool("enable-cache"), + CacheRepo: fmt.Sprintf("%s/%s", c.String("registry"), c.String("cache-repo")), + CacheTTL: c.Int("cache-ttl"), + DigestFile: defaultDigestFile, + NoPush: noPush, + Verbosity: c.String("verbosity"), + Platform: c.String("platform"), + SkipUnusedStages: c.Bool("skip-unused-stages"), + CacheDir: c.String("cache-dir"), + CacheCopyLayers: c.Bool("cache-copy-layers"), + CacheRunLayers: c.Bool("cache-run-layers"), + Cleanup: c.Bool("cleanup"), + CompressedCaching: c.Bool("compressed-caching"), + ContextSubPath: c.String("context-sub-path"), + CustomPlatform: c.String("custom-platform"), + Force: c.Bool("force"), + ImageNameWithDigestFile: c.String("image-name-with-digest-file"), + ImageNameTagWithDigestFile: c.String("image-name-tag-with-digest-file"), + Insecure: c.Bool("insecure"), + InsecurePull: c.Bool("insecure-pull"), + InsecureRegistry: c.String("insecure-registry"), + Label: c.String("label"), + LogFormat: c.String("log-format"), + LogTimestamp: c.Bool("log-timestamp"), + OCILayoutPath: c.String("oci-layout-path"), + PushRetry: c.Int("push-retry"), + RegistryCertificate: c.String("registry-certificate"), + RegistryClientCert: c.String("registry-client-cert"), + SkipDefaultRegistryFallback: c.Bool("skip-default-registry-fallback"), + Reproducible: c.Bool("reproducible"), + SingleSnapshot: c.Bool("single-snapshot"), + SkipTLSVerify: c.Bool("skip-tls-verify"), + SkipPushPermissionCheck: c.Bool("skip-push-permission-check"), + SkipTLSVerifyPull: c.Bool("skip-tls-verify-pull"), + SkipTLSVerifyRegistry: c.Bool("skip-tls-verify-registry"), + UseNewRun: c.Bool("use-new-run"), + IgnoreVarRun: c.Bool("ignore-var-run"), + IgnorePath: c.String("ignore-path"), + ImageFSExtractRetry: c.Int("image-fs-extract-retry"), + ImageDownloadRetry: c.Int("image-download-retry"), }, Artifact: kaniko.Artifact{ Tags: c.StringSlice("tags"), diff --git a/cmd/kaniko-gcr/main.go b/cmd/kaniko-gcr/main.go index 74bb2e5..add4eef 100644 --- a/cmd/kaniko-gcr/main.go +++ b/cmd/kaniko-gcr/main.go @@ -165,6 +165,157 @@ func main() { Usage: "build only used stages", EnvVar: "PLUGIN_SKIP_UNUSED_STAGES", }, + cli.StringFlag{ + Name: "cache-dir", + Usage: "Set this flag to specify a local directory cache for base images", + EnvVar: "PLUGIN_CACHE_DIR", + }, + + cli.BoolFlag{ + Name: "cache-copy-layers", + Usage: "Enable or disable copying layers from the cache.", + EnvVar: "PLUGIN_CACHE_COPY_LAYERS", + }, + cli.BoolFlag{ + Name: "cache-run-layers", + Usage: "Enable or disable running layers from the cache.", + EnvVar: "PLUGIN_CACHE_RUN_LAYERS", + }, + cli.BoolFlag{ + Name: "cleanup", + Usage: "Enable or disable cleanup of temporary files.", + EnvVar: "PLUGIN_CLEANUP", + }, + cli.BoolFlag{ + Name: "compressed-caching", + Usage: "Enable or disable compressed caching.", + EnvVar: "PLUGIN_COMPRESSED_CACHING", + }, + cli.StringFlag{ + Name: "context-sub-path", + Usage: "Sub-path within the context to build.", + EnvVar: "PLUGIN_CONTEXT_SUB_PATH", + }, + cli.StringFlag{ + Name: "custom-platform", + Usage: "Platform to use for building.", + EnvVar: "PLUGIN_CUSTOM_PLATFORM", + }, + cli.BoolFlag{ + Name: "force", + Usage: "Force building the image even if it already exists.", + EnvVar: "PLUGIN_FORCE", + }, + cli.StringFlag{ + Name: "image-name-with-digest-file", + Usage: "Write image name with digest to a file.", + EnvVar: "PLUGIN_IMAGE_NAME_WITH_DIGEST_FILE", + }, + cli.StringFlag{ + Name: "image-name-tag-with-digest-file", + Usage: "Write image name with tag and digest to a file.", + EnvVar: "PLUGIN_IMAGE_NAME_TAG_WITH_DIGEST_FILE", + }, + cli.BoolFlag{ + Name: "insecure", + Usage: "Allow connecting to registries without TLS.", + EnvVar: "PLUGIN_INSECURE", + }, + cli.BoolFlag{ + Name: "insecure-pull", + Usage: "Allow insecure pulls from the registry.", + EnvVar: "PLUGIN_INSECURE_PULL", + }, + cli.StringFlag{ + Name: "insecure-registry", + Usage: "Use plain HTTP for registry communication.", + EnvVar: "PLUGIN_INSECURE_REGISTRY", + }, + cli.StringFlag{ + Name: "log-format", + Usage: "Set the log format for build output.", + EnvVar: "PLUGIN_LOG_FORMAT", + }, + cli.BoolFlag{ + Name: "log-timestamp", + Usage: "Show timestamps in build output.", + EnvVar: "PLUGIN_LOG_TIMESTAMP", + }, + cli.StringFlag{ + Name: "oci-layout-path", + Usage: "Directory to store OCI layout.", + EnvVar: "PLUGIN_OCI_LAYOUT_PATH", + }, + cli.IntFlag{ + Name: "push-retry", + Usage: "Number of times to retry pushing an image.", + EnvVar: "PLUGIN_PUSH_RETRY", + }, + cli.StringFlag{ + Name: "registry-certificate", + Usage: "Path to a file containing a registry certificate.", + EnvVar: "PLUGIN_REGISTRY_CERTIFICATE", + }, + cli.StringFlag{ + Name: "registry-client-cert", + Usage: "Path to a file containing a registry client certificate.", + EnvVar: "PLUGIN_REGISTRY_CLIENT_CERT", + }, + cli.BoolFlag{ + Name: "skip-default-registry-fallback", + Usage: "Skip Docker Hub and default registry fallback.", + EnvVar: "PLUGIN_SKIP_DEFAULT_REGISTRY_FALLBACK", + }, + cli.BoolFlag{ + Name: "reproducible", + Usage: "Create a reproducible image.", + EnvVar: "PLUGIN_REPRODUCIBLE", + }, + cli.BoolFlag{ + Name: "single-snapshot", + Usage: "Only create a single snapshot of the image.", + EnvVar: "PLUGIN_SINGLE_SNAPSHOT", + }, + cli.BoolFlag{ + Name: "skip-push-permission-check", + Usage: "Skip permission check when pushing.", + EnvVar: "PLUGIN_SKIP_PUSH_PERMISSION_CHECK", + }, + cli.BoolFlag{ + Name: "skip-tls-verify-pull", + Usage: "Skip TLS verification when pulling.", + EnvVar: "PLUGIN_SKIP_TLS_VERIFY_PULL", + }, + cli.BoolFlag{ + Name: "skip-tls-verify-registry", + Usage: "Skip TLS verification when connecting to a registry.", + EnvVar: "PLUGIN_SKIP_TLS_VERIFY_REGISTRY", + }, + cli.BoolFlag{ + Name: "use-new-run", + Usage: "Skip TLS verification when connecting to a registry.", + EnvVar: "PLUGIN_USE_NEW_RUN", + }, + cli.BoolFlag{ + Name: "ignore-var-run", + Usage: "Ignore the /var/run directory during build.", + EnvVar: "PLUGIN_IGNORE_VAR_RUN", + }, + cli.StringFlag{ + Name: "ignore-path", + Usage: "Path to ignore during the build.", + EnvVar: "PLUGIN_IGNORE_PATH", + }, + cli.IntFlag{ + Name: "image-fs-extract-retry", + Usage: "Number of retries for extracting filesystem layers.", + EnvVar: "PLUGIN_IMAGE_FS_EXTRACT_RETRY", + }, + cli.IntFlag{ + Name: "image-download-retry", + Usage: "Number of retries for downloading base images.", + EnvVar: "PLUGIN_IMAGE_DOWNLOAD_RETRY", + }, } if err := app.Run(os.Args); err != nil { @@ -187,28 +338,60 @@ func run(c *cli.Context) error { plugin := kaniko.Plugin{ Build: kaniko.Build{ - DroneCommitRef: c.String("drone-commit-ref"), - DroneRepoBranch: c.String("drone-repo-branch"), - Dockerfile: c.String("dockerfile"), - Context: c.String("context"), - Tags: c.StringSlice("tags"), - AutoTag: c.Bool("auto-tag"), - AutoTagSuffix: c.String("auto-tag-suffix"), - ExpandTag: c.Bool("expand-tag"), - Args: c.StringSlice("args"), - Target: c.String("target"), - Repo: fmt.Sprintf("%s/%s", c.String("registry"), c.String("repo")), - Mirrors: c.StringSlice("registry-mirrors"), - Labels: c.StringSlice("custom-labels"), - SnapshotMode: c.String("snapshot-mode"), - EnableCache: c.Bool("enable-cache"), - CacheRepo: fmt.Sprintf("%s/%s", c.String("registry"), c.String("cache-repo")), - CacheTTL: c.Int("cache-ttl"), - DigestFile: defaultDigestFile, - NoPush: noPush, - Verbosity: c.String("verbosity"), - Platform: c.String("platform"), - SkipUnusedStages: c.Bool("skip-unused-stages"), + DroneCommitRef: c.String("drone-commit-ref"), + DroneRepoBranch: c.String("drone-repo-branch"), + Dockerfile: c.String("dockerfile"), + Context: c.String("context"), + Tags: c.StringSlice("tags"), + AutoTag: c.Bool("auto-tag"), + AutoTagSuffix: c.String("auto-tag-suffix"), + ExpandTag: c.Bool("expand-tag"), + Args: c.StringSlice("args"), + Target: c.String("target"), + Repo: fmt.Sprintf("%s/%s", c.String("registry"), c.String("repo")), + Mirrors: c.StringSlice("registry-mirrors"), + Labels: c.StringSlice("custom-labels"), + SnapshotMode: c.String("snapshot-mode"), + EnableCache: c.Bool("enable-cache"), + CacheRepo: fmt.Sprintf("%s/%s", c.String("registry"), c.String("cache-repo")), + CacheTTL: c.Int("cache-ttl"), + DigestFile: defaultDigestFile, + NoPush: noPush, + Verbosity: c.String("verbosity"), + Platform: c.String("platform"), + SkipUnusedStages: c.Bool("skip-unused-stages"), + CacheDir: c.String("cache-dir"), + CacheCopyLayers: c.Bool("cache-copy-layers"), + CacheRunLayers: c.Bool("cache-run-layers"), + Cleanup: c.Bool("cleanup"), + CompressedCaching: c.Bool("compressed-caching"), + ContextSubPath: c.String("context-sub-path"), + CustomPlatform: c.String("custom-platform"), + Force: c.Bool("force"), + ImageNameWithDigestFile: c.String("image-name-with-digest-file"), + ImageNameTagWithDigestFile: c.String("image-name-tag-with-digest-file"), + Insecure: c.Bool("insecure"), + InsecurePull: c.Bool("insecure-pull"), + InsecureRegistry: c.String("insecure-registry"), + Label: c.String("label"), + LogFormat: c.String("log-format"), + LogTimestamp: c.Bool("log-timestamp"), + OCILayoutPath: c.String("oci-layout-path"), + PushRetry: c.Int("push-retry"), + RegistryCertificate: c.String("registry-certificate"), + RegistryClientCert: c.String("registry-client-cert"), + SkipDefaultRegistryFallback: c.Bool("skip-default-registry-fallback"), + Reproducible: c.Bool("reproducible"), + SingleSnapshot: c.Bool("single-snapshot"), + SkipTLSVerify: c.Bool("skip-tls-verify"), + SkipPushPermissionCheck: c.Bool("skip-push-permission-check"), + SkipTLSVerifyPull: c.Bool("skip-tls-verify-pull"), + SkipTLSVerifyRegistry: c.Bool("skip-tls-verify-registry"), + UseNewRun: c.Bool("use-new-run"), + IgnoreVarRun: c.Bool("ignore-var-run"), + IgnorePath: c.String("ignore-path"), + ImageFSExtractRetry: c.Int("image-fs-extract-retry"), + ImageDownloadRetry: c.Int("image-download-retry"), }, Artifact: kaniko.Artifact{ Tags: c.StringSlice("tags"), diff --git a/kaniko.go b/kaniko.go index b3dbfab..2a11a1b 100644 --- a/kaniko.go +++ b/kaniko.go @@ -273,9 +273,13 @@ func (p Plugin) Exec() error { cmdArgs = append(cmdArgs, "--cleanup=true") } - compressedCaching, ok := os.LookupEnv("PLUGIN_COMPRESSED_CACHING") + _, ok := os.LookupEnv("PLUGIN_COMPRESSED_CACHING") if ok { - cmdArgs = append(cmdArgs, "--compressed-caching=%s", compressedCaching) + if p.Build.CompressedCaching { + cmdArgs = append(cmdArgs, "--compressed-caching=true") + } else { + cmdArgs = append(cmdArgs, "--compressed-caching=false") + } } if p.Build.ContextSubPath != "" { @@ -366,8 +370,13 @@ func (p Plugin) Exec() error { cmdArgs = append(cmdArgs, "--use-new-run") } - if p.Build.IgnoreVarRun { - cmdArgs = append(cmdArgs, "--ignore-var-run") + _, ok = os.LookupEnv("PLUGIN_IGNORE_VAR_RUN") + if ok { + if p.Build.IgnoreVarRun { + cmdArgs = append(cmdArgs, "--ignore-var-run=true") + } else { + cmdArgs = append(cmdArgs, "--ignore-var-run=false") + } } if p.Build.IgnorePath != "" {