Skip to content
This repository was archived by the owner on Nov 30, 2023. It is now read-only.

Commit 2af1252

Browse files
authored
Start of JDK 17 support, build system support for multiple build args for a variant (#1113)
1 parent 59d5732 commit 2af1252

File tree

12 files changed

+1004
-230
lines changed

12 files changed

+1004
-230
lines changed

NOTICE.txt

+800
Large diffs are not rendered by default.

build/src/push.js

+19-4
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ async function push(repo, release, updateLatest, registry, registryPath, stubReg
3030
const stagingFolder = await configUtils.getStagingFolder(release);
3131
await configUtils.loadConfig(stagingFolder);
3232

33-
// Use or create a buildx / buildkit "builder" that using the docker-container driver that
33+
// Use or create a buildx / buildkit "builder" that using the docker-container driver which internally
3434
// uses QEMU to emulate different architectures for cross-platform builds. Setting up a separate
3535
// builder avoids problems with the default config being different otherwise altered. It also can
3636
// be tweaked down the road to use a different driver like using separate machines per architecture.
@@ -99,7 +99,8 @@ async function pushImage(definitionId, repo, release, updateLatest,
9999
// Determine tags to use
100100
const versionTags = configUtils.getTagList(definitionId, release, updateLatest, registry, registryPath, variant);
101101
console.log(`(*) Tags:${versionTags.reduce((prev, current) => prev += `\n ${current}`, '')}`);
102-
let architectures = configUtils.getBuildSettings(definitionId).architectures;
102+
const buildSettings = configUtils.getBuildSettings(definitionId);
103+
let architectures = buildSettings.architectures;
103104
switch (typeof architectures) {
104105
case 'string': architectures = [architectures]; break;
105106
case 'object': if (!Array.isArray(architectures)) { architectures = architectures[variant]; } break;
@@ -122,9 +123,23 @@ async function pushImage(definitionId, repo, release, updateLatest,
122123
if (replaceImage || !await isDefinitionVersionAlreadyPublished(definitionId, release, registry, registryPath, variant)) {
123124
const context = devContainerJson.build ? devContainerJson.build.context || '.' : devContainerJson.context || '.';
124125
const workingDir = path.resolve(dotDevContainerPath, context);
126+
// Add tags to buildx command params
127+
const buildParams = versionTags.reduce((prev, current) => prev.concat(['-t', current]), []);
125128
// Note: build.args in devcontainer.json is intentionally ignored so you can vary image contents and defaults as needed
126-
const buildParams = (variant ? ['--build-arg', `VARIANT=${variant}`] : [])
127-
.concat(versionTags.reduce((prev, current) => prev.concat(['-t', current]), []));
129+
// Add VARIANT --build-arg if applicable
130+
if(variant) {
131+
buildParams.push('--build-arg', `VARIANT=${variant}`);
132+
}
133+
// Generate list of --build-arg values if applicable
134+
for (let buildArg in buildSettings.buildArgs || {}) {
135+
buildParams.push('--build-arg', `${buildArg}=${buildSettings.buildArgs[buildArg]}`);
136+
}
137+
// Generate list of variant specific --build-arg values if applicable
138+
if (buildSettings.variantBuildArgs) {
139+
for (let buildArg in buildSettings.variantBuildArgs[variant] || {}) {
140+
buildParams.push('--build-arg', `${buildArg}=${buildSettings.variantBuildArgs[variant][buildArg]}`);
141+
}
142+
}
128143
const spawnOpts = { stdio: 'inherit', cwd: workingDir, shell: true };
129144
await asyncUtils.spawn('docker', [
130145
'buildx',

containers/java/.devcontainer/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# [Choice] Java version (use -bullseye variants on local arm64/Apple Silicon): 11, 16, 11-bullseye, 16-bullseye, 11-buster, 16-buster
1+
# [Choice] Java version (use -bullseye variants on local arm64/Apple Silicon): 11, 17, 11-bullseye, 17-bullseye, 11-buster, 17-buster
22
ARG VARIANT=11-bullseye
33
FROM mcr.microsoft.com/vscode/devcontainers/java:${VARIANT}
44

containers/java/.devcontainer/base.Dockerfile

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
# [Choice] Java version (use -bullseye variants on local arm64/Apple Silicon): 11-jdk-bullseye, 16-jdk-bullseye, 11-jdk-buster, 16-jdk-buster
2-
ARG VARIANT=11-jdk-buster
3-
FROM openjdk:${VARIANT}
1+
# This base.Dockerfile uses separate build arguments instead of VARIANT
2+
ARG TARGET_JAVA_VERSION=11
3+
ARG BASE_IMAGE_VERSION_CODENAME=bullseye
4+
FROM openjdk:${TARGET_JAVA_VERSION}-jdk-${BASE_IMAGE_VERSION_CODENAME}
45

56
# Copy library scripts to execute
67
COPY library-scripts/*.sh library-scripts/*.env /tmp/library-scripts/

containers/java/definition-manifest.json

+36-18
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,56 @@
11
{
2-
"variants": [ "16-jdk-bullseye", "11-jdk-bullseye", "16-jdk-buster", "11-jdk-buster" ],
3-
"definitionVersion": "0.203.0",
2+
"variants": [ "17-bullseye", "17-buster", "11-bullseye", "11-buster" ],
3+
"definitionVersion": "0.204.0",
44
"build": {
5-
"latest": "16-jdk-buster",
5+
"latest": "17-bullseye",
66
"rootDistro": "debian",
7+
"variantBuildArgs": {
8+
"17-bullseye": {
9+
"TARGET_JAVA_VERSION": "17",
10+
"BASE_IMAGE_VERSION_CODENAME": "bullseye"
11+
},
12+
"11-bullseye": {
13+
"TARGET_JAVA_VERSION": "11",
14+
"BASE_IMAGE_VERSION_CODENAME": "bullseye"
15+
},
16+
"17-buster": {
17+
"TARGET_JAVA_VERSION": "17",
18+
"BASE_IMAGE_VERSION_CODENAME": "buster"
19+
},
20+
"11-buster": {
21+
"JAVA_IMAGE_TAG": "11",
22+
"BASE_IMAGE_VERSION_CODENAME": "buster"
23+
}
24+
},
725
"architectures": {
8-
"16-jdk-bullseye": ["linux/amd64", "linux/arm64"],
9-
"11-jdk-bullseye": ["linux/amd64", "linux/arm64"],
10-
"16-jdk-buster": ["linux/amd64"],
11-
"11-jdk-buster": ["linux/amd64"]
26+
"17-bullseye": ["linux/amd64", "linux/arm64"],
27+
"11-bullseye": ["linux/amd64", "linux/arm64"],
28+
"17-buster": ["linux/amd64"],
29+
"11-buster": ["linux/amd64"]
1230
},
1331
"tags": [
1432
"java:${VERSION}-${VARIANT}"
1533
],
1634
"variantTags": {
17-
"16-jdk-bullseye": [
18-
"java:${VERSION}-16-bullseye",
35+
"17-bullseye": [
36+
"java:${VERSION}-17",
37+
"java:${VERSION}-17-jdk-bullseye",
1938
"java:${VERSION}-bullseye"
2039
],
21-
"11-jdk-bullseye": [ "java:${VERSION}-11-bullseye" ],
22-
"16-jdk-buster": [
23-
"java:${VERSION}-16",
24-
"java:${VERSION}-16-buster",
40+
"11-bullseye": [
41+
"java:${VERSION}-11",
42+
"java:${VERSION}-11-jdk-bullseye"
43+
],
44+
"17-jdk-buster": [
45+
"java:${VERSION}-17-jdk-buster",
2546
"java:${VERSION}-buster"
2647
],
27-
"11-jdk-buster": [
28-
"java:${VERSION}-11",
29-
"java:${VERSION}-11-buster"
30-
]
48+
"11-buster": [ "java:${VERSION}-11-jdk-buster" ]
3149
}
3250
},
3351
"dependencies": {
3452
"image": "openjdk:${VARIANT}",
35-
"imageLink": "https://hub.docker.com/_/java",
53+
"imageLink": "https://hub.docker.com/_/openjdk",
3654
"apt": [{
3755
"cgIgnore": false,
3856
"name": "yarn"

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
"prepack": "rimraf containers-readmes manifests container-features && copyfiles --up 1 containers/**/README.md containers-readmes && copyfiles --up 1 containers/**/definition-manifest.json manifests && copyfiles --up 1 script-library/*.sh container-features && copyfiles --up 3 script-library/container-features/src/* container-features"
2020
},
2121
"devDependencies": {
22-
"copyfiles": "^2.1.1",
22+
"copyfiles": "^2.4.1",
2323
"glob": "^7.1.6",
2424
"jsonc": "^2.0.0",
2525
"rimraf": "^2.6.3",
26-
"yargs": "^14.2.0",
26+
"yargs": "^17.2.1",
2727
"handlebars": "^4.7.7"
2828
}
2929
}

script-library/container-features/src/features.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@
732732
"options": {
733733
"version": {
734734
"type": "string",
735-
"proposals": ["lts", "latest", "16", "11", "8"],
735+
"proposals": ["lts", "latest", "17", "11", "8"],
736736
"default": "lts",
737737
"description": "Select or enter a Java version to install"
738738
}

script-library/gradle-debian.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ sdk_install() {
8282
local suffix="${4:-"\\s*"}"
8383
local full_version_check=${5:-".*-[a-z]+"}
8484
if [ "${requested_version}" = "none" ]; then return; fi
85-
# Blank will install latest stable AdoptOpenJDK version
85+
# Blank will install latest stable version
8686
if [ "${requested_version}" = "lts" ] || [ "${requested_version}" = "default" ]; then
8787
requested_version=""
8888
elif echo "${requested_version}" | grep -oE "${full_version_check}" > /dev/null 2>&1; then

script-library/java-debian.sh

+8-2
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ sdk_install() {
8282
local suffix="${4:-"\\s*"}"
8383
local full_version_check=${5:-".*-[a-z]+"}
8484
if [ "${requested_version}" = "none" ]; then return; fi
85-
# Blank will install latest stable AdoptOpenJDK version
85+
# Blank will install latest stable version
8686
if [ "${requested_version}" = "lts" ] || [ "${requested_version}" = "default" ]; then
8787
requested_version=""
8888
elif echo "${requested_version}" | grep -oE "${full_version_check}" > /dev/null 2>&1; then
@@ -131,6 +131,12 @@ if [ ! -d "${SDKMAN_DIR}" ]; then
131131
# Add sourcing of sdkman into bashrc/zshrc files (unless disabled)
132132
updaterc "export SDKMAN_DIR=${SDKMAN_DIR}\n. \${SDKMAN_DIR}/bin/sdkman-init.sh"
133133
fi
134-
sdk_install java ${JAVA_VERSION} "\\s*" "(\\.[a-z0-9]+)?-adpt\\s*" ".*-[a-z]+$"
134+
135+
# Use Microsoft JDK for everything but JDK 8
136+
jdk_distro="ms"
137+
if echo "${JAVA_VERSION}" | grep -E '^8([\s\.]|$)' > /dev/null 2>&1; then
138+
jdk_distro="tem"
139+
fi
140+
sdk_install java ${JAVA_VERSION} "\\s*" "(\\.[a-z0-9]+)*-${jdk_distro}\\s*" ".*-[a-z]+$"
135141

136142
echo "Done!"

script-library/maven-debian.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ sdk_install() {
8282
local suffix="${4:-"\\s*"}"
8383
local full_version_check=${5:-".*-[a-z]+"}
8484
if [ "${requested_version}" = "none" ]; then return; fi
85-
# Blank will install latest stable AdoptOpenJDK version
85+
# Blank will install latest stable version
8686
if [ "${requested_version}" = "lts" ] || [ "${requested_version}" = "default" ]; then
8787
requested_version=""
8888
elif echo "${requested_version}" | grep -oE "${full_version_check}" > /dev/null 2>&1; then

script-library/shared/utils.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ sdk_install() {
6969
local suffix="${4:-"\\s*"}"
7070
local full_version_check=${5:-".*-[a-z]+"}
7171
if [ "${requested_version}" = "none" ]; then return; fi
72-
# Blank will install latest stable AdoptOpenJDK version
72+
# Blank will install latest stable version
7373
if [ "${requested_version}" = "lts" ] || [ "${requested_version}" = "default" ]; then
7474
requested_version=""
7575
elif echo "${requested_version}" | grep -oE "${full_version_check}" > /dev/null 2>&1; then

0 commit comments

Comments
 (0)