Skip to content

Dockerfile.local: place COPY targets under /out#153

Merged
milan-zededa merged 1 commit into
lf-edge:masterfrom
eriknordmark:dockerfile-local-out-paths
May 15, 2026
Merged

Dockerfile.local: place COPY targets under /out#153
milan-zededa merged 1 commit into
lf-edge:masterfrom
eriknordmark:dockerfile-local-out-paths

Conversation

@eriknordmark
Copy link
Copy Markdown
Contributor

Summary

make image-local (documented in README.md as the recommended quick
reproducible build path) currently produces an image without
/bin/adam. Running such an image fails immediately with:

"/bin/adam": stat /bin/adam: no such file or directory

Root cause

Dockerfile.local's build stage sets WORKDIR /out but the three
COPY directives target absolute paths at root:

WORKDIR /out
COPY scripts /bin
COPY samples /adam
COPY ./bin/adam-linux-amd64 /bin/adam

Absolute paths in COPY are not joined with WORKDIR, so the
files land at /bin, /adam, and /bin/adam in the build stage's
filesystem.

The final scratch stage then does:

FROM scratch
COPY --from=build /out/ /

…which copies only what's under /out/. The scripts, samples, and
adam binary at the build-stage root are silently dropped from the
final image.

The non-.local Dockerfile (used for CI / Docker Hub builds) does
this correctly — RUN go build -o /out/bin/adam main.go,
COPY scripts/ /out/bin/, COPY samples/ /out/adam/. Only
Dockerfile.local has the bug.

Fix

Redirect the three COPY destinations to /out/bin/, /out/adam/,
and /out/bin/adam so the scratch stage picks them up.

How to test

Before this patch, on master HEAD:

make build                 # produce bin/adam-linux-amd64
make image-local IMG=lfedge/adam:test
docker run --rm --entrypoint=/bin/sh lfedge/adam:test -c 'ls /bin/adam'
# → ls: /bin/adam: No such file or directory

After this patch:

docker run --rm --entrypoint=/bin/sh lfedge/adam:test -c 'ls -la /bin/adam'
# → -rwxr-xr-x 1 root root 21998444 … /bin/adam
docker run --rm --entrypoint=/bin/sh lfedge/adam:test -c 'ls /adam/'
# → simple.json … (samples present)

The actual make image-local flow (which calls make build first on
my local machine has an unrelated go.mod-version vs. pinned-golang
issue), but the Dockerfile change itself is independently verifiable
by building it directly with a pre-existing bin/adam-linux-amd64,
which I've done locally as shown above.

The build stage uses WORKDIR /out, but the three COPY directives went
to absolute paths at root (/bin, /adam, /bin/adam). The final scratch
stage does `COPY --from=build /out/ /`, which only picks up files
under /out — so scripts, samples, and the adam binary itself were
silently dropped from the image.

Result: `make image-local` (documented in README.md as a recommended
quick reproducible build path) produces an image without /bin/adam.
Running it fails with `"/bin/adam": stat /bin/adam: no such file or
directory`.

Fix: redirect the COPY destinations to /out/bin/, /out/adam/, and
/out/bin/adam so the scratch stage finds them.

Signed-off-by: eriknordmark <erik@zededa.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@milan-zededa milan-zededa merged commit 0da48cf into lf-edge:master May 15, 2026
2 checks passed
@eriknordmark eriknordmark deleted the dockerfile-local-out-paths branch May 15, 2026 20:16
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