Skip to content

[AAASM-3527] 🐛 (aa-runtime): Fix Docker image entrypoint (/aa-runtime was a directory)#1198

Merged
Chisanan232 merged 2 commits into
masterfrom
v0.0.1/AAASM-3527/fix/runtime_image_entrypoint
Jun 22, 2026
Merged

[AAASM-3527] 🐛 (aa-runtime): Fix Docker image entrypoint (/aa-runtime was a directory)#1198
Chisanan232 merged 2 commits into
masterfrom
v0.0.1/AAASM-3527/fix/runtime_image_entrypoint

Conversation

@Chisanan232

Copy link
Copy Markdown
Contributor

Description

aa-runtime/Dockerfile produced an image whose ENTRYPOINT ["/aa-runtime"] resolved to a directory instead of the binary, so the published sidecar could not start:

exec /aa-runtime: is a directory

Root cause. The image builds with context: . (repo root). COPY . . brings the repo's aa-runtime/ source directory into the builder as /app/aa-runtime. The builder step then ran cp target/$TARGET/release/aa-runtime /app/aa-runtime — but /app/aa-runtime already existed as a directory, so the binary was placed inside it as /app/aa-runtime/aa-runtime. The final stage's COPY --from=builder /app/aa-runtime /aa-runtime therefore copied that directory into the runtime image, and the entrypoint pointed at a directory.

Fix. Copy the built binary to /aa-runtime-bin (outside /app), a path that no source directory in the build context can shadow, and COPY that single file into the final image. Also added a root .dockerignore (excludes target/, .git/, .github/, node_modules/) as defense-in-depth so the context stays lean and a host-built artifact can never be pulled in.

Before / after evidence

Built docker build -f aa-runtime/Dockerfile -t aa-runtime-test . from the repo root, then inspected the final image filesystem (distroless, no shell) via docker export:

$ docker export $(docker create aa-runtime-test) | tar -tvf - | grep aa-runtime
-rwxr-xr-x  0 0 0  9339280 21 Jun 22:31 aa-runtime

The /aa-runtime entry is now a regular executable file (-rwxr-xr-x, 9.3 MB) — before the fix it was a directory (d...).

Running the container executes the binary (no is a directory):

$ docker run --rm aa-runtime-test            # entrypoint runs the binary
thread 'main' panicked at aa-runtime/src/main.rs:15: "AA_AGENT_ID is required but not set"

$ docker run --rm -e AA_AGENT_ID=test-agent -e AA_POLICY_PATH="" aa-runtime-test
# boots and keeps running (timeout-killed) — no exec error

The runtime reaches its own main.rs config-loading logic, proving the entrypoint is the executable.

Type of Change

  • 🐛 Bug fix
  • 🔧 Configuration / CI change

Breaking Changes

  • No

Related Issues

  • Related Jira ticket: AAASM-3527

Closes AAASM-3527

Testing

  • Manual testing performed (real docker build + filesystem inspection + container start, see evidence above)
  • No unit tests required (Dockerfile/build-packaging change; correctness proven by building and running the image)

Checklist

  • Code follows project style guidelines
  • Self-review of the diff completed
  • Commits are small and follow the Gitmoji convention

Chisanan232 and others added 2 commits June 21, 2026 22:32
The build context (context: .) `COPY . .` brings the repo's aa-runtime/
source dir into /app as /app/aa-runtime. The builder then `cp`d the built
binary to /app/aa-runtime, which landed *inside* that pre-existing directory
as /app/aa-runtime/aa-runtime. The final stage COPYd that directory to
/aa-runtime, so ENTRYPOINT ["/aa-runtime"] resolved to a directory and the
sidecar failed at startup with `exec /aa-runtime: is a directory`.

Copy the binary to /aa-runtime-bin (outside /app), a path no source dir can
shadow, and COPY that single file into the final image. The entrypoint is now
the executable binary.

Closes AAASM-3527

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The aa-runtime image builds with context: . (repo root). Exclude target/,
VCS, and node_modules from the context so a host-built (wrong-arch, non-musl)
artifact can never be pulled in and the context stays small. Defense in depth
against the source-dir/binary name collision fixed in the prior commit.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Chisanan232

Copy link
Copy Markdown
Contributor Author

🤖 Claude Code — PR review (record)

CI: ✅ all green (Analyze rust/python/js-ts, Build language images, CodeQL).

Scope vs AAASM-3527: ✅ fully covers it. Root cause correctly identified — COPY . . with no .dockerignore pulled the repo's aa-runtime/ source dir into the builder as /app/aa-runtime, so the built binary cp'd to that path landed inside the directory and the final COPY shipped the directory → exec /aa-runtime: is a directory. Fix: stage the binary at a collision-free path (/aa-runtime-bin) then COPY it to /aa-runtime, plus a root .dockerignore. Verified by build: docker build succeeds and /aa-runtime is now a 9.3 MB executable file (not a directory); the container boots the runtime (panics only on missing AA_AGENT_ID, i.e. real app logic — no "is a directory").

Verdict:Ready to approve & merge. Closes AAASM-3527. This also unblocks the Docker smoke's Tier-B (sidecar-up) path.

@Chisanan232 Chisanan232 merged commit 77165e0 into master Jun 22, 2026
43 checks passed
@Chisanan232 Chisanan232 deleted the v0.0.1/AAASM-3527/fix/runtime_image_entrypoint branch June 22, 2026 00:36
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