Skip to content

fix(docker): add coreutils so MAX_LIFETIME_SECONDS works on Wolfi base - #586

Open
agarctfi wants to merge 1 commit into
mainfrom
fix/eng-1428-coreutils-timeout
Open

fix(docker): add coreutils so MAX_LIFETIME_SECONDS works on Wolfi base#586
agarctfi wants to merge 1 commit into
mainfrom
fix/eng-1428-coreutils-timeout

Conversation

@agarctfi

Copy link
Copy Markdown

Summary

MAX_LIFETIME_SECONDS is broken on the published unstructured-api image and has been since the base image moved from RockyLinux to Chainguard Wolfi (#423).

scripts/app-start.sh runs GNU timeout with --preserve-status and --foreground when MAX_LIFETIME_SECONDS is set. The Wolfi base only provides BusyBox timeout, which does not support those flags, so BusyBox rejects the first one and exits non-zero. uvicorn never launches, the script falls through to its shutdown echoes, and a container with a restart policy loops.

GNU coreutils shipped for free as part of the old RockyLinux userland and was lost in the distro swap; it has never been an explicit package in the Dockerfile. This PR adds it back.

Reported in Pylon 2657. Fixes ENG-1428.

Reproduction

Runs the real scripts/app-start.sh with a stub standing in for uvicorn.

Current base (BusyBox timeout), server never starts:

$ docker run --rm -e MAX_LIFETIME_SECONDS=3 -v "$PWD:/work" \
    --entrypoint sh cgr.dev/chainguard/wolfi-base:latest \
    -c 'apk add --no-cache bash >/dev/null 2>&1; export PATH=/work/bin:$PATH; cd /work; bash app-start.sh'
Server's lifetime set to 3 seconds.
timeout: unrecognized option '--preserve-status'
BusyBox v1.38.0 multi-call binary.
Usage: timeout [-s SIG] [-k KILL_SECS] SECS PROG ARGS
Server was shutdown
Reached timeout of 3 seconds

The stub "server started" line never prints.

With this fix (base + coreutils), server launches and runs for the full lifetime:

$ docker run --rm -e MAX_LIFETIME_SECONDS=3 -v "$PWD:/work" \
    --entrypoint sh cgr.dev/chainguard/wolfi-base:latest \
    -c 'apk add --no-cache bash coreutils >/dev/null 2>&1; export PATH=/work/bin:$PATH; cd /work; bash app-start.sh'
Server's lifetime set to 3 seconds.
[stub-uvicorn] server started, args: prepline_general.api.app:app --log-config logger_config.yaml --host 0.0.0.0 --port 8000 --workers 1
Server was shutdown
Reached timeout of 3 seconds

CVE impact

apk add coreutils was scanned with grype (DB 27 August 2026) on cgr.dev/chainguard/wolfi-base:latest:

Image apk packages CVEs
base as-is 15 0
base + coreutils 21 0

It pulls in 6 Chainguard-maintained packages (coreutils, libacl1, libattr1, libpcre2-8-0, libselinux, libsepol), all with no known vulnerabilities. Image size grows about 10 MB. Adding coreutils does not reintroduce the RockyLinux CVE surface that #423 was shedding.

Notes

  • The guard in app-start.sh (command -v timeout) is also broken independent of the base image: BusyBox timeout satisfies the check, so the intended gtimeout fallback never runs. This PR fixes the reported bug by making GNU timeout present; hardening the script to detect BusyBox vs GNU would make it robust regardless of base and can be a follow-up.
  • The core-product mirror of this Dockerfile (base cgr.dev/unstructured.io/python-fips:3.12-dev) is also Wolfi-based and lacks coreutils, so it needs the same change.

Test plan

  • Reproduced the failure with the real app-start.sh on the current base
  • Verified the server starts and runs for the full lifetime with coreutils
  • Confirmed 0 new CVEs via grype

scripts/app-start.sh invokes GNU `timeout` with --preserve-status and
--foreground when MAX_LIFETIME_SECONDS is set. The Wolfi base only ships
BusyBox `timeout`, which rejects those flags, so the server never starts
and the container restart-loops. GNU coreutils rode in for free on the old
RockyLinux base and was lost in the RockyLinux -> Wolfi switch (PR #423).

Add coreutils to the image to restore GNU `timeout`. Verified against the
real app-start.sh: the server now starts and runs for the full lifetime.
grype shows adding coreutils introduces 0 new CVEs (6 Chainguard-maintained
packages, ~10 MB).

Reported in Pylon 2657. Fixes ENG-1428.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@agarctfi
agarctfi force-pushed the fix/eng-1428-coreutils-timeout branch from 1ce331c to 72ffc71 Compare August 27, 2026 15:56
@agarctfi
agarctfi marked this pull request as ready for review August 27, 2026 16:40

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No issues found across 3 files

Shadow auto-approve: would not auto-approve. This PR does not meet the repository auto-approval settings.

Re-trigger cubic

@agarctfi
agarctfi requested review from a team, awalker4, lawrence-u10d and luke-kucing August 27, 2026 16:43
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