-
Notifications
You must be signed in to change notification settings - Fork 107
Description
Summary
When using agentcore configure with an entrypoint located in a subdirectory (e.g., server/server.py), the Docker build fails during CodeBuild with the error "/server": not found. The root cause is that the generated Dockerfile attempts to COPY a subdirectory that doesn't exist in the Docker build context.
Environment
- Tool:
bedrock-agentcore-starter-toolkit(viauv run agentcore) - Platform: Windows
- Deployment Type: Container
Steps to Reproduce
- Create a parent project with agentcore:
uv init --bare
uv add bedrock-agentcore-starter-toolkit- Create a subdirectory for the deployable:
mkdir server && cd server
uv init --bare --no-workspace
uv add mcp- Create a simple MCP server (
server/server.py):
from mcp.server.fastmcp import FastMCP
mcp = FastMCP(name="EchoServer", stateless_http=True)
def main():
mcp.run(transport="streamable-http")
if __name__ == "__main__":
main()- Return to parent directory and configure agentcore:
cd ..
uv run agentcore configure \
--entrypoint server/server.py \
--requirements-file server/pyproject.toml \
--non-interactive --disable-memory --disable-otel \
--name test_server --protocol MCP \
--deployment-type container- Launch the agent:
uv run agentcore launch --agent test_serverExpected Behavior
The CodeBuild project should succeed and the container should be deployed to ECR.
Actual Behavior
The tookit fails with:
🔄 COMPLETED started (total: 12s)
⠋ Launching Bedrock AgentCore...❌ Build failed during COMPLETED phase
❌ CodeBuild failed with status: FAILED
The CodeBuild project fails with:
#6 ERROR: failed to calculate checksum of ref 3dbb0167-26e0-4aa8-afd6-f9e595d75983::wes51ujh9l3i1ahked3byxdc7: "/server": not found
...
------
> [3/6] COPY server server:
------
Dockerfile:15
--------------------
13 \|
14 \|
15 \| >>> COPY server server
16 \| # Install from pyproject.toml directory
17 \| RUN cd server && uv pip install .
--------------------
ERROR: failed to build: failed to solve: failed to compute cache key: failed to calculate checksum of ref 3dbb0167-26e0-4aa8-afd6-f9e595d75983::wes51ujh9l3i1ahked3byxdc7: "/server": not found
Docker build failed
Root Cause Analysis
The issue occurs because of a mismatch between the Docker build context and the Dockerfile's COPY instruction:
-
Build Context: When
agentcoredetects the entrypoint is in a subdirectory (server/server.py), it setssource_pathto the subdirectory:source_path: C:\Users\traubd\code\GitHub\code\examples\temp\server
-
Dockerfile Generation: The generated Dockerfile attempts to copy the subdirectory relative to the build context:
COPY server server RUN cd server && uv pip install .
-
The Problem: Since the build context is already set to the
serverdirectory, there is noserversubdirectory to copy. The Dockerfile is trying to copyserver/serverwhich doesn't exist.
Proposed Solution
When the source_path is set to a subdirectory, the Dockerfile should copy from the current directory (.) instead of trying to copy a subdirectory that doesn't exist in the build context.
The Dockerfile generation logic should be updated to:
- Detect when
source_pathpoints to a subdirectory - Generate
COPY . .(or copy specific files) instead ofCOPY <subdirectory> <subdirectory> - Adjust the
RUNcommand to install from the current directory:RUN uv pip install .
Example corrected Dockerfile:
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim
WORKDIR /app
ENV UV_SYSTEM_PYTHON=1 \
UV_COMPILE_BYTECODE=1 \
UV_NO_PROGRESS=1 \
PYTHONUNBUFFERED=1 \
DOCKER_CONTAINER=1
# Copy and install from current directory (which is already the server directory)
COPY . .
RUN uv pip install .
# Create non-root user
RUN useradd -m -u 1000 bedrock_agentcore
USER bedrock_agentcore
EXPOSE 9000 8000 8080
CMD ["python", "-m", "server"]Workaround
Currently, users must place their files in the root directory of the project rather than in a subdirectory.
Additional Context
This issue affects common project structures where developers organize their code into subdirectories (e.g., server/, src/, app/) rather than placing everything in the root directory.