Build Windows images for smoke tests
MODIFY
.github/workflows/build-test-matrix.yaml
.github/workflows/build-test-matrix.yaml
@@ -5,11 +5,11 @@ on:
paths:
- 'smoke-tests/matrix/**'
- '.github/workflows/build-test-matrix.yaml'
- branches: 'main'
+ branches: ['main']
workflow_dispatch:
jobs:
- publish:
+ buildLinux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
@@ -34,5 +34,40 @@ jobs:
run: |
TAG="$(date '+%Y%m%d').$GITHUB_RUN_ID"
echo "Using extra tag $TAG"
- ./gradlew buildMatrix pushMatrix -PextraTag=$TAG
+ ./gradlew buildLinuxTestImages pushMatrix -PextraTag=$TAG
+ working-directory: smoke-tests/matrix
+
+ buildWindows:
+ runs-on: windows-latest
+ defaults:
+ run:
+ shell: bash
+ steps:
+ - name: Support longpaths
+ run: git config --system core.longpaths true
+
+ - uses: actions/checkout@v2
+
+ - name: Set up JDK 11 for running Gradle
+ uses: actions/setup-java@v1
+ with:
+ java-version: 11
+
+ - name: Cache gradle dependencies
+ uses: burrunan/gradle-cache-action@v1.10
+ with:
+ job-id: matrix-smoke
+
+ - name: Login to GitHub Package Registry
+ uses: docker/login-action@v1
+ with:
+ registry: ghcr.io
+ username: ${{ github.repository_owner }}
+ password: ${{ secrets.GHCR_TOKEN }}
+
+ - name: Build Docker Image
+ run: |
+ TAG="$(date '+%Y%m%d').$GITHUB_RUN_ID"
+ echo "Using extra tag $TAG"
+ ./gradlew buildWindowsTestImages pushMatrix -PextraTag=$TAG
working-directory: smoke-tests/matrix
\ No newline at end of file

