-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile_corretto19
50 lines (41 loc) · 1.56 KB
/
Dockerfile_corretto19
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
FROM --platform=linux/amd64 amazonlinux:2
# Add the Amazon Corretto repository
RUN rpm --import https://yum.corretto.aws/corretto.key
RUN curl -L -o /etc/yum.repos.d/corretto.repo https://yum.corretto.aws/corretto.repo
# Update the packages and install Amazon Corretto 19, Maven and Zip
RUN yum -y update
RUN yum install -y java-19-amazon-corretto-devel maven zip
# Set Java 19 as the default
RUN update-alternatives --set java "/usr/lib/jvm/java-19-amazon-corretto/bin/java"
RUN update-alternatives --set javac "/usr/lib/jvm/java-19-amazon-corretto/bin/javac"
# Copy the software folder to the image and build the function
COPY lambda-app lambda-app
WORKDIR /lambda-app
RUN mvn clean package
# Find JDK module dependencies dynamically from the uber jar
RUN jdeps -q \
--ignore-missing-deps \
--multi-release 19 \
--print-module-deps \
target/lambda-app.jar > jre-deps.info
# Create a slim Java 19 JRE which only contains the required modules to run the function
RUN jlink --verbose \
--compress 2 \
--strip-java-debug-attributes \
--no-header-files \
--no-man-pages \
--output /jre-custom \
--add-modules $(cat jre-deps.info)
# Use Javas Application Class Data Sharing feature
# It creates the file /jre18-custom/lib/server/classes.jsa
RUN /jre-custom/bin/java -Xshare:dump
# Package everything together into a custom runtime archive
WORKDIR /
COPY bootstrap bootstrap
RUN chmod 755 bootstrap
RUN cp /lambda-app/target/lambda-app.jar lambda-app.jar
RUN zip -r lambda-app.zip \
lambda-app.jar
RUN zip -r layer.zip \
bootstrap \
/jre-custom