-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: manage packages in Dockerfile with uv instead of poetry
- Loading branch information
1 parent
2783345
commit ee3d5d1
Showing
3 changed files
with
70 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,34 @@ | ||
FROM python:3.13.0-slim-bullseye AS builder | ||
FROM ghcr.io/astral-sh/uv:0.5.14 AS uv | ||
|
||
# Install the same version of Poetry as inside the dev container | ||
RUN pip install --no-cache-dir poetry==1.8.3 | ||
# First, bundle the dependencies into the task root. | ||
FROM public.ecr.aws/lambda/python:3.11 AS builder | ||
|
||
# Enable bytecode compilation, to improve cold-start performance. | ||
ENV UV_COMPILE_BYTECODE=1 | ||
|
||
# Disable installer metadata, to create a deterministic layer. | ||
ENV UV_NO_INSTALLER_METADATA=1 | ||
|
||
# Enable copy mode to support bind mount caching. | ||
ENV UV_LINK_MODE=copy | ||
|
||
# Copy uv binary | ||
COPY --from=uv /uv /bin/uv | ||
|
||
# Copy dependency files | ||
WORKDIR /app | ||
COPY pyproject.toml poetry.lock ./ | ||
RUN poetry export --without-hashes --format=requirements.txt > requirements.txt | ||
COPY uv.lock pyproject.toml ./ | ||
|
||
# Generate requirements.txt and install dependencies | ||
RUN uv export --frozen --no-emit-workspace --no-dev --no-editable -o requirements.txt && \ | ||
uv pip install -r requirements.txt --target "${LAMBDA_TASK_ROOT}" | ||
|
||
FROM public.ecr.aws/lambda/python:3.13 | ||
FROM public.ecr.aws/lambda/python:3.11 | ||
|
||
COPY --from=builder /app/requirements.txt ${LAMBDA_TASK_ROOT}/ | ||
COPY openchallenges_data_lambda/app.py ${LAMBDA_TASK_ROOT}/ | ||
# Copy the runtime dependencies from the builder stage. | ||
COPY --from=builder ${LAMBDA_TASK_ROOT} ${LAMBDA_TASK_ROOT} | ||
|
||
RUN python3.13 -m pip install --no-cache-dir -r requirements.txt -t . | ||
# Copy the application code. | ||
COPY openchallenges_data_lambda/app.py ${LAMBDA_TASK_ROOT}/app | ||
|
||
# Command can be overwritten by providing a different command in the template directly. | ||
CMD ["app.lambda_handler"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.