aws / aws-lambda-python-runtime-interface-client

Apache License 2.0
258 stars 73 forks source link

pip install awslambdaric fails!! #82

Closed subhankar-trisetra closed 2 years ago

subhankar-trisetra commented 2 years ago

I'm trying to make a custom lambda container image from base ubuntu18.04, but cannot seem to install awslambdaric I'm using python 3.7.5 to install awslambdaric Here's the Dockerfile:

# Define custom function directory
ARG FUNCTION_DIR="/function"

FROM nytimes/blender:latest as build-image

# Include global arg in this stage of the build
ARG FUNCTION_DIR

RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/3bf863cc.pub
RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64/7fa2af80.pub

# Install aws-lambda-cpp build dependencies
RUN echo "deb http://archive.ubuntu.com/ubuntu bionic-updates main universe" >> /etc/apt/sources.list && \
    apt-get update -y && \
    apt-get upgrade -y && \
    apt-get install -y --no-install-recommends \
    make software-properties-common \
    git unzip build-essential wget libssl-dev libcurl4-openssl-dev \
    libgflags-dev libgoogle-glog-dev libatlas-base-dev libeigen3-dev libsuitesparse-dev \
    python3.7 python3.7-dev python3-pip python3-setuptools autoconf libtool python python-dev python-pip pkg-config libjpeg8-dev \
    libtiff5-dev libpng-dev libgtk2.0-dev libavcodec-dev libavformat-dev libswscale-dev libv4l-dev \
    libatlas-base-dev gfortran libavresample-dev libgphoto2-dev libgstreamer-plugins-base1.0-dev libdc1394-22-dev

# Install gcc10
RUN add-apt-repository ppa:ubuntu-toolchain-r/test && \
    apt-get update -y && \
    apt install -y gcc-10 g++-10

# cmake
RUN cd /tmp && wget "https://github.com/Kitware/CMake/releases/download/v3.23.2/cmake-3.23.2-linux-x86_64.sh" && \
    chmod +x cmake-3.23.2-linux-x86_64.sh && \
    ./cmake-3.23.2-linux-x86_64.sh --skip-license --prefix=/usr/local && \
    ldconfig && rm -rf cmake-3.23.2-linux-x86_64.sh

# googltest
RUN cd /tmp && \
    git clone https://github.com/google/googletest && \
    cd googletest && \
    cmake -S . -B build && \
    cmake --build build --target install -- -j $(nproc) && ldconfig

# opencv-contrib
RUN python3 -m pip install numpy && \
    cd /opt && \
    git clone https://github.com/opencv/opencv_contrib.git && \
    cd opencv_contrib && \
    git checkout 3.4

# opencv
RUN cd /opt && \
    git clone https://github.com/opencv/opencv.git && \
    cd opencv && \
    git checkout 3.4 && \
    cmake -S . -B build -D CMAKE_BUILD_TYPE=RELEASE \
    -D BUILD_NEW_PYTHON_SUPPORT=ON \
    -D CMAKE_INSTALL_PREFIX=/usr/local \
    -D INSTALL_C_EXAMPLES=OFF \
    -D INSTALL_PYTHON_EXAMPLES=OFF \
    -D OPENCV_EXTRA_MODULES_PATH=/opt/opencv_contrib/modules \
    -D PYTHON_EXECUTABLE=/usr/bin/python3 \
    -D PYTHON2_EXECUTABLE=/usr/bin/python \
    -D BUILD_EXAMPLES=OFF /opt/opencv && \
    cmake --build build --target install -- -j $(nproc) && ldconfig

# ceres-solver
RUN cd /tmp && \
    wget http://ceres-solver.org/ceres-solver-2.1.0.tar.gz && \
    tar -xzf ceres-solver-2.1.0.tar.gz && ls && \
    cd ceres-solver-2.1.0 && \
    cmake -S . -B build && \
    cmake --build build --target install -- -j $(nproc) && ldconfig

