From 012b40a592ac8111e9a916e60f7be7cd2b96e7b4 Mon Sep 17 00:00:00 2001 From: Laurent Goujon Date: Tue, 21 May 2024 13:47:14 -0700 Subject: [PATCH] Build java image directly --- .github/workflows/java.yml | 1 + ci/docker/java.dockerfile | 37 ++++++++++++++++++++++ ci/maven-toolchains.xml | 64 ++++++++++++++++++++++++++++++++++++++ docker-compose.yml | 10 +++--- 4 files changed, 108 insertions(+), 4 deletions(-) create mode 100644 ci/docker/java.dockerfile create mode 100644 ci/maven-toolchains.xml diff --git a/.github/workflows/java.yml b/.github/workflows/java.yml index 472613b8abe6c..47560536c9c09 100644 --- a/.github/workflows/java.yml +++ b/.github/workflows/java.yml @@ -62,6 +62,7 @@ jobs: maven: [3.9.6] image: [java] env: + JDK: 22 TEST_JDK: ${{ matrix.jdk }} MAVEN: ${{ matrix.maven }} steps: diff --git a/ci/docker/java.dockerfile b/ci/docker/java.dockerfile new file mode 100644 index 0000000000000..2535abce2741a --- /dev/null +++ b/ci/docker/java.dockerfile @@ -0,0 +1,37 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +FROM maven:3.9.6-eclipse-temurin-22 + +COPY --from=maven:3.9.6-eclipse-temurin-8 /opt/java/openjdk /opt/java/openjdk8 +COPY --from=maven:3.9.6-eclipse-temurin-11 /opt/java/openjdk /opt/java/openjdk11 +COPY --from=maven:3.9.6-eclipse-temurin-17 /opt/java/openjdk /opt/java/openjdk17 +COPY --from=maven:3.9.6-eclipse-temurin-21 /opt/java/openjdk /opt/java/openjdk21 + + +env JAVA8_HOME /opt/java/openjdk8 +env JAVA11_HOME /opt/java/openjdk11 +env JAVA17_HOME /opt/java/openjdk17 +env JAVA21_HOME /opt/java/openjdk21 +env JAVA22_HOME /opt/java/openjdk + +RUN find "$JAVA8_HOME/lib" "$JAVA11_HOME/lib" "$JAVA17_HOME/lib" "$JAVA21_HOME/lib" "$JAVA22_HOME/lib" -name '*.so' -exec dirname '{}' ';' | sort -u > /etc/ld.so.conf.d/docker-openjdk.conf; \ + ldconfig; + +COPY ci/maven-toolchains.xml /usr/share/maven/conf/toolchains.xml + +CMD ["mvn"] diff --git a/ci/maven-toolchains.xml b/ci/maven-toolchains.xml new file mode 100644 index 0000000000000..f2eafb0ba9409 --- /dev/null +++ b/ci/maven-toolchains.xml @@ -0,0 +1,64 @@ + + + + + jdk + + 1.8 + openjdk + + + ${env.JAVA8_HOME} + + + + jdk + + 11 + openjdk + + + ${env.JAVA11_HOME} + + + + jdk + + 17 + openjdk + + + ${env.JAVA17_HOME} + + + + jdk + + 21 + openjdk + + + ${env.JAVA21_HOME} + + + + jdk + + 22 + openjdk + + + ${env.JAVA22_HOME} + + + diff --git a/docker-compose.yml b/docker-compose.yml index 8e58342a743a0..8e3896345dca5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1711,10 +1711,12 @@ services: # Usage: # docker-compose build java # docker-compose run java - # Parameters: - # MAVEN: 3.9.5 - # JDK: 8, 11, 17, 21 - image: ghcr.io/laurentgo/multi-jdk-maven-image:main + image: ${REPO}:${ARCH}-java + build: + context: . + dockerfile: ci/docker/java.dockerfile + cache_from: + - ${REPO}:${ARCH}-java shm_size: *shm-size volumes: &java-volumes - .:/arrow:delegated