Skip to content

chore(docker): use heredoc syntax for multi-step RUN blocks#2433

Open
dunglas wants to merge 1 commit into
mainfrom
chore/dockerfile-heredoc
Open

chore(docker): use heredoc syntax for multi-step RUN blocks#2433
dunglas wants to merge 1 commit into
mainfrom
chore/dockerfile-heredoc

Conversation

@dunglas
Copy link
Copy Markdown
Member

@dunglas dunglas commented May 16, 2026

Summary

Converts multi-command RUN instructions across all six Dockerfiles from \-continuation + && chains to `<<EOF` heredoc form:

  • `Dockerfile`
  • `alpine.Dockerfile`
  • `dev.Dockerfile`
  • `dev-alpine.Dockerfile`
  • `static-builder-musl.Dockerfile`
  • `static-builder-gnu.Dockerfile`

Each step becomes one command per line — easier to scan, easier to diff, and no more trailing-backslash bookkeeping.

Notes

  • Heredoc bodies start with `set -e` where the SHELL directive doesn't already imply errexit (the bash builders in `Dockerfile`, `dev.Dockerfile`, and `static-builder-gnu.Dockerfile`). The ash-based SHELLs in alpine variants already include `-e` so it stays implicit there.
  • Behavior should be unchanged — same commands, same order. The only structural shift is the `if/then/else` block in `static-builder-gnu.Dockerfile`'s arch detection, which is rewritten without trailing `\` and `;` continuations.
  • The e-dant/watcher install block in `Dockerfile` and `alpine.Dockerfile` is intentionally left alone — build(docker): make e-dant/watcher install robust #2432 already converts those specifically. Both PRs touch adjacent regions but disjoint line ranges, so a 3-way merge resolves cleanly whichever lands first.

Convert multi-command RUN instructions across all six Dockerfiles from
'\\'-continuation joined with '&&' to <<EOF heredoc form. Each script
becomes one command per line, easier to scan and edit.

Heredoc bodies start with 'set -e' where SHELL doesn't already imply it
(bash builder stages in Dockerfile, dev.Dockerfile, and
static-builder-gnu.Dockerfile). Alpine/ash SHELL declarations already
include '-e', so it stays implicit there.

The e-dant/watcher install block in Dockerfile and alpine.Dockerfile is
intentionally left alone here — #2432 already converts those
specifically.
Copilot AI review requested due to automatic review settings May 16, 2026 14:59
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Converts multi-command RUN instructions in all six Dockerfiles from \-continuation + && chains to <<EOF heredoc form, making the steps easier to scan and diff. Explicit set -e is added at the top of heredoc bodies where the configured SHELL does not already imply errexit (bash variants); ash-based SHELLs already include -e so no explicit guard is added.

Changes:

  • Rewrite multi-line RUN blocks in all six Dockerfiles to BuildKit heredoc syntax.
  • Add set -e/set -eux where the active SHELL lacks errexit.
  • Drop two broken in-list # comment \ lines (would have been consumed as shell comments) and simplify a couple of if/then/else arch detection blocks.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
Dockerfile Convert four RUN blocks to heredoc form with explicit set -e/set -eux.
alpine.Dockerfile Convert four RUN blocks to heredoc; rely on ash -e SHELL where applicable.
dev.Dockerfile Convert install/build/watcher RUN blocks to heredoc; add set -e; drop broken # Dev tools comment.
dev-alpine.Dockerfile Convert install/build/watcher RUN blocks to heredoc; drop two broken inline comments.
static-builder-musl.Dockerfile Convert the apk add + xcaddy install RUN to heredoc form.
static-builder-gnu.Dockerfile Convert three RUN blocks (yum setup, arch-specific SCL repo logic, build-essentials) to heredoc form with set -e.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants