From a8c618b1227684b7bbecc6a094e3cfaf8d37d985 Mon Sep 17 00:00:00 2001 From: stark Date: Mon, 21 Nov 2022 16:49:26 +0800 Subject: [PATCH] Add maven jdk17 --- .github/workflows/build-podman.yaml | 22 +++++++++++++++++++++- .github/workflows/build.yaml | 21 ++++++++++++++++++++- Makefile | 19 +++++++++++++++++-- maven/Dockerfile | 25 ++++++++++++++++++++----- maven/podman/Dockerfile | 25 ++++++++++++++++++++----- 5 files changed, 98 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build-podman.yaml b/.github/workflows/build-podman.yaml index 7ef2ffe..3b95c5f 100644 --- a/.github/workflows/build-podman.yaml +++ b/.github/workflows/build-podman.yaml @@ -132,6 +132,26 @@ jobs: ghcr-token: ${{ secrets.GHCR_TOKEN }} build-args: "JDK_VERSION=11" + BuildMavenJDK17: + needs: BuildBase + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + - name: Build maven(JDK17) agent + uses: ./.github/actions/build + with: + context: maven + dockerfile: maven/podman/Dockerfile + image-name: builder-maven + tag-suffix: -jdk17-podman + platforms: linux/amd64 + docker-namespace: ${{ secrets.DOCKER_HUB_USER }} + docker-password: ${{ secrets.DOCKER_HUB_SECRETS }} + ghcr-token: ${{ secrets.GHCR_TOKEN }} + build-args: | + "JDK_VERSION=17" + "JDK_HOME=/usr/java/default" + BuildGradle: needs: BuildBase runs-on: ubuntu-20.04 @@ -148,7 +168,7 @@ jobs: docker-namespace: ${{ secrets.DOCKER_HUB_USER }} docker-password: ${{ secrets.DOCKER_HUB_SECRETS }} ghcr-token: ${{ secrets.GHCR_TOKEN }} - + BuildNodeJs: needs: BuildBase runs-on: ubuntu-20.04 diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 72b1839..4d16f4d 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -128,6 +128,25 @@ jobs: docker-password: ${{ secrets.DOCKER_HUB_SECRETS }} ghcr-token: ${{ secrets.GHCR_TOKEN }} build-args: "JDK_VERSION=11" + BuildMavenJDK17: + needs: BuildBase + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + - name: Build maven(JDK17) agent + uses: ./.github/actions/build + with: + context: maven + dockerfile: maven/Dockerfile + image-name: builder-maven + tag-suffix: -jdk17 + platforms: linux/amd64,linux/arm64 + docker-namespace: ${{ secrets.DOCKER_HUB_USER }} + docker-password: ${{ secrets.DOCKER_HUB_SECRETS }} + ghcr-token: ${{ secrets.GHCR_TOKEN }} + build-args: | + "JDK_VERSION=17" + "JDK_HOME=/usr/java/default" BuildGradle: needs: BuildBase @@ -144,7 +163,7 @@ jobs: docker-namespace: ${{ secrets.DOCKER_HUB_USER }} docker-password: ${{ secrets.DOCKER_HUB_SECRETS }} ghcr-token: ${{ secrets.GHCR_TOKEN }} - + BuildNodeJs: needs: BuildBase runs-on: ubuntu-20.04 diff --git a/Makefile b/Makefile index f9ecafb..b783e45 100644 --- a/Makefile +++ b/Makefile @@ -11,5 +11,20 @@ build-maven-podman: push-maven-podman: docker push kubespheredev/builder-maven:$(VERSION)-podman -build-jdk11: - docker build maven -f maven/Dockerfile -t kubespheredev/builder-maven:$(VERSION)-jdk11 --build-arg JDK_VERSION=11 +build-maven-jdk11: + docker build maven -f maven/Dockerfile -t kubespheredev/builder-maven:$(VERSION)-jdk11 \ +--build-arg JDK_VERSION=11 +push-maven-jdk11: + docker push kubespheredev/builder-maven:$(VERSION)-jdk11 + +build-maven-jdk17: + docker build maven -f maven/Dockerfile -t kubespheredev/builder-maven:$(VERSION)-jdk17 \ +--build-arg JDK_VERSION=17 --build-arg JDK_HOME=/usr/java/default +push-maven-jdk17: + docker push kubespheredev/builder-maven:$(VERSION)-jdk17 + +build-maven-jdk17-podman: + docker build maven -f maven/podman/Dockerfile -t kubespheredev/builder-maven:$(VERSION)-jdk17-podman \ +--build-arg JDK_VERSION=17 --build-arg JDK_HOME=/usr/java/default +push-maven-jdk17-podman: + docker push kubespheredev/builder-maven:$(VERSION)-jdk17-podman diff --git a/maven/Dockerfile b/maven/Dockerfile index 76bb5d8..14c7924 100644 --- a/maven/Dockerfile +++ b/maven/Dockerfile @@ -1,17 +1,28 @@ FROM kubespheredev/builder-base:v3.1.0 ARG JDK_VERSION 1.8.0 +ARG JDK_HOME /usr/lib/jvm/java-${JDK_VERSION}-openjdk # java -ENV JAVA_VERSIOIN $JDK_VERSION -RUN yum install -y java-${JAVA_VERSIOIN}-openjdk-devel \ - java-${JAVA_VERSIOIN}-openjdk-devel.i686 +ENV JAVA_VERSION $JDK_VERSION +RUN if [ "x${JAVA_VERSION}" = "x17" ]; then \ + ARCH= && uArch="$(uname -m)" \ + && case "${uArch##*-}" in \ + x86_64) ARCH='x64';; \ + aarch64) ARCH='aarch64';; \ + *) echo "unsupported architecture"; exit 1 ;; \ + esac \ + && wget https://download.oracle.com/java/${JAVA_VERSION}/latest/jdk-${JAVA_VERSION}_linux-${ARCH}_bin.rpm \ + && rpm -ivh jdk-${JAVA_VERSION}_linux-${ARCH}_bin.rpm; \ + else \ + yum install -y java-${JAVA_VERSION}-openjdk-devel java-${JAVA_VERSION}-openjdk-devel.i686; \ + fi # maven ENV MAVEN_VERSION 3.5.3 RUN curl -f -L https://archive.apache.org/dist/maven/maven-3/$MAVEN_VERSION/binaries/apache-maven-$MAVEN_VERSION-bin.tar.gz | tar -C /opt -xzv ENV M2_HOME /opt/apache-maven-$MAVEN_VERSION -ENV JAVA_HOME /usr/lib/jvm/java-${JAVA_VERSIOIN}-openjdk +ENV JAVA_HOME $JDK_HOME ENV maven.home $M2_HOME ENV M2 $M2_HOME/bin ENV PATH $M2:$PATH:JAVA_HOME/bin @@ -28,6 +39,10 @@ ENV PATH ${PATH}:/opt/ant/bin # Set JDK to be 32bit COPY set_java $M2 -RUN $M2/set_java && rm $M2/set_java +RUN if [ "x${JAVA_VERSION}" = "x17" ]; then \ + rm $M2/set_java; \ + else \ + $M2/set_java && rm $M2/set_java; \ + fi CMD ["mvn","-version"] diff --git a/maven/podman/Dockerfile b/maven/podman/Dockerfile index 3af91dc..771eec0 100644 --- a/maven/podman/Dockerfile +++ b/maven/podman/Dockerfile @@ -1,17 +1,28 @@ FROM kubespheredev/builder-base:v3.1.0-podman ARG JDK_VERSION 1.8.0 +ARG JDK_HOME /usr/lib/jvm/java-${JDK_VERSION}-openjdk # java -ENV JAVA_VERSIOIN $JDK_VERSION -RUN yum install -y java-${JAVA_VERSIOIN}-openjdk-devel \ - java-${JAVA_VERSIOIN}-openjdk-devel.i686 +ENV JAVA_VERSION $JDK_VERSION +RUN if [ "x${JAVA_VERSION}" = "x17" ]; then \ + ARCH= && uArch="$(uname -m)" \ + && case "${uArch##*-}" in \ + x86_64) ARCH='x64';; \ + aarch64) ARCH='aarch64';; \ + *) echo "unsupported architecture"; exit 1 ;; \ + esac \ + && wget https://download.oracle.com/java/${JAVA_VERSION}/latest/jdk-${JAVA_VERSION}_linux-${ARCH}_bin.rpm \ + && rpm -ivh jdk-${JAVA_VERSION}_linux-${ARCH}_bin.rpm; \ + else \ + yum install -y java-${JAVA_VERSION}-openjdk-devel java-${JAVA_VERSION}-openjdk-devel.i686; \ + fi # maven ENV MAVEN_VERSION 3.5.3 RUN curl -f -L https://archive.apache.org/dist/maven/maven-3/$MAVEN_VERSION/binaries/apache-maven-$MAVEN_VERSION-bin.tar.gz | tar -C /opt -xzv ENV M2_HOME /opt/apache-maven-$MAVEN_VERSION -ENV JAVA_HOME /usr/lib/jvm/java-${JAVA_VERSIOIN}-openjdk +ENV JAVA_HOME $JDK_HOME ENV maven.home $M2_HOME ENV M2 $M2_HOME/bin ENV PATH $M2:$PATH:JAVA_HOME/bin @@ -28,6 +39,10 @@ ENV PATH ${PATH}:/opt/ant/bin # Set JDK to be 32bit COPY set_java $M2 -RUN $M2/set_java && rm $M2/set_java +RUN if [ "x${JAVA_VERSION}" = "x17" ]; then \ + rm $M2/set_java; \ + else \ + $M2/set_java && rm $M2/set_java; \ + fi CMD ["mvn","-version"]