# Define global args ARG DISTRO_VERSION # Grab a fresh copy of the image and install ruby and build the runtime interface client gem FROM ubuntu:${DISTRO_VERSION} AS build-image ENV DEBIAN_FRONTEND=noninteractive ARG RUNTIME_VERSION RUN apt-get update -y && \ apt-get install -y git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev libffi-dev libtool RUN ln -sf /bin/bash /bin/sh RUN rm -rf /root/.rbenv/ RUN git clone https://github.com/rbenv/rbenv.git /root/.rbenv ENV PATH="/root/.rbenv/bin:$PATH" RUN echo 'eval "$(rbenv init -)"' >> /root/.bashrc RUN git clone https://github.com/rbenv/ruby-build.git /root/.rbenv/plugins/ruby-build RUN bash /root/.bashrc RUN RUNTIME_VERSIONS=($(rbenv install -L | grep -oE $(echo "^${RUNTIME_VERSION}\.[0-9]+"))) && \ RUNTIME_LATEST_VERSION=${RUNTIME_VERSIONS[-1]} && \ rbenv install -v ${RUNTIME_LATEST_VERSION} && \ rbenv global ${RUNTIME_LATEST_VERSION} && \ cp /root/.rbenv/versions/${RUNTIME_LATEST_VERSION}/bin/gem /usr/local/bin/gem && \ cp /root/.rbenv/versions/${RUNTIME_LATEST_VERSION}/bin/rake /usr/local/bin/rake && \ gem install bundler ARG RIC_BUILD_DIR="/build" # Create directory to build the Runtime Interface Client gem RUN mkdir -p ${RIC_BUILD_DIR} WORKDIR ${RIC_BUILD_DIR} COPY . . RUN rake build # Grab a fresh copy of the Ruby image FROM ubuntu:${DISTRO_VERSION} # Get dependencies for the Runtime Interface Client RUN apt-get update -y && \ apt-get install -y libyaml-dev libssl-dev ARG RUNTIME_VERSION # Copy ruby from the build-image COPY --from=build-image /root/.rbenv /root/.rbenv ENV PATH="/root/.rbenv/bin:$PATH" # Copy the Runtime Interface Client gem and install it ARG RIC_BUILD_DIR="/build" COPY --from=build-image ${RIC_BUILD_DIR}/pkg/aws_lambda_ric*.gem aws_lambda_ric.gem RUN ln -sf /bin/bash /bin/sh RUN RUNTIME_VERSIONS=($(rbenv install -L | grep -oE $(echo "^${RUNTIME_VERSION}\.[0-9]+"))) && \ RUNTIME_LATEST_VERSION=${RUNTIME_VERSIONS[-1]} && \ cp /root/.rbenv/versions/${RUNTIME_LATEST_VERSION}/bin/gem /usr/local/bin/gem && \ gem install aws_lambda_ric.gem && \ cp /root/.rbenv/versions/${RUNTIME_LATEST_VERSION}/bin/aws_lambda_ric /usr/local/bin/aws_lambda_ric ARG FUNCTION_DIR="/function" RUN mkdir -p ${FUNCTION_DIR} # Copy function code COPY test/integration/test-handlers/echo/* ${FUNCTION_DIR} # Set working directory to function root directory WORKDIR ${FUNCTION_DIR} ENTRYPOINT ["aws_lambda_ric"] CMD ["app.App::Handler.process"]