Skip to content

Decouple corepack enable from the runner chmod in the Dockerfile template#53

Merged
chiro-hiro merged 2 commits into
orochi-network:mainfrom
chiro-hiro:fix/decouple-corepack-from-chmod
Jun 4, 2026
Merged

Decouple corepack enable from the runner chmod in the Dockerfile template#53
chiro-hiro merged 2 commits into
orochi-network:mainfrom
chiro-hiro:fix/decouple-corepack-from-chmod

Conversation

@chiro-hiro

Copy link
Copy Markdown
Contributor

Problem

Closes #44.

The runner-stage chmod in Dockerfile.template chained corepack enable onto its tail through a template variable whose value was the literal shell operator " && corepack enable":

chmod -R 750 ${RUNNER_WORKDIR}{{corepack_enable}}

Embedding a shell operator inside a template variable couples shell control flow to the templating layer, and the {{corepack_enable}} placeholder was concatenated directly onto the chmod with no separation boundary. Both previously-open branches independently removed this pattern, which suggests it was recognised as fragile.

Fix

corepack enable is now emitted as its own RUN layer:

  • COREPACK_ENABLE holds only the command (corepack enable), no shell operator.
  • New generate_corepack_run() helper emits a dedicated RUN corepack enable (with a comment) when the template requires it.
  • New {{corepack_run}} multi-line placeholder; the runner chmod stands alone.
  • {{corepack_enable}} and its perl substitution are removed.

Behaviour is unchanged: node/next still enable corepack (now in a clean dedicated layer), nginx still emits none.

Generated node runner stage (after)

RUN mkdir -p ${RUNNER_WORKDIR} && \
  chown -R node:node ${RUNNER_WORKDIR} && \
  chown -R node /home/node && \
  chmod -R 750 ${RUNNER_WORKDIR}

# Enable corepack to manage the project's package manager
RUN corepack enable

Verification

  • shellcheck dockerfile.sh — no findings
  • --dry-run for node, next, nginx all generate valid Dockerfiles; corepack appears as a standalone RUN for node/next and is absent for nginx; no stray blank lines

…late

The runner-stage chmod command piggybacked corepack enable onto its tail via
a COREPACK_ENABLE template variable whose value was the literal shell operator
" && corepack enable". Embedding a shell operator inside a template variable
coupled shell control flow to templating and left the {{corepack_enable}}
placeholder concatenated directly onto the chmod with no separation boundary.

Emit corepack enable as its own RUN layer instead, via a new generate_corepack_run()
helper and a {{corepack_run}} placeholder. COREPACK_ENABLE now holds only the
command ("corepack enable"), and the runner chmod stands alone. Behaviour is
unchanged: node/next still enable corepack (now in a dedicated RUN), nginx still
emits none.

Closes orochi-network#44
@chiro-hiro chiro-hiro force-pushed the fix/decouple-corepack-from-chmod branch from 107170a to e9dc5ba Compare June 4, 2026 10:11
@chiro-hiro chiro-hiro merged commit 544934f into orochi-network:main Jun 4, 2026
4 checks passed
@chiro-hiro chiro-hiro deleted the fix/decouple-corepack-from-chmod branch June 4, 2026 10:13
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.

dockerfile.sh: COREPACK_ENABLE template variable embeds shell operator (&&)

1 participant