diff options
author | Kristóf Marussy <kristof@marussy.com> | 2023-09-04 21:09:22 +0200 |
---|---|---|
committer | Kristóf Marussy <kristof@marussy.com> | 2023-09-05 00:14:46 +0200 |
commit | 056cc92da52fad11083a0f961fbe14d0eb40dfd4 (patch) | |
tree | a8de33ff3bc9bf36e9a9c329cde6e24a0cc3099f | |
parent | refactor: server environemntal variables (diff) | |
download | refinery-056cc92da52fad11083a0f961fbe14d0eb40dfd4.tar.gz refinery-056cc92da52fad11083a0f961fbe14d0eb40dfd4.tar.zst refinery-056cc92da52fad11083a0f961fbe14d0eb40dfd4.zip |
build: switch to Amazon Corretto
Hopefully improved performance on AWS Graviton
-rw-r--r-- | docker/Dockerfile | 46 |
1 files changed, 36 insertions, 10 deletions
diff --git a/docker/Dockerfile b/docker/Dockerfile index 1485e95b..89fa454e 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile | |||
@@ -2,19 +2,45 @@ | |||
2 | # | 2 | # |
3 | # SPDX-License-Identifier: EPL-2.0 | 3 | # SPDX-License-Identifier: EPL-2.0 |
4 | 4 | ||
5 | FROM docker.io/eclipse-temurin:17-jammy AS jlink | 5 | FROM public.ecr.aws/amazoncorretto/amazoncorretto:17-al2023-jdk AS jdk |
6 | # Disable HotSpot C1 compilation, because it causes spurious | 6 | |
7 | # NullPointerException instances to be thrown when running in | 7 | FROM --platform=$BUILDPLATFORM docker.io/eclipse-temurin:17-jammy AS jlink-base |
8 | # qemu-aarch64-static for image cross-building. | 8 | # Use the Ubuntu Jammy based Temurin image for JLink, because it already |
9 | ENV _JAVA_OPTIONS="-XX:CompilationMode=high-only" | 9 | # contains the require objcopy tool for stripping debug symbols: |
10 | # We need to manually add jdk.zipfs to the list of modules output by jdeps to | 10 | # https://github.com/docker-library/openjdk/issues/351 |
11 | # enable serving static assets from the refinery-language-web-VERSION.jar, | 11 | # We'll have to cross-jlink the JDK: https://stackoverflow.com/a/47611708 |
12 | # because the dependency doesn't get picked up by static analysis. | 12 | COPY --link --from=jdk /usr/lib/jvm/java-17-amazon-corretto /crossjdk |
13 | RUN jlink --no-header-files --no-man-pages --compress=2 --strip-debug --add-modules \ | 13 | |
14 | FROM --platform=$BUILDPLATFORM jlink-base AS jlink-amd64-on-amd64 | ||
15 | |||
16 | FROM --platform=$BUILDPLATFORM jlink-base AS jlink-arm64-on-arm64 | ||
17 | |||
18 | FROM --platform=$BUILDPLATFORM jlink-base AS jlink-arm64-on-amd64 | ||
19 | # When cross-building the Docker image, we have the wrong toolchain for the | ||
20 | # target architecture. We forcibly override the target for the objcopy tool. | ||
21 | # The cross toolchain is not available in Amazon Linux 2023. | ||
22 | RUN --mount=type=cache,target=/var/cache/apt \ | ||
23 | apt-get update && \ | ||
24 | apt-get install binutils-aarch64-linux-gnu && \ | ||
25 | ln -sf /usr/bin/aarch64-linux-gnu-objcopy /usr/bin/objcopy | ||
26 | |||
27 | FROM --platform=$BUILDPLATFORM jlink-base AS jlink-amd64-on-arm64 | ||
28 | RUN --mount=type=cache,target=/var/cache/apt \ | ||
29 | apt-get update && \ | ||
30 | apt-get install binutils-x86-64-linux-gnu && \ | ||
31 | ln -sf /usr/bin/x86_64-linux-gnu-objcopy /usr/bin/objcopy | ||
32 | |||
33 | FROM --platform=$BUILDPLATFORM jlink-$TARGETARCH-on-$BUILDARCH as jlink | ||
34 | RUN jlink --no-header-files --no-man-pages --compress=2 \ | ||
35 | --module-path=/crossjdk/jmods --strip-debug --add-modules \ | ||
14 | java.base,java.compiler,java.desktop,java.instrument,java.management,java.naming,java.rmi,java.security.jgss,java.sql,jdk.unsupported,jdk.zipfs \ | 36 | java.base,java.compiler,java.desktop,java.instrument,java.management,java.naming,java.rmi,java.security.jgss,java.sql,jdk.unsupported,jdk.zipfs \ |
15 | --output /jlink | 37 | --output /jlink |
16 | 38 | ||
17 | FROM docker.io/debian:12-slim AS base | 39 | FROM public.ecr.aws/amazonlinux/amazonlinux:2023-minimal AS base |
40 | # The launcher script generated by Gradle uses xargs to parse the argument list. | ||
41 | RUN --mount=type=cache,id=yum-$TARGETARCH,target=/var/cache/apt \ | ||
42 | dnf install -y findutils && \ | ||
43 | dnf clean all | ||
18 | # The first layer contains the slimmed down JRE. | 44 | # The first layer contains the slimmed down JRE. |
19 | COPY --link --from=jlink /jlink /usr/lib/java | 45 | COPY --link --from=jlink /jlink /usr/lib/java |
20 | ENV JAVA_HOME="/usr/lib/java" PATH="/usr/lib/java/bin:${PATH}" | 46 | ENV JAVA_HOME="/usr/lib/java" PATH="/usr/lib/java/bin:${PATH}" |