Fix Dockerfile heredoc parse error in RUN if block

Use printf instead of heredoc for cargo config — heredoc inside a
conditional RUN block confuses Docker's parser (fi becomes an unknown
instruction). The config is always written; unused linker entries are
harmless on native builds.
This commit is contained in:
Claude 2026-03-20 10:42:46 +00:00
parent 3096d251c6
commit 3794f4cf36
No known key found for this signature in database

View file

@ -29,19 +29,16 @@ RUN case "${TARGETARCH}:${TARGETVARIANT}" in \
esac > /rust_target && \
rustup target add "$(cat /rust_target)"
# Tell Cargo which cross-linker to use — only needed when cross-compiling.
RUN if [ "${BUILDPLATFORM}" != "${TARGETPLATFORM}" ]; then \
mkdir -p /root/.cargo && cat >> /root/.cargo/config.toml <<'EOF'
[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"
[target.armv7-unknown-linux-gnueabihf]
linker = "arm-linux-gnueabihf-gcc"
[target.arm-unknown-linux-gnueabi]
linker = "arm-linux-gnueabi-gcc"
EOF
fi
# Tell Cargo which cross-linker to use (ignored on native builds).
RUN mkdir -p /root/.cargo && printf '\
[target.aarch64-unknown-linux-gnu]\n\
linker = "aarch64-linux-gnu-gcc"\n\
\n\
[target.armv7-unknown-linux-gnueabihf]\n\
linker = "arm-linux-gnueabihf-gcc"\n\
\n\
[target.arm-unknown-linux-gnueabi]\n\
linker = "arm-linux-gnueabi-gcc"\n' >> /root/.cargo/config.toml
WORKDIR /build