aboutsummaryrefslogtreecommitdiffstats
path: root/docker/Dockerfile.base
diff options
context:
space:
mode:
Diffstat (limited to 'docker/Dockerfile.base')
-rw-r--r--docker/Dockerfile.base58
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
5FROM public.ecr.aws/amazoncorretto/amazoncorretto:21-al2023-jdk AS jdk
6
7FROM --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
12COPY --link --from=jdk /usr/lib/jvm/java-21-amazon-corretto /crossjdk
13
14FROM --platform=$BUILDPLATFORM jlink-base AS jlink-amd64-on-amd64
15
16FROM --platform=$BUILDPLATFORM jlink-base AS jlink-arm64-on-arm64
17
18FROM --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.
22RUN 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
27FROM --platform=$BUILDPLATFORM jlink-base AS jlink-amd64-on-arm64
28RUN 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
33FROM --platform=$BUILDPLATFORM jlink-$TARGETARCH-on-$BUILDARCH as jlink
34RUN 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
39FROM public.ecr.aws/amazonlinux/amazonlinux:2023-minimal AS base
40# The launcher script generated by Gradle uses xargs to parse the argument list.
41RUN dnf install -y findutils && \
42 dnf clean all
43# The first layer contains the slimmed down JRE.
44COPY --link --from=jlink /jlink /usr/lib/java
45ENV JAVA_HOME="/usr/lib/java" PATH="/usr/lib/java/bin:${PATH}"
46# Layer with platform-independent dependencies, slow changing.
47ADD --link common_lib /app/lib
48
49FROM base AS base-amd64
50# Layer with platform-dependent dependencies, slow changing.
51ADD --link common_amd64_lib /app/lib
52
53FROM base AS base-arm64
54# Layer with platform-dependent dependencies, slow changing.
55ADD --link common_arm64_lib /app/lib
56
57FROM base-$TARGETARCH
58