From 8260f93e6cb1b2567887f53b7d8d86933dcd35b6 Mon Sep 17 00:00:00 2001 From: Jason Montleon Date: Fri, 11 Aug 2023 08:18:10 -0400 Subject: [PATCH] :ghost: Fix GitHub Action Builds (#56) Signed-off-by: Jason Montleon --- .../workflows/multi-arch_images_build.yaml | 6 +++++ Dockerfile | 24 ++++++++++--------- hack/maven.default.index | 14 +++++++++++ 3 files changed, 33 insertions(+), 11 deletions(-) create mode 100644 hack/maven.default.index diff --git a/.github/workflows/multi-arch_images_build.yaml b/.github/workflows/multi-arch_images_build.yaml index 492ed20..a4b8aea 100644 --- a/.github/workflows/multi-arch_images_build.yaml +++ b/.github/workflows/multi-arch_images_build.yaml @@ -25,9 +25,15 @@ jobs: with: architectures: "amd64, arm64, ppc64le, s390x" containerfile: "./Dockerfile" + extra-args: "--build-arg BUILDENV=github" image_name: "jdtls-server-base" image_namespace: "konveyor" image_registry: "quay.io" quay_publish_robot: ${{ secrets.QUAY_PUBLISH_ROBOT }} quay_publish_token: ${{ secrets.QUAY_PUBLISH_TOKEN }} + pre_build_cmd: | + curl -s -o nexus-maven-repository-index.gz https://repo.maven.apache.org/maven2/.index/nexus-maven-repository-index.gz + unpigz nexus-maven-repository-index.gz + cat nexus-maven-repository-index | parallel -j150% --pipe --block 100M --cat grep -oaP "'[a-z][a-zA-Z0-9_.-]+\|[a-zA-Z][a-zA-Z0-9_.-]+\|([a-zA-Z0-9_.-]+\|)?(sources|pom|jar|maven-plugin|ear|ejb|ejb-client|java-source|rar|war)\|(jar|war|ear|pom|war|rar)'" {} | cut -d'|' -f1 | sed 's/$/.*/' | sort | uniq > hack/maven.default.index + rm -rf nexus-maven-repository-index ref: ${{ github.ref }} diff --git a/Dockerfile b/Dockerfile index 3b11adb..b8a1738 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,32 +1,34 @@ FROM registry.access.redhat.com/ubi9/ubi AS jdtls-download WORKDIR /jdtls -RUN curl -o jdtls.tar.gz https://download.eclipse.org/jdtls/milestones/1.16.0/jdt-language-server-1.16.0-202209291445.tar.gz &&\ +RUN curl -s -o jdtls.tar.gz https://download.eclipse.org/jdtls/milestones/1.16.0/jdt-language-server-1.16.0-202209291445.tar.gz &&\ tar -xvf jdtls.tar.gz --no-same-owner &&\ - chmod 755 /jdtls/bin/jdtls + chmod 755 /jdtls/bin/jdtls &&\ + rm -rf jdtls.tar.gz FROM registry.access.redhat.com/ubi9/ubi AS maven-index -RUN curl -o nexus-maven-repository-index.gz https://repo.maven.apache.org/maven2/.index/nexus-maven-repository-index.gz &&\ - gunzip -k nexus-maven-repository-index.gz &&\ - grep -oaP '[a-z][a-zA-Z0-9_.-]+\|[a-zA-Z][a-zA-Z0-9_.-]+\|([a-zA-Z0-9_.-]+\|)?(sources|pom|jar|maven-plugin|ear|ejb|ejb-client|java-source|rar|war)\|(jar|war|ear|pom|war|rar)' nexus-maven-repository-index | cut -d'|' -f1 | sed 's/$/.*/' | sort | uniq > /maven.default.index +ARG BUILDENV=local +COPY hack/maven.default.index /maven.default.index +RUN if [ $BUILDENV == "local" ]; then curl -s -o nexus-maven-repository-index.gz https://repo.maven.apache.org/maven2/.index/nexus-maven-repository-index.gz &&\ + zgrep -oaP '[a-z][a-zA-Z0-9_.-]+\|[a-zA-Z][a-zA-Z0-9_.-]+\|([a-zA-Z0-9_.-]+\|)?(sources|pom|jar|maven-plugin|ear|ejb|ejb-client|java-source|rar|war)\|(jar|war|ear|pom|war|rar)' nexus-maven-repository-index.gz | cut -d'|' -f1 | sed 's/$/.*/' | sort | uniq > /maven.default.index &&\ + rm -rf nexus-maven-repository-index.gz; fi FROM registry.access.redhat.com/ubi9/ubi AS fernflower -RUN dnf install -y maven-openjdk17 wget -RUN wget https://github.com/JetBrains/intellij-community/archive/refs/tags/idea/231.9011.34.tar.gz -O intellij-community.tar && tar xf intellij-community.tar +RUN dnf install -y maven-openjdk17 wget --setopt=install_weak_deps=False && dnf clean all && rm -rf /var/cache/dnf +RUN wget --quiet https://github.com/JetBrains/intellij-community/archive/refs/tags/idea/231.9011.34.tar.gz -O intellij-community.tar && tar xf intellij-community.tar intellij-community-idea-231.9011.34/plugins/java-decompiler/engine && rm -rf intellij-community.tar WORKDIR /intellij-community-idea-231.9011.34/plugins/java-decompiler/engine RUN export JAVA_HOME=/usr/lib/jvm/java-17-openjdk -RUN ./gradlew build -x test +RUN ./gradlew build -x test && rm -rf /root/.gradle RUN mkdir /output && cp ./build/libs/fernflower.jar /output FROM registry.access.redhat.com/ubi9/ubi AS addon-build -RUN dnf install -y maven-openjdk17 +RUN dnf install -y maven-openjdk17 && dnf clean all && rm -rf /var/cache/dnf WORKDIR /app COPY ./ /app/ RUN export JAVA_HOME=/usr/lib/jvm/java-17-openjdk RUN JAVA_HOME=/usr/lib/jvm/java-17-openjdk mvn clean install -DskipTests=true FROM registry.access.redhat.com/ubi9/ubi-minimal -RUN microdnf install -y python39 java-17-openjdk go-toolset maven-openjdk17 -RUN microdnf clean all +RUN microdnf install -y python39 java-17-openjdk go-toolset maven-openjdk17 && microdnf clean all && rm -rf /var/cache/dnf RUN go install golang.org/x/tools/gopls@latest ENV JAVA_HOME /usr/lib/jvm/java-17-openjdk COPY --from=jdtls-download /jdtls /jdtls/ diff --git a/hack/maven.default.index b/hack/maven.default.index new file mode 100644 index 0000000..464b545 --- /dev/null +++ b/hack/maven.default.index @@ -0,0 +1,14 @@ +# Fake maven.default.index to COPY when BUILDENV=local +# +# This file takes far too long to generate on alternate architectures using +# emulation in GitHub actions. +# +# It is not possible to conditionally run a Dockerfile / Containerfile COPY +# But we can use an ARG to manipulate what happens in a RUN command, so we +# either overwrite this file in GitHub before starting the container build, +# copy it into the container and skip generating it within the container or +# copy it in and overwrite it within the container when building locally. +# +# This means no additional steps have to be added to the development workflow. +# +# If this message appears in a container image something went wrong.