Reputation: 151
I have been struggling with creating a dockerFile from node:16-alpine base image for AWS Lambda. Anything I find on the internet is outdated and I am stuck. Any help would be appreciated at this stage.
Here is my current dockerfile:
ARG FUNCTION_DIR="/app"
#*****************************************************************************
# Builder Stage
#****************************************************************************/
FROM node:16-alpine AS base
# Include global arg in this stage of the build
ARG FUNCTION_DIR
# The working directory is where "npm install" created the node_modules folder.
WORKDIR ${FUNCTION_DIR}
# Install aws-lambda-cpp build dependencies. aws-lambda-cpp is used by aws-lambda-ric which is a
# node-gyp compiled dependency. Find it in package.json.
# See the Node.js example at https://github.com/aws/aws-lambda-nodejs-runtime-interface-client
RUN apk add --no-cache \
libstdc++ \
build-base \
libtool \
autoconf \
automake \
elfutils-dev \
make \
cmake \
libcurl \
python3
# Copy dependencies
COPY package*.json ./
# Install the AWS Lambda Runtime Interface Client (RIC) that is only required within this Docker container (not in package.json on development machine).
# It helps AWS to run the Lambda function code that autoiXpert provides.
RUN npm install
RUN npm install aws-lambda-ric
RUN npm prune --production
RUN npm ci
COPY src/main ./
RUN npm run docker-build
#*****************************************************************************
# Production Stage
#****************************************************************************/
FROM node:16-alpine
# Include global arg in this stage of the build
ARG FUNCTION_DIR
# The working directory is where "npm install" created the node_modules folder.
WORKDIR ${FUNCTION_DIR}
COPY --from=base app/dist ${LAMBDA_TASK_ROOT}
ENTRYPOINT ["/usr/local/bin/npx", "aws-lambda-ric"]
CMD [ "app.lambdaHandler" ]
When I run "docker build ." This is the error I get on the line of "RUN npm install aws-lambda-ric":
#16 424.3 npm ERR! /usr/bin/install -c -m 644 libcurl-multi.3 libcurl-security.3 libcurl-share.3 libcurl-symbols.3 libcurl-thread.3 libcurl-tutorial.3 libcurl-url.3 libcurl.3 '/app/node_modules/aws-lambda-ric/deps/artifacts/share/man/man3'
#16 424.3 npm ERR! make[6]: Leaving directory '/app/node_modules/aws-lambda-ric/deps/curl-curl-7_83_1/docs/libcurl'
#16 424.3 npm ERR! make[5]: Leaving directory '/app/node_modules/aws-lambda-ric/deps/curl-curl-7_83_1/docs/libcurl'
#16 424.3 npm ERR! make[4]: Leaving directory '/app/node_modules/aws-lambda-ric/deps/curl-curl-7_83_1/docs/libcurl'
#16 424.3 npm ERR! make[3]: Leaving directory '/app/node_modules/aws-lambda-ric/deps/curl-curl-7_83_1'
#16 424.3 npm ERR! make[2]: Leaving directory '/app/node_modules/aws-lambda-ric/deps/curl-curl-7_83_1'
#16 424.3 npm ERR! make[1]: Leaving directory '/app/node_modules/aws-lambda-ric/deps/curl-curl-7_83_1'
#16 424.3 npm ERR! -- The CXX compiler identification is GNU 12.2.1
#16 424.3 npm ERR! -- Detecting CXX compiler ABI info
#16 424.3 npm ERR! -- Detecting CXX compiler ABI info - done
#16 424.3 npm ERR! -- Check for working CXX compiler: /usr/bin/c++ - skipped
#16 424.3 npm ERR! -- Detecting CXX compile features
#16 424.3 npm ERR! -- Detecting CXX compile features - done
#16 424.3 npm ERR! -- Found CURL: /app/node_modules/aws-lambda-ric/deps/artifacts/lib/libcurl.a (found version "7.83.1-DEV")
#16 424.3 npm ERR! -- Looking for backtrace
#16 424.3 npm ERR! -- Looking for backtrace - not found
#16 424.3 npm ERR! -- Configuring incomplete, errors occurred!
#16 424.3 npm ERR! *** Do not use buildconf. Instead, just use: autoreconf -fi
#16 424.3 npm ERR! configure.ac:120: installing './compile'
#16 424.3 npm ERR! configure.ac:317: installing './config.guess'
#16 424.3 npm ERR! configure.ac:317: installing './config.sub'
#16 424.3 npm ERR! configure.ac:120: installing './install-sh'
#16 424.3 npm ERR! configure.ac:125: installing './missing'
#16 424.3 npm ERR! docs/examples/Makefile.am: installing './depcomp'
#16 424.3 npm ERR! parallel-tests: installing './test-driver'
#16 424.3 npm ERR! configure: WARNING: zlib disabled
#16 424.3 npm ERR! configure: WARNING: SSL disabled, you will not be able to use HTTPS, FTPS, NTLM and more.
#16 424.3 npm ERR! configure: WARNING: Use --with-openssl, --with-gnutls, --with-wolfssl, --with-mbedtls, --with-nss, --with-schannel, --with-secure-transport, --with-amissl, --with-bearssl or --with-rustls to address this.
#16 424.3 npm ERR! configure: WARNING: libgsasl was not found
#16 424.3 npm ERR! configure: WARNING: disabling built-in manual
#16 424.3 npm ERR! CMake Error at /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
#16 424.3 npm ERR! Could NOT find Backtrace (missing: Backtrace_LIBRARY Backtrace_INCLUDE_DIR)
#16 424.3 npm ERR! Call Stack (most recent call first):
#16 424.3 npm ERR! /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
#16 424.3 npm ERR! /usr/share/cmake/Modules/FindBacktrace.cmake:90 (find_package_handle_standard_args)
#16 424.3 npm ERR! CMakeLists.txt:44 (find_package)
Is there anyone out there who can help me with this?
Thanks and regards,
Ben
Upvotes: 0
Views: 1206
Reputation: 151
I found a workaround on github (reference). "libexecinfo-dev" is a must for aws-lambda-ric. It can't be simply replaced by the "elfutils-dev" even though it's suggested in several internet forums.
Here is the workaround to import the libexecinfo-dev. It will allow you to install aws-lambda-ric:
RUN apk add --no-cache --update --repository=https://dl-cdn.alpinelinux.org/alpine/v3.16/main/ libexecinfo-dev
Upvotes: 2