Skip to content

fix: inject APP_VERSION from build host instead of running git inside the image#57

Merged
chiro-hiro merged 2 commits into
orochi-network:mainfrom
chiro-hiro:fix/app-version-from-build-host
Jun 6, 2026
Merged

fix: inject APP_VERSION from build host instead of running git inside the image#57
chiro-hiro merged 2 commits into
orochi-network:mainfrom
chiro-hiro:fix/app-version-from-build-host

Conversation

@chiro-hiro

Copy link
Copy Markdown
Contributor

The generated Dockerfile builds with a context that excludes .git (consumers .dockerignore it). But scripts/build-prod-node.sh computed the version inside the container:

REV=$(git rev-parse --short HEAD)   # fatal: not a git repository

Under set -euo pipefail that command substitution aborts the build at the builder stage:

#14 [builder 5/5] RUN ... build-prod-node.sh
#14 0.552 fatal: not a git repository (or any of the parent directories): .git

This broke every template build that runs build-prod-node.sh (node, strapi).

Fix — compute the version on the build host, pass it in

  • dockerfile.sh: emit ARG APP_VERSION + ENV APP_VERSION=${APP_VERSION} right before the builder build RUN, so a version injected via --build-arg is visible to the build script.
  • scripts/build-prod-node.sh: use the injected $APP_VERSION; only fall back to git (now tolerant: || echo unknown) when run locally inside a real repo. No more hard git dependency inside the image.

Companion change in orochi-network/actions (build-docker-template) computes the version on the runner (which does have .git) and passes --build-arg APP_VERSION=....

Backward-compatible / independently safe: if the build-arg is absent, APP_VERSION is empty and the script falls back to unknown rather than crashing.

… the image

The image build context excludes .git, so git rev-parse failed under
set -euo pipefail and aborted the build at builder stage. Take APP_VERSION
from the build host (injected via build-arg/ENV); keep a tolerant git
fallback only for local runs.
…injection

Emit ARG APP_VERSION + ENV APP_VERSION before the builder build RUN so the
version computed on the build host (which has .git) is available to
build-prod-node.sh inside the container.
@chiro-hiro chiro-hiro merged commit 889b353 into orochi-network:main Jun 6, 2026
2 of 4 checks passed
@chiro-hiro chiro-hiro deleted the fix/app-version-from-build-host branch June 6, 2026 06:14
chiro-hiro added a commit that referenced this pull request Jun 7, 2026
…#58)

Consumer docker builds (and the CI trust checks) could hang indefinitely in
the fetch/install phase. Every curl fetch in dev-off ran without a timeout, so
a stalled-but-open TCP connection blocked forever with no output. yarn and
corepack have their own network timeouts; the bare `curl ... | bash` that
fetches the build script — and the trust-script fetches — did not.

Add bounded --connect-timeout/--max-time plus --retry/--retry-delay to every
curl so a stalled fetch fails fast and retries transient blips instead of
hanging:
- dockerfile.sh: generated build RUN fetch + remote template fetch
- check-gpg.sh / check-ssh.sh: checksum + allowlist fetches (CURL_OPTS array)
- generate-ssh-allowed-signers.sh: GitHub .keys fetch

Also restore green CI (both jobs went red after the #57 merge):
- regenerate checksum.sha256 — it was stale because #57 changed dockerfile.sh
  and scripts/build-prod-node.sh without refreshing it
- silence a false-positive shellcheck SC2016 on the intentional single-quoted
  `ENV APP_VERSION=${APP_VERSION}` (Docker, not the shell, expands it)
chiro-hiro added a commit to chiro-hiro/dev-off that referenced this pull request Jun 7, 2026
The generated Dockerfile ran `corepack enable` only in the runner stage, even
though the build (`yarn install`/`yarn build`) happens in the builder. It worked
by accident — the orochinetwork/ubuntu:node base image already ships yarn as a
corepack shim — and contradicted the documented contract (DOCKERFILE.md:
"Enables corepack in both the builder and the runner"). If the base image ever
stopped pre-shimming yarn, the Strapi (Yarn 4 berry) build would break with no
corepack in the builder.

Emit the corepack-enable RUN layer in BOTH stages:
- Dockerfile.template: add {{builder_corepack_run}}, placed as root before the
  USER switch (and before COPY, so the layer caches independently of code).
- dockerfile.sh: substitute {{builder_corepack_run}} from the same generator;
  refresh the now-stale comment.

Also carries the same shellcheck SC2016 silence as orochi-network#58 so this PR is green
independently of merge order (the finding was introduced by the orochi-network#57 merge).
chiro-hiro added a commit that referenced this pull request Jun 7, 2026
…ner (#59)

The generated Dockerfile ran `corepack enable` only in the runner stage, even
though the build (`yarn install`/`yarn build`) happens in the builder. It worked
by accident — the orochinetwork/ubuntu:node base image already ships yarn as a
corepack shim — and contradicted the documented contract (DOCKERFILE.md:
"Enables corepack in both the builder and the runner"). If the base image ever
stopped pre-shimming yarn, the Strapi (Yarn 4 berry) build would break with no
corepack in the builder.

Emit the corepack-enable RUN layer in BOTH stages:
- Dockerfile.template: add {{builder_corepack_run}}, placed as root before the
  USER switch (and before COPY, so the layer caches independently of code).
- dockerfile.sh: substitute {{builder_corepack_run}} from the same generator;
  refresh the now-stale comment.

Also carries the same shellcheck SC2016 silence as #58 so this PR is green
independently of merge order (the finding was introduced by the #57 merge).
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.

1 participant