Skip to content

Install inotify-tools in runtime image instead of build stage#26

Merged
tom-pang merged 1 commit intomainfrom
support-inotify-arm64
Mar 9, 2026
Merged

Install inotify-tools in runtime image instead of build stage#26
tom-pang merged 1 commit intomainfrom
support-inotify-arm64

Conversation

@tom-pang
Copy link

@tom-pang tom-pang commented Mar 9, 2026

Problem: The Dockerfile installs inotify-tools in the build stage,
which uses --platform=$BUILDPLATFORM (always the build host's architecture,
typically x86-64). The inotifywait binary and libinotifytools.so.0 are then
COPY --from=build into the runtime image. On ARM64 nodes, the x86-64 binary
cannot execute — busybox sh falls back to interpreting the ELF as a shell
script, producing syntax error: unexpected "(". The dynamic linker
/lib64/ld-linux-x86-64.so.2 is missing; only
/lib/ld-linux-aarch64.so.1 exists. This silently breaks all inotifywait-based
config reload in postgres-exporter on ARM64.

Solution: Remove inotify-tools from the build stage and install it via
apk --no-cache add inotify-tools in the runtime stage instead. The runtime
stage uses the target platform, so ARM64 builds get an ARM64 inotifywait. Remove
the two COPY --from=build lines for /bin/inotifywait and
/lib/libinotifytools.so.0 since the package manager handles installation.


Security Impact:

None. Same package, installed from the same apk repository, just in the correct build stage. No new privileges or dependencies.


Testing:

  • Multi-arch image build (linux/amd64,linux/arm64) verifies ARM64 inotifywait is present and executable — runs automatically on merge to main via build.yml, so will test there.

**Problem**: The Dockerfile installs `inotify-tools` in the `build` stage,
which uses `--platform=$BUILDPLATFORM` (always the build host's architecture,
typically x86-64). The inotifywait binary and libinotifytools.so.0 are then
`COPY --from=build` into the runtime image. On ARM64 nodes, the x86-64 binary
cannot execute — busybox sh falls back to interpreting the ELF as a shell
script, producing `syntax error: unexpected "("`. The dynamic linker
`/lib64/ld-linux-x86-64.so.2` is missing; only
`/lib/ld-linux-aarch64.so.1` exists. This silently breaks all inotifywait-based
config reload in postgres-exporter on ARM64.

**Solution**: Remove `inotify-tools` from the build stage and install it via
`apk --no-cache add inotify-tools` in the runtime stage instead. The runtime
stage uses the target platform, so ARM64 builds get an ARM64 inotifywait. Remove
the two `COPY --from=build` lines for `/bin/inotifywait` and
`/lib/libinotifytools.so.0` since the package manager handles installation.

**Testing**: Needs a multi-arch image build to verify ARM64 inotifywait works.
@tom-pang tom-pang requested a review from a team as a code owner March 9, 2026 09:49
@tom-pang tom-pang merged commit c434608 into main Mar 9, 2026
7 checks passed
@tom-pang tom-pang deleted the support-inotify-arm64 branch March 9, 2026 09:58
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