Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installation fails with compilation error #29

Open
cmil opened this issue Jun 21, 2021 · 2 comments
Open

Installation fails with compilation error #29

cmil opened this issue Jun 21, 2021 · 2 comments

Comments

@cmil
Copy link

cmil commented Jun 21, 2021

When trying to install aws-lambda-ric on a recent Alpine Linux with the following Dockerfile

FROM alpine:3.14

ARG FUNCTION_DIR="/function"

RUN apk add g++ make cmake unzip libtool curl-dev automake autoconf nodejs npm

WORKDIR ${FUNCTION_DIR}
RUN npm install aws-lambda-ric

a docker run exits with the following error messages in the end:

#7 82.55 npm ERR! -- The CXX compiler identification is GNU 10.3.1
#7 82.55 npm ERR! -- Detecting CXX compiler ABI info
#7 82.55 npm ERR! -- Detecting CXX compiler ABI info - done
#7 82.55 npm ERR! -- Check for working CXX compiler: /usr/bin/c++ - skipped
#7 82.55 npm ERR! -- Detecting CXX compile features
#7 82.55 npm ERR! -- Detecting CXX compile features - done
#7 82.55 npm ERR! -- Found CURL: /usr/lib/libcurl.so (found version "7.77.0")  
#7 82.55 npm ERR! -- Configuring done
#7 82.55 npm ERR! -- Generating done
#7 82.55 npm ERR! -- Build files have been written to: /function/node_modules/aws-lambda-ric/deps/aws-lambda-cpp-0.2.6/build
#7 82.55 npm ERR! [ 20%] Building CXX object CMakeFiles/aws-lambda-runtime.dir/src/logging.cpp.o
#7 82.55 npm ERR! [ 40%] Building CXX object CMakeFiles/aws-lambda-runtime.dir/src/runtime.cpp.o
#7 82.55 npm ERR! [ 60%] Building CXX object CMakeFiles/aws-lambda-runtime.dir/src/backward.cpp.o
#7 82.55 npm ERR! *** Do not use buildconf. Instead, just use: autoreconf -fi
#7 82.55 npm ERR! configure.ac:120: installing './compile'
#7 82.55 npm ERR! configure.ac:125: installing './missing'
#7 82.55 npm ERR! docs/examples/Makefile.am: installing './depcomp'
#7 82.55 npm ERR! ./configure: line 1: /usr/bin/file: not found
#7 82.55 npm ERR! configure: WARNING: zlib disabled
#7 82.55 npm ERR! configure: WARNING: Cannot find libraries for LDAP support: LDAP disabled
#7 82.55 npm ERR! configure: WARNING: SSL disabled, you will not be able to use HTTPS, FTPS, NTLM and more.
#7 82.55 npm ERR! configure: WARNING: Use --with-openssl, --with-gnutls, --with-wolfssl, --with-mbedtls, --with-nss, --with-schannel, --with-secure-transport, --with-mesalink, --with-amissl, --with-bearssl or --with-rustls to address this.
#7 82.55 npm ERR! configure: WARNING: libpsl was not found
#7 82.55 npm ERR! configure: WARNING: libgsasl was not found
#7 82.55 npm ERR! configure: WARNING: Cannot find libraries for IDN support: IDN disabled
#7 82.55 npm ERR! configure: WARNING: disabling built-in manual
#7 82.55 npm ERR! In file included from /function/node_modules/aws-lambda-ric/deps/aws-lambda-cpp-0.2.6/src/backward.cpp:26:
#7 82.55 npm ERR! /function/node_modules/aws-lambda-ric/deps/aws-lambda-cpp-0.2.6/include/backward.h:238:22: fatal error: execinfo.h: No such file or directory
#7 82.55 npm ERR!   238 | #            include <execinfo.h>
#7 82.55 npm ERR!       |                      ^~~~~~~~~~~~
#7 82.55 npm ERR! compilation terminated.
#7 82.55 npm ERR! make[2]: *** [CMakeFiles/aws-lambda-runtime.dir/build.make:104: CMakeFiles/aws-lambda-runtime.dir/src/backward.cpp.o] Error 1
#7 82.55 npm ERR! make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/aws-lambda-runtime.dir/all] Error 2
#7 82.55 npm ERR! make: *** [Makefile:136: all] Error 2
#7 82.61 
#7 82.61 npm ERR! A complete log of this run can be found in:
#7 82.61 npm ERR!     /root/.npm/_logs/2021-06-21T12_32_55_474Z-debug.log
------
executor failed running [/bin/sh -c npm install aws-lambda-ric]: exit code: 2

Also see awslabs/aws-lambda-cpp#124.

@GusBuonv
Copy link

GusBuonv commented Jun 23, 2021

Adding libexecinfo-dev to the apk package add list resolves this error and gets the build process through preinstall and install. However, I then received the following error on postinstall:

> aws-lambda-ric@1.1.0 postinstall /home/node/node_modules/aws-lambda-ric
> ./scripts/postinstall.sh


> aws-lambda-ric@1.1.0 build:gyp /home/node/node_modules/aws-lambda-ric
> node-gyp rebuild

