diff --git a/README.md b/README.md index 5b3b18867..daa64d8a7 100644 --- a/README.md +++ b/README.md @@ -149,6 +149,7 @@ expect - see [Known Issues](#known-issues). - [Flag `FF_KANIKO_SECUREJOIN_EXTRACTION`](#flag-ff_kaniko_securejoin_extraction) - [Flag `FF_KANIKO_RESOLVE_CACHE_KEY`](#flag-ff_kaniko_resolve_cache_key) - [Flag `FF_KANIKO_UNTAR_SKIP_ROOT`](#flag-ff_kaniko_untar_skip_root) + - [Flag `FF_KANIKO_EXPAND_HEREDOC`](#flag-ff_kaniko_expand_heredoc) - [Assertion Overrides](#assertion-overrides) - [Debug Image](#debug-image) - [Security](#security) @@ -1305,6 +1306,13 @@ Set this flag to `true` to skip the root `.` entry when untarring. Defaults to `false`. Becomes default in `v1.29.0`. +#### Flag `FF_KANIKO_EXPAND_HEREDOC` + +Docker applies Dockerfile word-expansion to a `COPY` or `ADD` heredoc body when the delimiter is unquoted, so `${VAR}` expands and `\${VAR}` keeps the literal text. A quoted delimiter (`<<'EOF'`) leaves the body verbatim. kaniko writes the body verbatim in every case, so the expanded files diverge from Docker. +Set this flag to `true` to expand build args and env in unquoted `COPY` and `ADD` heredoc bodies. +Defaults to `false`. +Becomes default in `v1.29.0`. + ### Assertion Overrides Kaniko checks internal invariants at runtime. If one is violated the build stops with a message like: diff --git a/integration/dockerfiles/Dockerfile_test_issue_mz817 b/integration/dockerfiles/Dockerfile_test_issue_mz817 new file mode 100644 index 000000000..0360601be --- /dev/null +++ b/integration/dockerfiles/Dockerfile_test_issue_mz817 @@ -0,0 +1,19 @@ +# mz817: on v1.27.6 COPY heredoc does not expand build variables. +# Docker applies Dockerfile word-expansion to a COPY heredoc body when the +# delimiter is unquoted: ${VAR} expands and \${VAR} keeps the literal text with +# the backslash stripped. A quoted delimiter (<<'EOF') leaves the body verbatim. +# kaniko writes the body verbatim in every case, so the expanded files diverge. +FROM scratch + +ENV DO_EXPAND=expanded + +# unquoted delimiter expands ${DO_EXPAND}, keeps \${DO_EXPAND} literal +COPY <