Skip to content

Commit

Permalink
Try microsoft base img
Browse files Browse the repository at this point in the history
  • Loading branch information
stuart23 committed Nov 10, 2024
1 parent 52f0902 commit 3159eaf
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 12 deletions.
44 changes: 34 additions & 10 deletions image/Dockerfile
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" ]
3 changes: 1 addition & 2 deletions image/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ Jinja2
jinja2-time
google-api-python-client
google-auth-httplib2
google-auth-oauthlib
playwright
google-auth-oauthlib

0 comments on commit 3159eaf

Please sign in to comment.