aws / aws-lambda-nodejs-runtime-interface-client

Apache License 2.0
180 stars 56 forks source link

RIC and Distroless base images #21

Closed seano-vs closed 3 years ago

seano-vs commented 3 years ago

Hey everyone- Really enjoying all of this so far. I have this working just fine with the Python RIC, but running into a few issues with trying to get it to execute on distroless/nodejs:14 as the final base image. Does anyone have a suggested best practice for executing the RIC without npx? Here is my Dockerfile thus far:

ARG FUNCTION_DIR="/function"
FROM node:14-buster as build-image
ARG FUNCTION_DIR
RUN apt-get update && \
    apt-get install -y \
    g++ \
    make \
    cmake \
    unzip \
    libcurl4-openssl-dev
RUN mkdir -p ${FUNCTION_DIR}
COPY * ${FUNCTION_DIR}
WORKDIR ${FUNCTION_DIR}
RUN npm install

FROM gcr.io/distroless/nodejs:14
ARG FUNCTION_DIR
WORKDIR ${FUNCTION_DIR}
COPY --from=build-image ${FUNCTION_DIR} ${FUNCTION_DIR}
# Naturally, the below doesn't work. 
ENTRYPOINT ["/usr/local/bin/npx", "aws-lambda-ric"]
CMD ["app.handler"]

Any ideas? For obvious reasons, any attempts at having the npx binary play ball are unsuccessful.