-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
35 additions
and
12 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,16 +1,40 @@ | ||
FROM public.ecr.aws/lambda/python:3.12 | ||
ARG LAMBDA_TASK_ROOT="/var/task" | ||
|
||
# Install git | ||
RUN microdnf install git -y | ||
# Use the official Playwright Docker image as the base image, make sure the version matches the one you are using in your project | ||
FROM mcr.microsoft.com/playwright/python:v1.41.0-jammy as build-image | ||
|
||
# Copy requirements.txt | ||
COPY requirements.txt ${LAMBDA_TASK_ROOT} | ||
# Re-declare ARG so it's available in this stage | ||
ARG LAMBDA_TASK_ROOT | ||
RUN mkdir -p ${LAMBDA_TASK_ROOT} | ||
WORKDIR ${LAMBDA_TASK_ROOT} | ||
|
||
# Install aws-lambda-cpp build dependencies | ||
RUN apt-get update && apt-get install -y g++ make cmake unzip libcurl4-openssl-dev | ||
|
||
# Install the runtime interface client | ||
RUN pip install --target ${LAMBDA_TASK_ROOT} awslambdaric | ||
|
||
# ==== MULTI STAGE BUILD ==== | ||
|
||
# Use multi-stage build, to keep the final image cleaner | ||
FROM mcr.microsoft.com/playwright/python:v1.41.0-jammy | ||
|
||
# Re-declare ARG so it's available in this stage | ||
ARG LAMBDA_TASK_ROOT | ||
WORKDIR ${LAMBDA_TASK_ROOT} | ||
|
||
# Copy in the build image dependencies | ||
COPY --from=build-image ${LAMBDA_TASK_ROOT} ${LAMBDA_TASK_ROOT} | ||
|
||
# Get the project dependencies | ||
COPY requirements.txt ${LAMBDA_TASK_ROOT}/requirements.txt | ||
|
||
# Install the specified packages | ||
RUN pip install -r requirements.txt | ||
RUN playwright install --with-deps webkit | ||
RUN pip install -r ${LAMBDA_TASK_ROOT}/requirements.txt | ||
|
||
# Copy function code | ||
COPY . ${LAMBDA_TASK_ROOT} | ||
# Create function directory and copy the function code into it | ||
COPY ./src ./ | ||
|
||
ENV GOOGLE_APPLICATION_CREDENTIALS gcp_config.json | ||
# Considering your handler function is called lambda_handler in app.py | ||
ENTRYPOINT [ "/usr/bin/python", "-m", "awslambdaric" ] | ||
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