-
Notifications
You must be signed in to change notification settings - Fork 60
/
Copy pathDockerfile.echo.alpine
68 lines (58 loc) · 2.09 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 FUNCTION_DIR="/home/app/"
ARG RUNTIME_VERSION
ARG DISTRO_VERSION
# Stage 1 - build function and dependencies
FROM node:${RUNTIME_VERSION}-alpine${DISTRO_VERSION} AS build-image
# Include global arg in this stage of the build
ARG DISTRO_VERSION
# Install aws-lambda-cpp build dependencies
RUN apk add --update-cache \
build-base \
libtool \
musl-dev \
libressl-dev \
libffi-dev \
autoconf \
automake \
make \
cmake \
python3 \
libcurl
# AWS Lambda CPP and libcurl rely on backtrace which requires libexecinfo from Alpine.
# Since starting from Alpine3.17 libexecinfo is no longer available, temporarily source it from Alpine3.16
# while awaiting an upstream resolution in AWS Lambda CPP.
RUN if [[ "${DISTRO_VERSION}" == "3.17" ]] || [[ "${DISTRO_VERSION}" == "3.18" ]] ; \
then \
apk add --update-cache --repository=https://dl-cdn.alpinelinux.org/alpine/v3.16/main/ libexecinfo-dev ; \
else \
apk add --update-cache libexecinfo-dev ; \
fi
# Include global arg in this stage of the build
ARG FUNCTION_DIR
# Create function directory
RUN mkdir -p ${FUNCTION_DIR}
# Copy & build Runtime Interface Client package (as we're installing it from a local filesystem source)
WORKDIR ${FUNCTION_DIR}/deps/aws-lambda-ric
COPY . .
RUN make build && \
npm run test:unit
# Copy function code
COPY test/integration/test-handlers/echo/* ${FUNCTION_DIR}
# Install the function's dependencies
WORKDIR ${FUNCTION_DIR}
RUN npm install
# Stage 2 - final runtime image
# Grab a fresh copy of the Node image
FROM node:${RUNTIME_VERSION}-alpine${DISTRO_VERSION}
# Required for Node runtimes which use [email protected]+ because
# by default npm writes logs under /home/.npm and Lambda fs is read-only
ENV NPM_CONFIG_CACHE=/tmp/.npm
# 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}
ENTRYPOINT [ "/usr/local/bin/npx", "aws-lambda-ric" ]
CMD [ "index.handler" ]