Skip to content

Commit 751dc2c

Browse files
committed
Manually download and prepare boot JDKs
The problem with the previous approach of using Ubuntu packages was that JDK packages might not exist for the required boot JDK version, especially if that version is not an LTS one.
1 parent d5d4d40 commit 751dc2c

11 files changed

+22
-15
lines changed

Dockerfile

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,18 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive && apt-get -y instal
2020
libfontconfig1-dev
2121

2222
# Install boot JDK
23-
ARG BOOT_JDK_VERSION=18
24-
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive && apt-get -y install --no-install-recommends \
25-
"openjdk-${BOOT_JDK_VERSION}-jdk-headless"
23+
ARG BOOT_JDK_URL="https://github.com/adoptium/temurin18-binaries/releases/download/jdk-18.0.2.1+1/OpenJDK18U-jdk_x64_linux_hotspot_18.0.2.1_1.tar.gz"
24+
RUN apt-get -y install ca-certificates \
25+
&& wget --no-verbose "${BOOT_JDK_URL}" --output-document=boot-jdk.tar.gz \
26+
&& mkdir boot-jdk \
27+
# --strip-components because all JDK files are nested inside a directory in the archive
28+
&& tar -xzf boot-jdk.tar.gz -C boot-jdk --strip-components=1 \
29+
&& rm boot-jdk.tar.gz
2630

2731
# Set up CodeQL CLI
2832
ARG CODEQL_CLI_VERSION=2.10.5
29-
RUN wget -q "https://github.com/github/codeql-cli-binaries/releases/download/v${CODEQL_CLI_VERSION}/codeql-linux64.zip" --output-document=codeql-linux64.zip \
33+
RUN apt-get -y install ca-certificates \
34+
&& wget --no-verbose "https://github.com/github/codeql-cli-binaries/releases/download/v${CODEQL_CLI_VERSION}/codeql-linux64.zip" --output-document=codeql-linux64.zip \
3035
&& unzip -q -d codeql-cli codeql-linux64.zip \
3136
&& rm codeql-linux64.zip
3237

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ Note: Building the Docker image, the JDK and the CodeQL database are all resourc
3434

