You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here is an example Dockerfile/Containerfile not formatted.
FROM debian:12.6-slim
RUN set -eux; for x in {1..3}; do echo 'foo'; echo 'bar'; echo "$x"; done
Here is what it looks like after formatting.
FROM debian:12.6-slim
RUN set -eux
for x in {1..3}; do
echo 'foo'
echo 'bar'
echo "$x"
done
Here is the output from podman build. Obviously, FOR is not a Dockerfile instruction.
STEP 1/7: FROM debian:12.6-slim
STEP 2/7: RUN set -eux
--> 9816982104ff
STEP 3/7: forxin {1..3};do
time="2024-07-10T08:01:59-10:00" level=error msg="+(UNHANDLED LOGLEVEL) &imagebuilder.Step{Env:[]string{\"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin\"}, Command:\"for\", Args:[]string{\"\"}, Flags:[]string{}, Attrs:map[string]bool(nil), Message:\"FOR \", Heredocs:[]parser.Heredoc(nil), Original:\"for x in {1..3}; do\"}"
Error: building at STEP "FOR ": Build error: Unknown instruction: "FOR"&imagebuilder.Step{Env:[]string{"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"}, Command:"for", Args:[]string{""}, Flags:[]string{}, Attrs:map[string]bool(nil), Message:"FOR ", Heredocs:[]parser.Heredoc(nil), Original:"for x in {1..3}; do"}
I would rather write RUN <<EOF, but that is also broken by the formatting.
FROM debian:12.6-slim
RUN <<EOF
set -eux
for x in {1..3}
do
echo 'foo'
echo 'bar'
echo "$x"
done
EOF
Here is what it looks like after formatting.
FROM debian:12.6-slim
RUN << EOF
set -eux
for x in {1..3}
do
echo 'foo'
echo 'bar'
echo "$x"
done
EOF
The problem here is the space that is added between << and EOF.
STEP 1/10: FROM debian:12.6-slim
STEP 2/10: RUN <<EOF--> 687a1076c4e0STEP 3/10: set -euxtime="2024-07-10T08:20:19-10:00" level=error msg="+(UNHANDLED LOGLEVEL) &imagebuilder.Step{Env:[]string{\"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin\"}, Command:\"set\", Args:[]string{\"\"}, Flags:[]string{}, Attrs:map[string]bool(nil), Message:\"SET \", Heredocs:[]parser.Heredoc(nil), Original:\"set -eux\"}"Error: building at STEP "SET ": Build error: Unknown instruction: "SET" &imagebuilder.Step{Env:[]string{"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"}, Command:"set", Args:[]string{""}, Flags:[]string{}, Attrs:map[string]bool(nil), Message:"SET ", Heredocs:[]parser.Heredoc(nil), Original:"set -eux"}
The text was updated successfully, but these errors were encountered:
jameshearttech
changed the title
Format Dockerfile RUN for loop
Dockerfile/Containerfile formatting issues with for loops and RUN <<EOF
Jul 10, 2024
jameshearttech
changed the title
Dockerfile/Containerfile formatting issues with for loops and RUN <<EOF
Dockerfile/Containerfile formatting issues with for loops/semicolons and RUN <<EOFJul 10, 2024
Recently started using
prettier-plugin-sh
. Seems to work okay with shell scripts, but I have been struggling with formatting Dockerfile/Containerfile.Here is the
prettier
loaded options from the CLI debug.Here is an example Dockerfile/Containerfile not formatted.
Here is what it looks like after formatting.
Here is the output from
podman build
. Obviously,FOR
is not a Dockerfile instruction.I would rather write
RUN <<EOF
, but that is also broken by the formatting.Here is what it looks like after formatting.
The problem here is the space that is added between
<<
andEOF
.The text was updated successfully, but these errors were encountered: