forked from aws/aws-lambda-ruby-runtime-interface-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.echo.amazonlinux
64 lines (48 loc) · 2.3 KB
/
Dockerfile.echo.amazonlinux
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# Define global args
ARG DISTRO_VERSION
# Grab a fresh copy of the image and install ruby and build the runtime interface client gem
FROM amazonlinux:${DISTRO_VERSION} AS build-image
ARG RUNTIME_VERSION
RUN yum update -y && \
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
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 source /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 amazonlinux:${DISTRO_VERSION}
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 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"]