-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathDockerfile
34 lines (28 loc) · 985 Bytes
/
Dockerfile
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
ARG image
FROM $image AS builder
ARG runtime
# Install dev dependencies
COPY . /ruby
WORKDIR /ruby
RUN apt-get update
RUN apt-get install -y gcc zip binutils
# Install this gem
RUN gem build datadog-lambda
# Install ddtrace gem
RUN gem install datadog-lambda --install-dir "/opt/ruby/gems/$runtime"
RUN gem install datadog -v 2.0 --install-dir "/opt/ruby/gems/$runtime"
# Copy handler
COPY handler.rb /opt
WORKDIR /opt
# Remove native extension debase-ruby_core_source (25MB) runtimes below Ruby 2.6
RUN rm -rf ./ruby/gems/$runtime/gems/debase-ruby_core_source*/
# Remove aws-sdk related (2MB), included in runtime
RUN rm -rf ./ruby/gems/$runtime/gems/aws*/
# Remove binaries not needed in AWS Lambda
RUN find . -name '*linux-musl*' -prune -exec rm -rf {} +
# Cache files zipped gem files, that aren't used by during runtime, only during
# installation, so they are safe to delete
RUN rm -rf "/opt/ruby/gems/${runtime}/cache"
RUN cd /opt
FROM scratch
COPY --from=builder /opt /