gyp ERR! find Python 
gyp ERR! find Python Python is not set from command line or npm configuration
gyp ERR! find Python Python is not set from environment variable PYTHON
gyp ERR! find Python checking if "python" can be used
gyp ERR! find Python - "python" is not in PATH or produced an error
gyp ERR! find Python checking if "python2" can be used
gyp ERR! find Python - "python2" is not in PATH or produced an error
gyp ERR! find Python checking if "python3" can be used
gyp ERR! find Python - "python3" is not in PATH or produced an error
gyp ERR! find Python 
gyp ERR! find Python **********************************************************
gyp ERR! find Python You need to install the latest version of Python.
gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
gyp ERR! find Python you can try one of the following options:
gyp ERR! find Python - Use the switch --python="/path/to/pythonexecutable"
gyp ERR! find Python   (accepted by both node-gyp and npm)
gyp ERR! find Python - Set the environment variable PYTHON
gyp ERR! find Python - Set the npm configuration variable python:
gyp ERR! find Python   npm config set python "/path/to/pythonexecutable"
gyp ERR! find Python For more information consult the documentation at:
gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
gyp ERR! find Python **********************************************************
gyp ERR! find Python 
gyp ERR! configure error 
gyp ERR! stack Error: Could not find any Python installation to use
gyp ERR! stack     at PythonFinder.fail (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:307:47)
gyp ERR! stack     at PythonFinder.runChecks (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:136:21)
gyp ERR! stack     at PythonFinder.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:179:16)
gyp ERR! stack     at PythonFinder.execFileCallback (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:271:16)
gyp ERR! stack     at exithandler (child_process.js:326:5)
gyp ERR! stack     at ChildProcess.errorhandler (child_process.js:338:5)
gyp ERR! stack     at ChildProcess.emit (events.js:375:28)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
gyp ERR! stack     at onErrorNT (internal/child_process.js:467:16)
gyp ERR! stack     at processTicksAndRejections (internal/process/task_queues.js:82:21)
gyp ERR! System Linux 5.4.0-74-generic
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"

Is Python actually required for the install?

EDIT: Python does seem to be an additional, unlisted dependency. Adding python3 to apk add resolves this final error and allows a successful build. Tested invoking while running the function on local RIE, and my function was successfully called.

This appears to be related to #12. While it isn't reasonable to expect every dependency on every OS to be listed, python is a large, critical dependency that should definitely be listed.

@coding-bunny
Copy link

I'm running into similar problems with trying to manually build a Lambda container on Ubuntu:

#12 25.26 configure: WARNING: SSL disabled, you will not be able to use HTTPS, FTPS, NTLM and more.
#12 25.26 configure: WARNING: Use --with-openssl, --with-gnutls, --with-wolfssl, --with-mbedtls, --with-nss, --with-schannel, --with-secure-transport, --with-mesalink, --with-amissl, --with-bearssl or --with-rustls to address this.
#12 25.26 checking for library containing psl_builtin... no

And I have all dependencies installed:

RUN apt update && \
    apt install -y build-essential make cmake autoconf automake libtool m4 python3 unzip libssl-dev libcurl4-openssl-dev && \
    apt clean && \
    rm -rf /tmp/* /var/lib/apt/lists/*

The compilation works when installing this, but a lot of the features like SSL etc are disabled because the scripts and cmake apparently cannot find the required libraries.

On the final image, I can see SSL installed however:

app@d528ea733c3b:/app$ openssl version
OpenSSL 1.1.1f  31 Mar 2020

So, can we get some feedback from AWS here on how to properly install this?
This is my entire Dockerfile:

# Custom Ink NodeJS Lambda Container Image
#
# This Dockerfile builds the Lambda runtime container for Ruby, making sure that all dependencies and
# requirements are met to provide the same functionality that the standard AWS Lambda images provide.
#
# Since this builds upon the standard Ruby Images provided by the Kubernetes platform, there is very
# little work that needs to be outside installing the required tooling and dependencies.
ARG BUILD_VARIANT
ARG UBUNTU_VERSION=20.04
FROM 916869144969.dkr.ecr.us-east-1.amazonaws.com/customink/nodejs:${UBUNTU_VERSION}-${BUILD_VARIANT}

# Because we consumed the argument in the FROM statement, we need to redefine it
# so we can use it inside the Dockerfile, this is a quirk from Docker.
ARG BUILD_VARIANT

# Update the labels of the container for proper information tracking
LABEL description="Custom Ink NodeJS Lambda $BUILD_VARIANT Image"

# Expose the required environment variables
ENV LAMBDA_TASK_ROOT="/app"

# Switch to the root user, as we will need to install packages and dependencies to ensure we can properly build Ruby.
WORKDIR /root
USER root

# Install the requirements needed to be able to install the AWS packages
RUN apt update && \
    apt install -y build-essential make cmake autoconf automake libtool m4 python3 unzip libssl-dev libcurl4-openssl-dev && \
    apt clean && \
    rm -rf /tmp/* /var/lib/apt/lists/*

# Ensure the runtime directory exists
RUN mkdir -p /var/runtime

# Install the AWS Commandline Client, granting the required access to executing things inside the image.
RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" \
    && unzip awscliv2.zip \
    && ./aws/install \
    && rm -rf .aws/install \
    && rm awscliv2.zip

# Install the Lambda Runtime Interface Emulator
# We will install this inside the required location to make it detectable by the system
RUN mkdir -p ~/.aws-lambda-rie \
    && curl -Lo "/usr/local/bin/aws-lambda-rie" "https://github.com/aws/aws-lambda-runtime-interface-emulator/releases/latest/download/aws-lambda-rie" \
    && chmod +x "/usr/local/bin/aws-lambda-rie"

# Switch back to the correct user and working directory,
# and ensure that the container is configured correctly.
USER "app"
WORKDIR "/app"

# Install the required gem for the AWS Lambda Runtime Client.
# This will be sourced through NPM.
RUN npm i aws-lambda-ric

ENTRYPOINT ["/usr/bin/npx", "aws-lambda-ric"]
CMD ["app.handler"]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants