-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
56 lines (44 loc) · 1.7 KB
/
Dockerfile
File metadata and controls
56 lines (44 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
########################################################
# Stage 1: Install dependencies with uv and copy to /opt/python
########################################################
FROM python:3.12-slim AS deps
# Avoid prompts & keep images small
ENV PIP_DISABLE_PIP_VERSION_CHECK=1 \
PIP_NO_CACHE_DIR=1
ARG APP_ROOT="/app"
WORKDIR ${APP_ROOT}
# Bring in lockfiles first for better caching
COPY pyproject.toml ${APP_ROOT}/
COPY uv.lock ${APP_ROOT}/
# Install uv and create a local venv, then sync (no dev deps)
RUN pip install --no-cache-dir uv
RUN uv sync --no-group dev --frozen
# Materialize a Lambda-style "layer" dir with only runtime packages
# (Lambda adds /opt/python to sys.path automatically)
RUN mkdir -p /opt/python
RUN cp -a ${APP_ROOT}/.venv/lib/python3.12/site-packages/. /opt/python/
########################################################
# Stage 2: Create final AWS Lambda image
########################################################
#FROM public.ecr.aws/lambda/python:3.12-arm64
FROM public.ecr.aws/lambda/python:3.12
ARG APP_NAME
ARG APP_VERSION
ARG COMMIT_SHA
ARG BRANCH
ARG BUILD_DATE
ENV APP_NAME="${APP_NAME}"
ENV APP_VERSION="${APP_VERSION}"
ENV COMMIT_SHA="${COMMIT_SHA}"
ENV BRANCH="${BRANCH}"
ENV BUILD_DATE="${BUILD_DATE}"
LABEL org.opencontainers.image.name="${APP_NAME}" \
org.opencontainers.image.version="${APP_VERSION}" \
org.opencontainers.image.revision="${COMMIT_SHA}" \
org.opencontainers.image.ref.branch="${BRANCH}" \
org.opencontainers.image.created="${BUILD_DATE}"
# This image automatically adds packages in /opt/python to sys.path
COPY --from=deps /opt/python /opt/python
COPY src/ ${LAMBDA_TASK_ROOT}/
ENV _HANDLER="main.handler"
CMD ["main.handler"]