Skip to content

Instantly share code, notes, and snippets.

@vatsalsaglani
Created June 6, 2022 07:08
Show Gist options
  • Save vatsalsaglani/8bb6761ed373ad05277b9833cad96c34 to your computer and use it in GitHub Desktop.
Save vatsalsaglani/8bb6761ed373ad05277b9833cad96c34 to your computer and use it in GitHub Desktop.
Dockerfile and requirements for Lambda OpenCV
# Define function directory
ARG FUNCTION_DIR="/function"
FROM python:3.7 as build-image
RUN apt-get update
RUN apt-get install -y
# RUN apt install python3-opencv -y
RUN apt install curl -y
# Include global arg in this stage of the build
ARG FUNCTION_DIR
# Create function directory
RUN mkdir -p ${FUNCTION_DIR}
# RUN mkdir -p /tmp/input-images
# RUN mkdir -p /tmp/output-images
RUN mkdir -p ${FUNCTION_DIR}/popular-memes
COPY ./*.py ${FUNCTION_DIR}
COPY ./popular-memes/*.png ${FUNCTION_DIR}/popular-memes
COPY ./requirements.txt ${FUNCTION_DIR}
RUN curl -L https://vs-bucket-allthings.s3.us-east-2.amazonaws.com/antelope.tar.gz -o ${FUNCTION_DIR}/antelope.tar.gz && tar xvzf ${FUNCTION_DIR}/antelope.tar.gz -C ${FUNCTION_DIR}/
RUN rm ${FUNCTION_DIR}/antelope.tar.gz
RUN curl -L https://vs-bucket-allthings.s3.us-east-2.amazonaws.com/arcface_checkpoint.tar -o ${FUNCTION_DIR}/arcface_checkpoint.tar
RUN curl -L https://vs-bucket-allthings.s3.us-east-2.amazonaws.com/checkpoints.tar.gz -o ${FUNCTION_DIR}/checkpoints.tar.gz && tar xvzf ${FUNCTION_DIR}/checkpoints.tar.gz -C ${FUNCTION_DIR}/
RUN rm ${FUNCTION_DIR}/checkpoints.tar.gz
RUN ls ${FUNCTION_DIR}
RUN pip install -r ${FUNCTION_DIR}/requirements.txt --target ${FUNCTION_DIR} awslambdaric
FROM python:3.7
ARG FUNCTION_DIR
WORKDIR ${FUNCTION_DIR}
COPY --from=build-image ${FUNCTION_DIR} ${FUNCTION_DIR}
ENTRYPOINT [ "/usr/local/bin/python", "-m", "awslambdaric" ]
CMD ["app.handler"]
# Flask
Pillow
torch
torchvision
opencv-python-headless
insightface==0.2.1
onnxruntime
moviepy
imageio==2.4.1
# flask_cors
requests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment