-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
62 lines (50 loc) · 2 KB
/
Dockerfile
File metadata and controls
62 lines (50 loc) · 2 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
57
58
59
60
61
62
#_copyright_ = "Copyright 2024, VISA Lab"
#_license_ = "MIT"
# Define global args
ARG FUNCTION_DIR="/home/app/"
ARG RUNTIME_VERSION="3.8"
ARG DISTRO_VERSION="3.12"
FROM alpine:latest
FROM python:${RUNTIME_VERSION}-slim AS python-alpine
#RUN apt-get update \
# && apt-get install -y cmake ca-certificates libgl1-mesa-glx
RUN python${RUNTIME_VERSION} -m pip install --upgrade pip
FROM python-alpine AS build-image
# Include global args in this stage of the build
ARG FUNCTION_DIR
ARG RUNTIME_VERSION
# Create function directory
RUN mkdir -p ${FUNCTION_DIR}
# Install Lambda Runtime Interface Client for Python
RUN python${RUNTIME_VERSION} -m pip install awslambdaric --target ${FUNCTION_DIR}
# Stage 3 - final runtime image
# Grab a fresh copy of the Python image
FROM python-alpine
# Include global arg in this stage of the build
ARG FUNCTION_DIR
# Set working directory to function root directory
WORKDIR ${FUNCTION_DIR}
# Copy in the built dependencies
COPY --from=build-image ${FUNCTION_DIR} ${FUNCTION_DIR}
# (Optional) Add Lambda Runtime Interface Emulator and use a script in the ENTRYPOINT for simpler local runs
ADD https://github.com/aws/aws-lambda-runtime-interface-emulator/releases/latest/download/aws-lambda-rie /usr/bin/aws-lambda-rie
RUN chmod 755 /usr/bin/aws-lambda-rie
# Install ffmpeg
RUN apt-get update
RUN apt-get install -y ffmpeg
#RUN apk --no-cache add ffmpeg
# Copy handler function
COPY requirements.txt ${FUNCTION_DIR}
#COPY ffmpeg ${FUNCTION_DIR}
#COPY ffmpeg /usr/bin
RUN python${RUNTIME_VERSION} -m pip install -r requirements.txt --target ${FUNCTION_DIR}
RUN python${RUNTIME_VERSION} -m pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
RUN python${RUNTIME_VERSION} -m pip install facenet-pytorch
COPY entry.sh /
# Copy function code
COPY handler.py ${FUNCTION_DIR}
RUN chmod 777 /entry.sh
ENV TORCH_HOME=/tmp
# Set the CMD to your handler (could also be done as a parameter override outside of the Dockerfile)
ENTRYPOINT [ "/entry.sh" ]
CMD [ "handler.handler" ]