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

Apache License 2.0
179 stars 56 forks source link

`preinstall.sh` script hangs when running `docker build --platform linux/amd64` #107

Closed aydangoon closed 5 months ago

aydangoon commented 5 months ago

tsia, docker build hangs at RUN npm install aws-lambda-ric --verbose. When i remove the platform flag it builds.

Here is my entire dockerfile:

# =================================== BUILD STAGE 1 ===================================

FROM node:20-buster AS build-image

# install aws-lambda-cpp build dependencies
RUN apt-get update && \
    apt-get install -y \
    g++ \
    make \
    cmake \
    unzip \
    libcurl4-openssl-dev

# define function directory
ARG FUNCTION_DIR="/function"

# create function directory in container
RUN mkdir -p ${FUNCTION_DIR}

# set working directory
WORKDIR ${FUNCTION_DIR}

# copy function code over
COPY . ${FUNCTION_DIR}

# install dependencies, aws lambda runtime interface client, and typescript
RUN npm cache clean --force
RUN npm install --verbose
# https://github.com/aws/aws-lambda-nodejs-runtime-interface-client/issues/77#issuecomment-1717599421
RUN npm install aws-lambda-ric--verbose 
RUN npm install -g typescript --verbose

# compile typescript
RUN npm run build

# =================================== BUILD STAGE 2 ===================================

# get a cleaner, smaller image
FROM node:20-buster-slim

# include global arg in this stage
ARG FUNCTION_DIR

# copy over the build artifacts from the previous stage
COPY --from=build-image ${FUNCTION_DIR} ${FUNCTION_DIR}

# Required for Node runtimes which use npm@8.6.0+ because
# by default npm writes logs under /home/.npm and Lambda fs is read-only
ENV NPM_CONFIG_CACHE=/tmp/.npm

# set npx and aws-lambda-ric wrapper as default executable
ENTRYPOINT [ "/usr/local/bin/npx", "aws-lambda-ric" ]

# run the function
CMD [ "dist/aws-lambda/index.handler" ]