_build_in_container¶
Container-side Lambda layer build script (pure stdlib, Python 3.11+).
This script runs inside the Docker container launched by
UvLambdaLayerContainerBuilder.
No third-party packages are needed — only uv (installed at runtime).
Why pure stdlib? This script is copied into a bare AWS SAM Docker image
that has nothing pre-installed except Python itself. If we imported any
third-party library here, we would have to install it inside the container
first, adding complexity and build time. Keeping this script stdlib-only
means the only external tool we need to fetch is uv.
The host mounts {project_root}/build/lambda/layer/ → /var/task/.
Layout inside the container:
/var/task/ ← mount point
├── build_lambda_layer_in_container.py ← this script (renamed copy)
├── private-repository-credentials.json ← optional credentials
└── repo/
├── pyproject.toml
├── uv.lock
└── .venv/ ← created by uv sync
The host-side step 4 moves repo/.venv/lib/pythonX.Y/site-packages/
into artifacts/python/ after the container exits.
See docs/source/99-Maintainer-Guide/03-Build-Lambda-Layer-using-UV-in-Container
for the full architecture guide.