blob: a94e3fe8ee098bc614c89d99ed34c75b2049f42d (
plain) (
blame)
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# SPDX-FileCopyrightText: 2023 The Refinery Authors <https://refinery.tools/>
#
# SPDX-License-Identifier: EPL-2.0
FROM public.ecr.aws/amazoncorretto/amazoncorretto:17-al2023-jdk AS jdk
FROM --platform=$BUILDPLATFORM docker.io/eclipse-temurin:17-jammy AS jlink-base
# Use the Ubuntu Jammy based Temurin image for JLink, because it already
# contains the require objcopy tool for stripping debug symbols:
# https://github.com/docker-library/openjdk/issues/351
# We'll have to cross-jlink the JDK: https://stackoverflow.com/a/47611708
COPY --link --from=jdk /usr/lib/jvm/java-17-amazon-corretto /crossjdk
FROM --platform=$BUILDPLATFORM jlink-base AS jlink-amd64-on-amd64
FROM --platform=$BUILDPLATFORM jlink-base AS jlink-arm64-on-arm64
FROM --platform=$BUILDPLATFORM jlink-base AS jlink-arm64-on-amd64
# When cross-building the Docker image, we have the wrong toolchain for the
# target architecture. We forcibly override the target for the objcopy tool.
# The cross toolchain is not available in Amazon Linux 2023.
RUN --mount=type=cache,target=/var/cache/apt \
apt-get update && \
apt-get install binutils-aarch64-linux-gnu && \
ln -sf /usr/bin/aarch64-linux-gnu-objcopy /usr/bin/objcopy
FROM --platform=$BUILDPLATFORM jlink-base AS jlink-amd64-on-arm64
RUN --mount=type=cache,target=/var/cache/apt \
apt-get update && \
apt-get install binutils-x86-64-linux-gnu && \
ln -sf /usr/bin/x86_64-linux-gnu-objcopy /usr/bin/objcopy
FROM --platform=$BUILDPLATFORM jlink-$TARGETARCH-on-$BUILDARCH as jlink
RUN jlink --no-header-files --no-man-pages --compress=2 \
--module-path=/crossjdk/jmods --strip-debug --add-modules \
java.base,java.logging,java.xml,jdk.zipfs \
--output /jlink
FROM public.ecr.aws/amazonlinux/amazonlinux:2023-minimal AS base
# The launcher script generated by Gradle uses xargs to parse the argument list.
RUN --mount=type=cache,id=yum-$TARGETARCH,target=/var/cache/apt \
dnf install -y findutils && \
dnf clean all
# The first layer contains the slimmed down JRE.
COPY --link --from=jlink /jlink /usr/lib/java
ENV JAVA_HOME="/usr/lib/java" PATH="/usr/lib/java/bin:${PATH}"
# Layer with platform-independent dependencies, slow changing.
ADD --link lib /app/lib
FROM base AS refinery-amd64
# Layer with platform-dependent dependencies, slow changing.
ADD --link lib_amd64 /app/lib
# Layer with platform-dependent startup script containing references to all
# dependency version.
ADD --link app_amd64_bin /app/bin
FROM base AS refinery-arm64
# Layer with platform-dependent dependencies, slow changing.
ADD --link lib_arm64 /app/lib
# Layer with platform-dependent startup script containing references to all
# dependency version.
ADD --link app_arm64_bin /app/bin
FROM refinery-$TARGETARCH
# Layer with platform-independent application jars.
ADD --link app_lib /app/lib
# Common settings added on top.
ENV REFINERY_LISTEN_HOST=0.0.0.0 REFINERY_LISTEN_PORT=8888
EXPOSE 8888
USER 1000
WORKDIR /app
ENTRYPOINT /app/bin/refinery-language-web
|