# clean up phase
RUN rm -rf /tmp/ceres* && apt-get clean && rm -rf /var/lib/apt/lists/* && rm -rf /opt/opencv*

# Copy function code
RUN mkdir -p ${FUNCTION_DIR}
# Copy function code
COPY app.py ${FUNCTION_DIR}
COPY convert_photo_into_3d_model.py ${FUNCTION_DIR}

# Install the function's dependencies
RUN /usr/bin/python3.7 -m pip install \
    --target ${FUNCTION_DIR} \
    awslambdaric

FROM nytimes/blender:latest

# 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/bin/python3.7", "-m", "awslambdaric" ]
CMD [ "app.handler" ]

Error which I get is:

[+] Building 6.6s (20/21)                                                                                                                  
 => [internal] load build definition from Dockerfile                                                                                  0.0s
 => => transferring dockerfile: 37B                                                                                                   0.0s
 => [internal] load .dockerignore                                                                                                     0.0s
 => => transferring context: 2B                                                                                                       0.0s
 => [internal] load metadata for docker.io/nytimes/blender:latest                                                                     1.4s
 => [build-image  1/15] FROM docker.io/nytimes/blender:latest@sha256:e7fc5a7ed58acf9463c64091635a3b5fc031f39ae8e8152b61859d3c9c09d61  0.0s
 => [internal] load build context                                                                                                     0.0s
 => => transferring context: 77B                                                                                                      0.0s
 => CACHED [stage-1 2/3] WORKDIR /function                                                                                            0.0s
 => CACHED [build-image  2/15] RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_  0.0s
 => CACHED [build-image  3/15] RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/machine-learning/repos/ubu  0.0s
 => CACHED [build-image  4/15] RUN echo "deb http://archive.ubuntu.com/ubuntu bionic-updates main universe" >> /etc/apt/sources.list  0.0s
 => CACHED [build-image  5/15] RUN add-apt-repository ppa:ubuntu-toolchain-r/test &&  apt-get update -y &&  apt install -y gcc-10 g+  0.0s
 => CACHED [build-image  6/15] RUN cd /tmp && wget "https://github.com/Kitware/CMake/releases/download/v3.23.2/cmake-3.23.2-linux-x8  0.0s
 => CACHED [build-image  7/15] RUN cd /tmp &&  git clone https://github.com/google/googletest &&  cd googletest &&     cmake -S . -B  0.0s
 => CACHED [build-image  8/15] RUN python3 -m pip install numpy &&  cd /opt &&  git clone https://github.com/opencv/opencv_contrib.g  0.0s
 => CACHED [build-image  9/15] RUN cd /opt &&  git clone https://github.com/opencv/opencv.git &&  cd opencv &&  git checkout 3.4 &&   0.0s
 => CACHED [build-image 10/15] RUN cd /tmp &&     wget http://ceres-solver.org/ceres-solver-2.1.0.tar.gz &&  tar -xzf ceres-solver-2  0.0s
 => CACHED [build-image 11/15] RUN rm -rf /tmp/ceres* && apt-get clean && rm -rf /var/lib/apt/lists/* && rm -rf /opt/opencv*          0.0s
 => CACHED [build-image 12/15] RUN mkdir -p /function                                                                                 0.0s
 => CACHED [build-image 13/15] COPY app.py /function                                                                                  0.0s
 => CACHED [build-image 14/15] COPY convert_photo_into_3d_model.py /function                                                          0.0s
 => ERROR [build-image 15/15] RUN /usr/bin/python3.7 -m pip install     --target /function     awslambdaric                           5.0s
------
 > [build-image 15/15] RUN /usr/bin/python3.7 -m pip install     --target /function     awslambdaric:
#20 1.152 Collecting awslambdaric
#20 1.750   Downloading https://files.pythonhosted.org/packages/c9/c1/c851767acd173512fe6089445b3a611283932961ace5dc8fdc337c440538/awslambdaric-2.0.4.tar.gz (4.4MB)
#20 4.815     Complete output from command python setup.py egg_info:
#20 4.815     *** Do not use buildconf. Instead, just use: autoreconf -fi
#20 4.815     Can't exec "aclocal": No such file or directory at /usr/share/autoconf/Autom4te/FileUtils.pm line 326.
#20 4.815     autoreconf: failed to run aclocal: No such file or directory
#20 4.815     Traceback (most recent call last):
#20 4.815       File "<string>", line 1, in <module>
#20 4.815       File "/tmp/pip-build-iuc0chln/awslambdaric/setup.py", line 95, in <module>
#20 4.815         ext_modules=get_runtime_client_extension(),
#20 4.815       File "/tmp/pip-build-iuc0chln/awslambdaric/setup.py", line 46, in get_runtime_client_extension
#20 4.815         extra_link_args=get_curl_extra_linker_flags(),
#20 4.815       File "/tmp/pip-build-iuc0chln/awslambdaric/setup.py", line 19, in get_curl_extra_linker_flags
#20 4.815         check_call(["./scripts/preinstall.sh"])
#20 4.815       File "/usr/lib/python3.7/subprocess.py", line 363, in check_call
#20 4.815         raise CalledProcessError(retcode, cmd)
#20 4.815     subprocess.CalledProcessError: Command '['./scripts/preinstall.sh']' returned non-zero exit status 1.
#20 4.815     
#20 4.815     ----------------------------------------
#20 4.901 Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-iuc0chln/awslambdaric/
------
executor failed running [/bin/sh -c /usr/bin/python3.7 -m pip install     --target ${FUNCTION_DIR}     awslambdaric]: exit code: 1