Skip to content
Snippets Groups Projects
Commit 4b350183 authored by Jason Leasure's avatar Jason Leasure
Browse files

Use jlink to shrink JDKs

parent 4d6c04bc
No related branches found
No related tags found
No related merge requests found
Pipeline #1628766685 passed
Pipeline: Custom CA

#1628772007

    ...@@ -12,8 +12,8 @@ COPY . . ...@@ -12,8 +12,8 @@ COPY . .
    # build the analyzer binary and automatically set the AnalyzerVersion # build the analyzer binary and automatically set the AnalyzerVersion
    # variable to the most recent version from the CHANGELOG.md file # variable to the most recent version from the CHANGELOG.md file
    RUN CHANGELOG_VERSION=$(grep -m 1 '^## v.*$' "CHANGELOG.md" | sed 's/## v//') && \ RUN CHANGELOG_VERSION=$(grep -m 1 '^## v.*$' "CHANGELOG.md" | sed 's/## v//') && \
    PATH_TO_MODULE=`go list -m` && \ PATH_TO_MODULE=`go list -m` && \
    go build -ldflags="-X '$PATH_TO_MODULE/metadata.AnalyzerVersion=$CHANGELOG_VERSION'" -o analyzer go build -ldflags="-X '$PATH_TO_MODULE/metadata.AnalyzerVersion=$CHANGELOG_VERSION'" -o analyzer
    FROM alpine:3.14 FROM alpine:3.14
    ...@@ -57,7 +57,9 @@ COPY --chown=gitlab config /home/gitlab ...@@ -57,7 +57,9 @@ COPY --chown=gitlab config /home/gitlab
    WORKDIR /home/gitlab WORKDIR /home/gitlab
    RUN apk add --no-cache binutils
    RUN bash /home/gitlab/install.sh RUN bash /home/gitlab/install.sh
    RUN apk del binutils
    ENV HOME=/home/gitlab ENV HOME=/home/gitlab
    ENV MAVEN_REPO_PATH=/home/gitlab ENV MAVEN_REPO_PATH=/home/gitlab
    ......
    ...@@ -33,30 +33,40 @@ asdf current ...@@ -33,30 +33,40 @@ asdf current
    # shellcheck source=/dev/null # shellcheck source=/dev/null
    . "$ASDF_DATA_DIR"/plugins/ant/set-ant-home.bash . "$ASDF_DATA_DIR"/plugins/ant/set-ant-home.bash
    asdf list java | while read -r jdk_version; do
    (
    cd "$ASDF_DATA_DIR/installs/java"
    jlink_bin="./$jdk_version/bin/jlink"
    "$jlink_bin" --verbose --add-modules ALL-MODULE-PATH --strip-debug --no-man-pages --no-header-files --compress=2 --output ./shrunk
    rm -rf "$jdk_version"
    mv shrunk "$jdk_version"
    )
    done
    # Ensure that Java is working correctly by printing the version. # Ensure that Java is working correctly by printing the version.
    asdf list java | while read -r jdk_version ; do asdf list java | while read -r jdk_version; do
    java_bin="$(asdf which java "$jdk_version")" java_bin="$(asdf which java "$jdk_version")"
    $java_bin -version 2&> /dev/null $java_bin -version 2 &>/dev/null
    exit_code=$? exit_code=$?
    if [ $exit_code -ne 0 ]; then if [ $exit_code -ne 0 ]; then
    echo "Java installation check failed. Attempted to run '$java_bin -version' and got exit code $exit_code" && exit 1 echo "Java installation check failed. Attempted to run '$java_bin -version' and got exit code $exit_code" && exit 1
    fi fi
    done; done
    # Install SpotBugs CLI # Install SpotBugs CLI
    cd /spotbugs; \ cd /spotbugs
    mkdir -p dist; \ mkdir -p dist
    curl -LO "https://repo.maven.apache.org/maven2/com/github/spotbugs/spotbugs/${SCANNER_VERSION}/spotbugs-${SCANNER_VERSION}.tgz"; \ curl -LO "https://repo.maven.apache.org/maven2/com/github/spotbugs/spotbugs/${SCANNER_VERSION}/spotbugs-${SCANNER_VERSION}.tgz"
    tar xzf "spotbugs-${SCANNER_VERSION}.tgz" -C dist --strip-components 1; \ tar xzf "spotbugs-${SCANNER_VERSION}.tgz" -C dist --strip-components 1
    rm -f "spotbugs-${SCANNER_VERSION}.tgz" rm -f "spotbugs-${SCANNER_VERSION}.tgz"
    # Install FindSecBugs for use as a SpotBugs plugin # Install FindSecBugs for use as a SpotBugs plugin
    mkdir -p /fsb; \ mkdir -p /fsb
    cd /fsb; \ cd /fsb
    curl -LO "https://github.com/find-sec-bugs/find-sec-bugs/releases/download/version-${FINDSECBUGS_VERSION}/findsecbugs-cli-${FINDSECBUGS_VERSION}.zip"; \ curl -LO "https://github.com/find-sec-bugs/find-sec-bugs/releases/download/version-${FINDSECBUGS_VERSION}/findsecbugs-cli-${FINDSECBUGS_VERSION}.zip"
    unzip -n "findsecbugs-cli-${FINDSECBUGS_VERSION}.zip"; \ unzip -n "findsecbugs-cli-${FINDSECBUGS_VERSION}.zip"
    rm -f "findsecbugs-cli-${FINDSECBUGS_VERSION}.zip"; \ rm -f "findsecbugs-cli-${FINDSECBUGS_VERSION}.zip"
    mv "lib/findsecbugs-plugin-${FINDSECBUGS_VERSION}.jar" lib/findsecbugs-plugin.jar mv "lib/findsecbugs-plugin-${FINDSECBUGS_VERSION}.jar" lib/findsecbugs-plugin.jar
    echo ["$(date "+%H:%M:%S")"] "==> Beginning cleanup…" echo ["$(date "+%H:%M:%S")"] "==> Beginning cleanup…"
    ......
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment