diff options
Diffstat (limited to 'docker/Dockerfile.base')
-rw-r--r-- | docker/Dockerfile.base | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/docker/Dockerfile.base b/docker/Dockerfile.base new file mode 100644 index 00000000..0668ce78 --- /dev/null +++ b/docker/Dockerfile.base | |||
@@ -0,0 +1,58 @@ | |||
1 | # SPDX-FileCopyrightText: 2023-2024 The Refinery Authors <https://refinery.tools/> | ||
2 | # | ||
3 | # SPDX-License-Identifier: EPL-2.0 | ||
4 | |||
5 | FROM public.ecr.aws/amazoncorretto/amazoncorretto:21-al2023-jdk AS jdk | ||
6 | |||
7 | FROM --platform=$BUILDPLATFORM docker.io/eclipse-temurin:21-jdk-jammy AS jlink-base | ||
8 | # Use the Ubuntu Jammy based Temurin image for JLink, because it already | ||
9 | # contains the require objcopy tool for stripping debug symbols: | ||
10 | # https://github.com/docker-library/openjdk/issues/351 | ||
11 | # We'll have to cross-jlink the JDK: https://stackoverflow.com/a/47611708 | ||
12 | COPY --link --from=jdk /usr/lib/jvm/java-21-amazon-corretto /crossjdk | ||
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 apt-get update && \ | ||
23 | apt-get -y install binutils-aarch64-linux-gnu && \ | ||
24 | ln -sf /usr/bin/aarch64-linux-gnu-objcopy /usr/bin/objcopy && \ | ||
25 | rm -rf /var/lib/apt/lists/* | ||
26 | |||
27 | FROM --platform=$BUILDPLATFORM jlink-base AS jlink-amd64-on-arm64 | ||
28 | RUN apt-get update && \ | ||
29 | apt-get -y install binutils-x86-64-linux-gnu && \ | ||
30 | ln -sf /usr/bin/x86_64-linux-gnu-objcopy /usr/bin/objcopy && \ | ||
31 | rm -rf /var/lib/apt/lists/* | ||
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 \ | ||
36 | java.base,java.logging,java.xml,jdk.zipfs \ | ||
37 | --output /jlink | ||
38 | |||
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 dnf install -y findutils && \ | ||
42 | dnf clean all | ||
43 | # The first layer contains the slimmed down JRE. | ||
44 | COPY --link --from=jlink /jlink /usr/lib/java | ||
45 | ENV JAVA_HOME="/usr/lib/java" PATH="/usr/lib/java/bin:${PATH}" | ||
46 | # Layer with platform-independent dependencies, slow changing. | ||
47 | ADD --link common_lib /app/lib | ||
48 | |||
49 | FROM base AS base-amd64 | ||
50 | # Layer with platform-dependent dependencies, slow changing. | ||
51 | ADD --link common_amd64_lib /app/lib | ||
52 | |||
53 | FROM base AS base-arm64 | ||
54 | # Layer with platform-dependent dependencies, slow changing. | ||
55 | ADD --link common_arm64_lib /app/lib | ||
56 | |||
57 | FROM base-$TARGETARCH | ||
58 | |||