11# Define global args
2- ARG DISTRO_VERSION
2+ ARG RUNTIME_VERSION
33
4- # Grab a fresh copy of the image and install ruby and build the runtime interface client gem
5- FROM amazonlinux:${DISTRO_VERSION} AS build-image
4+ # Build stage: compile Ruby and build the RIC gem
5+ FROM public.ecr.aws/lambda/provided:al2023 AS build-image
66
77ARG RUNTIME_VERSION
88
9- RUN yum update -y && \
10- yum install -y git-core zlib zlib-devel gcc-c++ patch readline readline-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison curl sqlite-devel
9+ RUN dnf update -y && \
10+ dnf install -y git gcc gcc-c++ make openssl-devel readline-devel zlib-devel \
11+ libffi-devel libyaml-devel bzip2 autoconf automake libtool bison tar gzip
1112
1213RUN rm -rf /root/.rbenv/
1314RUN git clone https://github.com/rbenv/rbenv.git /root/.rbenv
1415ENV PATH="/root/.rbenv/bin:$PATH"
15- RUN echo 'eval "$(rbenv init -)"' >> /root/.bashrc
1616RUN git clone https://github.com/rbenv/ruby-build.git /root/.rbenv/plugins/ruby-build
17- RUN source /root/.bashrc
18- RUN RUNTIME_VERSIONS=($(rbenv install -L | grep -oE $(echo "^${RUNTIME_VERSION}\.[0-9]+"))) && \
17+ RUN RUNTIME_VERSIONS=($(rbenv install -L | grep -oE $(echo "^${RUNTIME_VERSION}\.[0-9]+"))) && \
1918 RUNTIME_LATEST_VERSION=${RUNTIME_VERSIONS[-1]} && \
2019 rbenv install -v ${RUNTIME_LATEST_VERSION} && \
2120 rbenv global ${RUNTIME_LATEST_VERSION} && \
@@ -24,42 +23,37 @@ RUN RUNTIME_VERSIONS=($(rbenv install -L | grep -oE $(echo "^${RUNTIME_VERSION}
2423 gem install bundler
2524
2625ARG RIC_BUILD_DIR="/build"
27- # Create directory to build the Runtime Interface Client gem
2826RUN mkdir -p ${RIC_BUILD_DIR}
29-
3027WORKDIR ${RIC_BUILD_DIR}
3128COPY . .
3229RUN rake build
3330
3431
35- # Grab a fresh copy of the Ruby image
36- FROM amazonlinux:${DISTRO_VERSION}
37-
38- RUN yum install -y curl
32+ # Runtime stage
33+ FROM public.ecr.aws/lambda/provided:al2023
3934
4035ARG RUNTIME_VERSION
4136
37+ RUN dnf install -y libyaml
38+
4239# Copy ruby from the build-image
4340COPY --from=build-image /root/.rbenv /root/.rbenv
44-
4541ENV PATH="/root/.rbenv/bin:$PATH"
4642
4743# Copy the Runtime Interface Client gem and install it
4844ARG RIC_BUILD_DIR="/build"
4945COPY --from=build-image ${RIC_BUILD_DIR}/pkg/aws_lambda_ric*.gem aws_lambda_ric.gem
50- RUN RUNTIME_VERSIONS=($(rbenv install -L | grep -oE $(echo "^${RUNTIME_VERSION}\.[0-9]+"))) && \
46+ RUN RUNTIME_VERSIONS=($(rbenv install -L | grep -oE $(echo "^${RUNTIME_VERSION}\.[0-9]+"))) && \
5147 RUNTIME_LATEST_VERSION=${RUNTIME_VERSIONS[-1]} && \
5248 cp /root/.rbenv/versions/${RUNTIME_LATEST_VERSION}/bin/gem /usr/local/bin/gem && \
5349 gem install aws_lambda_ric.gem && \
5450 cp /root/.rbenv/versions/${RUNTIME_LATEST_VERSION}/bin/aws_lambda_ric /usr/local/bin/aws_lambda_ric
5551
5652ARG FUNCTION_DIR="/function"
57-
5853RUN mkdir -p ${FUNCTION_DIR}
59- # Copy function code
6054COPY test/integration/test-handlers/echo/* ${FUNCTION_DIR}
61- # Set working directory to function root directory
6255WORKDIR ${FUNCTION_DIR}
6356
6457ENTRYPOINT ["aws_lambda_ric"]
6558CMD ["app.App::Handler.process"]
59+ COPY .scratch/aws-lambda-rie /usr/bin/aws-lambda-rie
0 commit comments