3535
### Docker image configuration
3636
The Dockerfile uses [build-time variables](https://docs.docker.com/engine/reference/commandline/build/#set-build-time-variables---build-arg) for configuration.
37-
- `BOOT_JDK_VERSION`: Version of the [boot JDK](https://github.com/openjdk/jdk/blob/master/doc/building.md#boot-jdk-requirements), e.g. `16`
38-
The value is used for the package retrieved from the package repository of Ubuntu, make sure that a package for this version exists.
37+
- `BOOT_JDK_URL`: URL of the JDK to be used as [boot JDK](https://github.com/openjdk/jdk/blob/master/doc/building.md#boot-jdk-requirements). The URL should be a download link for a `.tar.gz` file containing all JDK files nested in an extra directory. For example the [Eclipse Adoptium](https://adoptium.net) download URLs of the GitHub releases can be used.
3938
- `CODEQL_CLI_VERSION`: Version of [CodeQL CLI](https://github.com/github/codeql-cli-binaries/releases) to use for building the database, e.g. `2.5.7`
4039

4140
### Build configuration

docker_scripts/create_database.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ fi
145145
echo "Building JDK commit ${ACTUAL_COMMIT_SHA}"
146146

147147
# Specify build and host OS to avoid detection of WSL as Windows
148-
CONF_COMMAND="configure --build=x86_64-unknown-linux-gnu --host=x86_64-unknown-linux-gnu"
148+
# Boot JDK is prepared by Dockerfile
149+
CONF_COMMAND="configure --build=x86_64-unknown-linux-gnu --host=x86_64-unknown-linux-gnu --with-boot-jdk=../boot-jdk"
149150

150151
# Build performance customization
151152
# https://github.com/openjdk/jdk/blob/master/doc/building.md#build-performance

jdk-versions/jdk-11-linux.cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
IF NOT EXIST "databases/" mkdir databases || EXIT 1
33

44
@REM Build image, then start container (with `--rm` to remove it once finished)
5-
docker build .. -t codeql-jdk:11-linux --build-arg BOOT_JDK_VERSION=11 && docker container run --rm --name "codeql-jdk-11-linux-db-build" --mount type=bind,source="%cd%/databases",target=/codeql-jdk/codeql-jdk-databases codeql-jdk:11-linux --jdk-git-repo https://github.com/openjdk/jdk11u --jdk-version-name 11-linux %*
5+
docker build .. -t codeql-jdk:11-linux --build-arg BOOT_JDK_URL=https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.16.1+1/OpenJDK11U-jdk_x64_linux_hotspot_11.0.16.1_1.tar.gz && docker container run --rm --name "codeql-jdk-11-linux-db-build" --mount type=bind,source="%cd%/databases",target=/codeql-jdk/codeql-jdk-databases codeql-jdk:11-linux --jdk-git-repo https://github.com/openjdk/jdk11u --jdk-version-name 11-linux %*

jdk-versions/jdk-11-linux.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ set -e
44
# Create output directory
55
mkdir -p databases
66
# Build image, then start container (with `--rm` to remove it once finished)
7-
docker build .. -t codeql-jdk:11-linux --build-arg BOOT_JDK_VERSION=11
7+
docker build .. -t codeql-jdk:11-linux --build-arg BOOT_JDK_URL=https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.16.1+1/OpenJDK11U-jdk_x64_linux_hotspot_11.0.16.1_1.tar.gz
88
docker container run --rm --name "codeql-jdk-11-linux-db-build" --mount type=bind,source="$(pwd)/databases",target=/codeql-jdk/codeql-jdk-databases codeql-jdk:11-linux --jdk-git-repo https://github.com/openjdk/jdk11u --jdk-version-name 11-linux "$@"

jdk-versions/jdk-17-linux.cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
IF NOT EXIST "databases/" mkdir databases || EXIT 1
33

44
@REM Build image, then start container (with `--rm` to remove it once finished)
5-
docker build .. -t codeql-jdk:17-linux --build-arg BOOT_JDK_VERSION=16 && docker container run --rm --name "codeql-jdk-17-linux-db-build" --mount type=bind,source="%cd%/databases",target=/codeql-jdk/codeql-jdk-databases codeql-jdk:17-linux --jdk-git-repo https://github.com/openjdk/jdk17u --jdk-version-name 17-linux %*
5+
docker build .. -t codeql-jdk:17-linux --build-arg BOOT_JDK_URL=https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.4.1+1/OpenJDK17U-jdk_x64_linux_hotspot_17.0.4.1_1.tar.gz && docker container run --rm --name "codeql-jdk-17-linux-db-build" --mount type=bind,source="%cd%/databases",target=/codeql-jdk/codeql-jdk-databases codeql-jdk:17-linux --jdk-git-repo https://github.com/openjdk/jdk17u --jdk-version-name 17-linux %*

jdk-versions/jdk-17-linux.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ set -e
44
# Create output directory
55
mkdir -p databases
66
# Build image, then start container (with `--rm` to remove it once finished)
7-
docker build .. -t codeql-jdk:17-linux --build-arg BOOT_JDK_VERSION=16
7+
docker build .. -t codeql-jdk:17-linux --build-arg BOOT_JDK_URL=https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.4.1+1/OpenJDK17U-jdk_x64_linux_hotspot_17.0.4.1_1.tar.gz
88
docker container run --rm --name "codeql-jdk-17-linux-db-build" --mount type=bind,source="$(pwd)/databases",target=/codeql-jdk/codeql-jdk-databases codeql-jdk:17-linux --jdk-git-repo https://github.com/openjdk/jdk17u --jdk-version-name 17-linux "$@"

jdk-versions/jdk-8-linux.cmd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ IF NOT EXIST "databases/" mkdir databases || EXIT 1
55
@REM Note: https://hg.openjdk.java.net/jdk8/jdk8/raw-file/tip/README-builds.html#bootjdk says JDK 7 should
66
@REM be used as boot JDK, but using JDK 8 seems to work as well
77
@REM Uses Adoptium repository because https://github.com/openjdk/jdk8u is not updated anymore
8-
docker build .. -t codeql-jdk:8-linux --build-arg BOOT_JDK_VERSION=8 && docker container run --rm --name "codeql-jdk-8-linux-db-build" --mount type=bind,source="%cd%/databases",target=/codeql-jdk/codeql-jdk-databases codeql-jdk:8-linux --jdk-git-repo https://github.com/adoptium/jdk8u --make-target all --jdk-version-name 8-linux %*
8+
@REM EDIT: Apparently openjdk/jdk8u is updated again?
9+
docker build .. -t codeql-jdk:8-linux --build-arg BOOT_JDK_URL=https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u345-b01/OpenJDK8U-jdk_x64_linux_hotspot_8u345b01.tar.gz && docker container run --rm --name "codeql-jdk-8-linux-db-build" --mount type=bind,source="%cd%/databases",target=/codeql-jdk/codeql-jdk-databases codeql-jdk:8-linux --jdk-git-repo https://github.com/adoptium/jdk8u --make-target all --jdk-version-name 8-linux %*

jdk-versions/jdk-8-linux.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ mkdir -p databases
66
# Build image, then start container (with `--rm` to remove it once finished)
77
# Note: https://hg.openjdk.java.net/jdk8/jdk8/raw-file/tip/README-builds.html#bootjdk says JDK 7 should
88
# be used as boot JDK, but using JDK 8 seems to work as well
9-
docker build .. -t codeql-jdk:8-linux --build-arg BOOT_JDK_VERSION=8
9+
docker build .. -t codeql-jdk:8-linux --build-arg BOOT_JDK_URL=https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u345-b01/OpenJDK8U-jdk_x64_linux_hotspot_8u345b01.tar.gz
1010
# Uses Adoptium repository because https://github.com/openjdk/jdk8u is not updated anymore
11+
# EDIT: Apparently openjdk/jdk8u is updated again?
1112
docker container run --rm --name "codeql-jdk-8-linux-db-build" --mount type=bind,source="$(pwd)/databases",target=/codeql-jdk/codeql-jdk-databases codeql-jdk:8-linux --jdk-git-repo https://github.com/adoptium/jdk8u --make-target all --jdk-version-name 8-linux "$@"

jdk-versions/jdk-latest(19)-linux.cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
IF NOT EXIST "databases/" mkdir databases || EXIT 1
33

44
@REM Build image, then start container (with `--rm` to remove it once finished)
5-
docker build .. -t codeql-jdk:19-linux --build-arg BOOT_JDK_VERSION=18 && docker container run --rm --name "codeql-jdk-19-linux-db-build" --mount type=bind,source="%cd%/databases",target=/codeql-jdk/codeql-jdk-databases codeql-jdk:19-linux --jdk-git-repo https://github.com/openjdk/jdk19u --jdk-version-name 19-linux %*
5+
docker build .. -t codeql-jdk:19-linux --build-arg BOOT_JDK_URL=https://github.com/adoptium/temurin18-binaries/releases/download/jdk-18.0.2.1+1/OpenJDK18U-jdk_x64_linux_hotspot_18.0.2.1_1.tar.gz && docker container run --rm --name "codeql-jdk-19-linux-db-build" --mount type=bind,source="%cd%/databases",target=/codeql-jdk/codeql-jdk-databases codeql-jdk:19-linux --jdk-git-repo https://github.com/openjdk/jdk19u --jdk-version-name 19-linux %*

jdk-versions/jdk-latest(19)-linux.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ set -e
44
# Create output directory
55
mkdir -p databases
66
# Build image, then start container (with `--rm` to remove it once finished)
7-
docker build .. -t codeql-jdk:19-linux --build-arg BOOT_JDK_VERSION=18
7+
docker build .. -t codeql-jdk:19-linux --build-arg BOOT_JDK_URL=https://github.com/adoptium/temurin18-binaries/releases/download/jdk-18.0.2.1+1/OpenJDK18U-jdk_x64_linux_hotspot_18.0.2.1_1.tar.gz
88
docker container run --rm --name "codeql-jdk-19-linux-db-build" --mount type=bind,source="$(pwd)/databases",target=/codeql-jdk/codeql-jdk-databases codeql-jdk:19-linux --jdk-git-repo https://github.com/openjdk/jdk19u --jdk-version-name 19-linux "$@"

0 commit comments

Comments
 (0)