-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathDockerfile
More file actions
60 lines (52 loc) · 1.78 KB
/
Dockerfile
File metadata and controls
60 lines (52 loc) · 1.78 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
# Define global args
ARG FUNCTION_DIR="/home/"
ARG RUNTIME_VERSION="3.9.6"
ARG DISTRO_VERSION="3.14"
FROM continuumio/miniconda3 AS miniconda3
# Install GCC (Alpine uses musl but we compile and link dependencies with GCC)
RUN apt-get install libstdc++ -y
# Stage 2 - build function and dependencies
FROM miniconda3 AS build-image
# Install aws-lambda-cpp build dependencies
RUN apt-get update && apt-get upgrade -y && apt-get install -y \
build-essential \
libtool \
autoconf \
automake \
make \
cmake \
libcurl4
# Install libgomp for lightgbm
RUN conda install -c conda-forge libgomp -y
# Include global args in this stage of the build
ARG FUNCTION_DIR
ARG RUNTIME_VERSION
# Create function directory
RUN mkdir -p ${FUNCTION_DIR}/app
# Copy handler function
COPY app/ ${FUNCTION_DIR}/app
# Optional – Install the function's dependencies
WORKDIR ${FUNCTION_DIR}
# Install Lambda Runtime Interface Client for Python
RUN python -m pip install awslambdaric --target ${FUNCTION_DIR}
# Stage 3 - final runtime image
# Grab a fresh copy of the Python image
FROM miniconda3
RUN apt-get update && apt-get upgrade -y
# 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
# Install Python Libraries for Model
COPY install_requirements.sh /home/app/
RUN chmod 755 /home/app/install_requirements.sh
RUN /home/app/install_requirements.sh
RUN python -m spacy download en_core_web_lg
COPY entry.sh /home/
RUN chmod 755 /home/entry.sh
ENTRYPOINT [ "/home/entry.sh" ]
RUN python -m app.main
CMD [ "app.main.handler" ]