MODIFY
smoke-tests/matrix/build.gradle
smoke-tests/matrix/build.gradle
@@ -11,28 +11,37 @@ compileJava {
}
repositories {
- jcenter()
+ mavenCentral()
}
+
dependencies {
implementation("javax.servlet:javax.servlet-api:3.0.1")
}
-def buildMatrixTask = tasks.create("buildMatrix") {
+def buildLinuxTestImagesTask = tasks.create("buildLinuxTestImages") {
group = "build"
- description = "Builds all Docker images for the test matrix"
+ description = "Builds all Linux Docker images for the test matrix"
+
+}
+
+def buildWindowsTestImagesTask = tasks.create("buildWindowsTestImages") {
+ group = "build"
+ description = "Builds all Windows Docker images for the test matrix"
+}
+
+ext {
+ matrix = []
}
-Set<String> matrix = []
tasks.create("pushMatrix", DockerPushImage) {
group = "publishing"
description = "Push all Docker images for the test matrix"
- dependsOn(buildMatrixTask)
- images.set(matrix)
+ images.set(project.ext.matrix)
}
// Each line under appserver describes one matrix of (version x vm x jdk), dockerfile key overrides
// Dockerfile name, args key passes raw arguments to docker build
-def targets = [
+def linuxTargets = [
"jetty": [
[version: ["9.4.35"], vm: ["hotspot", "openj9"], jdk: ["8", "11", "15"]],
[version: ["10.0.0"], vm: ["hotspot", "openj9"], jdk: ["11", "15"]],
@@ -61,14 +70,46 @@ def targets = [
]
]
-def configureImage(server, dockerfile, version, vm, jdk, Map<String, String> extraArgs) {
+def windowsTargets = [
+ "tomcat" : [
+ [version: ["7.0.107"], vm: ["hotspot", "openj9"], jdk: ["8"], args: [majorVersion: "7"]],
+ [version: ["8.5.60"], vm: ["hotspot", "openj9"], jdk: ["8", "11"], args: [majorVersion: "8"]],
+ [version: ["9.0.40"], vm: ["hotspot", "openj9"], jdk: ["8", "11"], args: [majorVersion: "9"]]
+ ],
+ "tomee" : [
+ [version: ["7.0.0"], vm: ["hotspot", "openj9"], jdk: ["8"]],
+ [version: ["8.0.6"], vm: ["hotspot", "openj9"], jdk: ["8", "11"]]
+ ],
+ "jetty" : [
+ [version: ["9.4.35"], vm: ["hotspot", "openj9"], jdk: ["8", "11", "15"], args: [sourceVersion: "9.4.35.v20201120"]],
+ [version: ["10.0.0"], vm: ["hotspot", "openj9"], jdk: ["11", "15"], dockerfile: "jetty-split", args: [sourceVersion: "10.0.0.beta3"]]
+ ],
+ "payara": [
+ [version: ["5.2020.6"], vm: ["hotspot", "openj9"], jdk: ["8", "11"]]
+ ],
+ "wildfly" : [
+ [version: ["13.0.0.Final"], vm: ["hotspot", "openj9"], jdk: ["8"]],
+ [version: ["17.0.1.Final", "21.0.0.Final"], vm: ["hotspot", "openj9"], jdk: ["8", "11"]]
+ ],
+ "liberty" : [
+ [version: ["20.0.0.12"], vm: ["hotspot", "openj9"], jdk: ["8", "11", "15"], args: [release: "2020-11-11_0736"]]
+ ]
+]
+
+createDockerTasks(buildLinuxTestImagesTask, linuxTargets, false)
+createDockerTasks(buildWindowsTestImagesTask, windowsTargets, true)
+
+def configureImage(Task parentTask, server, dockerfile, version, vm, jdk, Map<String, String> extraArgs, isWindows = false) {
def dockerWorkingDir = new File(project.buildDir, "docker")
+ def dockerFileName = isWindows ? "${dockerfile}.windows.dockerfile" : "${dockerfile}.dockerfile"
+ def platformSuffix = isWindows ? "-windows" : ""
- def prepareTask = tasks.register("${server}ImagePrepare-$version-jdk$jdk-$vm", Copy) {
+ def prepareTask = tasks.register("${server}ImagePrepare-$version-jdk$jdk-$vm$platformSuffix", Copy) {
def warTask = project.tasks.war
it.dependsOn(warTask)
it.into(dockerWorkingDir)
- it.from("src")
+ it.from("src/$dockerFileName")
+ it.from("src/main/docker/$server")
it.from(warTask.archiveFile) {
rename { _ -> "app.war" }
}
@@ -76,36 +117,41 @@ def configureImage(server, dockerfile, version, vm, jdk, Map<String, String> ext
def extraTag = findProperty("extraTag") ?: new Date().format("yyyyMMdd.HHmmSS")
def vmSuffix = vm == "hotspot" ? "" : "-$vm"
- def image = "ghcr.io/open-telemetry/java-test-containers:$server-$version-jdk$jdk$vmSuffix-$extraTag"
+ def image = "ghcr.io/open-telemetry/java-test-containers:$server-$version-jdk$jdk$vmSuffix$platformSuffix-$extraTag"
- def buildTask = tasks.register("${server}Image-$version-jdk$jdk$vmSuffix", DockerBuildImage) {
+ def buildTask = tasks.register("${server}Image-$version-jdk$jdk$vmSuffix$platformSuffix", DockerBuildImage) {
it.dependsOn(prepareTask)
group = "build"
- description = "Builds Docker image with $server $version on JDK $jdk"
+ description = "Builds Docker image with $server $version on JDK $jdk-$vm${isWindows ? ' on Windows' : ''}"
it.inputDir.set(dockerWorkingDir)
it.images.add(image)
- it.dockerFile.set(new File(dockerWorkingDir, dockerfile))
+ it.dockerFile.set(new File(dockerWorkingDir, dockerFileName))
it.buildArgs.set(extraArgs + [jdk: jdk, vm: vm, version: version])
+ it.doLast {
+ project.ext.matrix.add(image)
+ }
}
- project.tasks.buildMatrix.dependsOn(buildTask)
+ parentTask.dependsOn(buildTask)
return image
}
+def createDockerTasks(Task parentTask, targets, isWindows) {
+ Set<String> resultImages = []
targets.each { server, matrices ->
matrices.forEach { entry ->
- def dockerfile = (entry["dockerfile"]?.toString() ?: server) + ".dockerfile"
+ def dockerfile = entry["dockerfile"]?.toString() ?: server
def extraArgs = (entry["args"] ?: [:]) as Map<String, String>
entry.version.forEach { version ->
entry.vm.forEach { vm ->
entry.jdk.forEach { jdk ->
- matrix.add(configureImage(server, dockerfile, version, vm, jdk, extraArgs))
+ resultImages.add(configureImage(parentTask, server, dockerfile, version, vm, jdk, extraArgs, isWindows))
}
}
}
}
}
-
-assemble.dependsOn(buildMatrixTask)
\ No newline at end of file
+ return resultImages
+}
\ No newline at end of file

ADD
smoke-tests/matrix/src/jetty-split.windows.dockerfile
+ARG jdk
+ARG vm
+ARG sourceVersion
+
+# Unzip in a separate container so that zip file layer is not part of final image
+FROM mcr.microsoft.com/windows/servercore:1809 as builder
+ARG sourceVersion
+ADD https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-home/${sourceVersion}/jetty-home-${sourceVersion}.zip /server.zip
+RUN ["powershell", "-Command", "expand-archive -Path /server.zip -DestinationPath /server"]
+
+FROM adoptopenjdk:${jdk}-jdk-${vm}-windowsservercore-1809
+ARG sourceVersion
+# Make /server the base directory to simplify all further paths
+COPY --from=builder /server/jetty-home-${sourceVersion} /server
+RUN ["powershell", "-Command", "New-Item -Path / -Name base -ItemType directory"]
+WORKDIR /base
+ENV JETTY_HOME=/server
+ENV JETTY_BASE=/base
+RUN java -jar /server/start.jar --add-module=ext,server,jsp,resources,deploy,jstl,websocket,http
+COPY app.war /base/webapps/
+CMD java -jar /server/start.jar

ADD
smoke-tests/matrix/src/jetty.windows.dockerfile
+ARG jdk
+ARG vm
+ARG sourceVersion
+
+# Unzip in a separate container so that zip file layer is not part of final image
+FROM mcr.microsoft.com/windows/servercore:1809 as builder
+ARG sourceVersion
+ADD https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-distribution/${sourceVersion}/jetty-distribution-${sourceVersion}.zip /server.zip
+RUN ["powershell", "-Command", "expand-archive -Path /server.zip -DestinationPath /server"]
+
+FROM adoptopenjdk:${jdk}-jdk-${vm}-windowsservercore-1809
+ARG sourceVersion
+# Make /server the base directory to simplify all further paths
+COPY --from=builder /server/jetty-distribution-${sourceVersion} /server
+COPY app.war /server/webapps/
+RUN ["powershell", "-Command", "New-Item -Path /server -Name base -ItemType directory"]
+WORKDIR /server
+ENV JETTY_HOME=/server
+ENV JETTY_BASE=/server
+CMD java -jar /server/start.jar

MODIFY
smoke-tests/matrix/src/liberty.dockerfile
smoke-tests/matrix/src/liberty.dockerfile
@@ -14,7 +14,7 @@ ENV PATH=/opt/ol/wlp/bin:/opt/ol/docker/:/opt/ol/helpers/build:$PATH \
COPY --from=liberty $LIBERTY $LIBERTY
RUN ln -s /opt/ol/wlp/usr/servers/defaultServer /config
-COPY --chown=1001:0 liberty.xml /config/server.xml
+COPY --chown=1001:0 server.xml /config/server.xml
COPY --chown=1001:0 app.war /config/apps/
RUN configure.sh

ADD
smoke-tests/matrix/src/liberty.windows.dockerfile
+ARG jdk
+ARG vm
+ARG version
+ARG release
+
+# Unzip in a separate container so that zip file layer is not part of final image
+FROM mcr.microsoft.com/windows/servercore:1809 as builder
+ARG version
+ARG release
+ADD https://public.dhe.ibm.com/ibmdl/export/pub/software/openliberty/runtime/release/${release}/openliberty-${version}.zip /server.zip
+RUN ["powershell", "-Command", "expand-archive -Path /server.zip -DestinationPath /server"]
+
+FROM adoptopenjdk:${jdk}-jdk-${vm}-windowsservercore-1809
+ARG version
+# Make /server the base directory to simplify all further paths
+COPY --from=builder /server/wlp /server
+COPY server.xml /server/usr/servers/defaultServer/
+COPY app.war /server/usr/servers/defaultServer/apps/
+
+WORKDIR /server/bin
+CMD /server/bin/server.bat run defaultServer

RENAME
smoke-tests/matrix/src/liberty.xml
smoke-tests/matrix/src/main/docker/liberty/server.xml
ADD
smoke-tests/matrix/src/main/docker/payara/launch.bat
+java -jar glassfish/lib/client/appserver-cli.jar start-domain domain1
+powershell -command "Get-Content /server/glassfish/domains/domain1/logs/server.log -Wait"

ADD
smoke-tests/matrix/src/payara.windows.dockerfile
+ARG jdk
+ARG vm
+ARG version
+
+# Unzip in a separate container so that zip file layer is not part of final image
+FROM mcr.microsoft.com/windows/servercore:1809 as builder
+ARG version
+ADD https://s3-eu-west-1.amazonaws.com/payara.fish/Payara+Downloads/${version}/payara-${version}.zip /server.zip
+RUN ["powershell", "-Command", "expand-archive -Path /server.zip -DestinationPath /server"]
+RUN ["powershell", "-Command", "remove-item -Path /server/payara5/glassfish/modules/phonehome-bootstrap.jar"]
+
+FROM adoptopenjdk:${jdk}-jdk-${vm}-windowsservercore-1809
+ARG version
+# Make /server the base directory to simplify all further paths
+COPY --from=builder /server/payara5 /server
+COPY app.war /server/glassfish/domains/domain1/autodeploy/
+COPY launch.bat /server/
+WORKDIR /server
+CMD /server/launch.bat

ADD
smoke-tests/matrix/src/tomcat.windows.dockerfile
+ARG jdk
+ARG vm
+ARG majorVersion
+ARG version
+
+# Unzip in a separate container so that zip file layer is not part of final image
+FROM mcr.microsoft.com/windows/servercore:1809 as builder
+ARG majorVersion
+ARG version
+ADD https://archive.apache.org/dist/tomcat/tomcat-${majorVersion}/v${version}/bin/apache-tomcat-${version}-windows-x64.zip /server.zip
+RUN ["powershell", "-Command", "expand-archive -Path /server.zip -DestinationPath /server"]
+
+FROM adoptopenjdk:${jdk}-jdk-${vm}-windowsservercore-1809
+ARG version
+# Make /server the base directory to simplify all further paths
+COPY --from=builder /server/apache-tomcat-${version} /server
+# Delete default webapps to match the behavior of the official Linux Tomcat image
+RUN ["powershell", "-Command", "Remove-Item -Recurse -Path /server/webapps"]
+RUN ["powershell", "-Command", "New-Item -ItemType directory -Path /server/webapps"]
+COPY app.war /server/webapps/
+WORKDIR /server/bin
+CMD /server/bin/catalina.bat run

ADD
smoke-tests/matrix/src/tomee.windows.dockerfile
+ARG jdk
+ARG vm
+ARG version
+
+# Unzip in a separate container so that zip file layer is not part of final image
+FROM mcr.microsoft.com/windows/servercore:1809 as builder
+ARG majorVersion
+ARG version
+ADD https://archive.apache.org/dist/tomee/tomee-${version}/apache-tomee-${version}-webprofile.zip /server.zip
+RUN ["powershell", "-Command", "expand-archive -Path /server.zip -DestinationPath /server"]
+
+FROM adoptopenjdk:${jdk}-jdk-${vm}-windowsservercore-1809
+ARG version
+# Make /server the base directory to simplify all further paths
+COPY --from=builder /server/apache-tomee-webprofile-${version} /server
+COPY app.war /server/webapps/
+WORKDIR /server/bin
+CMD /server/bin/catalina.bat run

ADD
smoke-tests/matrix/src/wildfly.windows.dockerfile
+ARG jdk
+ARG vm
+ARG version
+
+# Unzip in a separate container so that zip file layer is not part of final image
+FROM mcr.microsoft.com/windows/servercore:1809 as builder
+ARG version
+ADD http://download.jboss.org/wildfly/${version}/wildfly-${version}.zip /server.zip
+RUN ["powershell", "-Command", "expand-archive -Path /server.zip -DestinationPath /server"]
+
+FROM adoptopenjdk:${jdk}-jdk-${vm}-windowsservercore-1809
+ARG version
+# Make /server the base directory to simplify all further paths
+COPY --from=builder /server/wildfly-${version} /server
+COPY app.war /server/standalone/deployments/
+WORKDIR /server/bin
+CMD /server/bin/standalone.bat -b 0.0.0.0

Build Windows images for smoke tests (#2568)