-
Notifications
You must be signed in to change notification settings - Fork 79
/
Copy pathDockerfile.echo.alpine
68 lines (58 loc) · 2.11 KB
/
Dockerfile.echo.alpine
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
63
64
65
66
67
68
# Define global args
ARG RUNTIME_VERSION
ARG DISTRO_VERSION
# Stage 1 - bundle base image + runtime interface client
# Grab a fresh copy of the image and install GCC
FROM public.ecr.aws/docker/library/python:${RUNTIME_VERSION}-alpine${DISTRO_VERSION} AS python-alpine
# Install libstdc++
RUN apk add --no-cache \
libstdc++
# https://github.com/aws/aws-lambda-python-runtime-interface-client/issues/144
RUN echo https://dl-cdn.alpinelinux.org/alpine/v3.19/main >> /etc/apk/repositories
RUN echo https://dl-cdn.alpinelinux.org/alpine/v3.19/community >> /etc/apk/repositories
# Stage 2 - build function and dependencies
FROM python-alpine AS build-image
# Install aws-lambda-cpp build dependencies
RUN apk add --no-cache \
build-base \
libtool \
autoconf=2.71-r2 \
automake \
elfutils-dev \
make \
cmake \
libcurl
# Include global args in this stage of the build
ARG RIC_BUILD_DIR="/home/build/"
# Create function directory
RUN mkdir -p ${RIC_BUILD_DIR}
# Copy function code and Runtime Interface Client .tgz
WORKDIR ${RIC_BUILD_DIR}
COPY . .
RUN make init build test && \
mv ./dist/awslambdaric-*.tar.gz ./dist/awslambdaric-test.tar.gz
# Include global args in this stage of the build
ARG FUNCTION_DIR="/home/app/"
# Create function directory
RUN mkdir -p ${FUNCTION_DIR}
# Copy function code
COPY tests/integration/test-handlers/echo/* ${FUNCTION_DIR}
# Copy Runtime Interface Client .tgz
RUN cp ./dist/awslambdaric-test.tar.gz ${FUNCTION_DIR}/awslambdaric-test.tar.gz
# Install the function's dependencies
WORKDIR ${FUNCTION_DIR}
RUN python${RUNTIME_VERSION} -m pip install \
awslambdaric-test.tar.gz \
--target ${FUNCTION_DIR} && \
rm awslambdaric-test.tar.gz
# Stage 3 - final runtime interface client image
# Grab a fresh copy of the Python image
FROM python-alpine
# Include global arg in this stage of the build
ARG FUNCTION_DIR="/home/app/"
# Set working directory to function root directory
WORKDIR ${FUNCTION_DIR}
# Copy in the built dependencies
COPY --from=build-image ${FUNCTION_DIR} ${FUNCTION_DIR}
ENTRYPOINT [ "/usr/local/bin/python", "-m", "awslambdaric" ]
CMD [ "app.handler" ]