From f370e1c28bdc4fe9dd3df65d9551dc17c1869178 Mon Sep 17 00:00:00 2001 From: Alex Earl Date: Wed, 7 Aug 2019 08:24:49 -0700 Subject: [PATCH 01/38] Fix #34 Add Windows images for everything but slim and IBM JDK --- README.md | 50 ++++++++++++--- amazoncorretto-11/Dockerfile.windows | 46 +++++++++++++ amazoncorretto-11/mvn-entrypoint.ps1 | 48 ++++++++++++++ amazoncorretto-8/Dockerfile.windows | 46 +++++++++++++ amazoncorretto-8/mvn-entrypoint.ps1 | 48 ++++++++++++++ azulzulu-11/Dockerfile.windows | 46 +++++++++++++ azulzulu-11/mvn-entrypoint.ps1 | 48 ++++++++++++++ jdk-11/Dockerfile.windows | 34 ++++++++++ jdk-11/mvn-entrypoint.ps1 | 48 ++++++++++++++ jdk-12/Dockerfile.windows | 34 ++++++++++ jdk-12/mvn-entrypoint.ps1 | 48 ++++++++++++++ jdk-13/Dockerfile.windows | 34 ++++++++++ jdk-13/mvn-entrypoint.ps1 | 48 ++++++++++++++ jdk-14/Dockerfile.windows | 34 ++++++++++ jdk-14/mvn-entrypoint.ps1 | 48 ++++++++++++++ jdk-8/Dockerfile.windows | 34 ++++++++++ jdk-8/mvn-entrypoint.ps1 | 48 ++++++++++++++ tests/Dockerfile.windows | 7 ++ tests/maven.Tests.ps1 | 73 +++++++++++++++++++++ tests/test_helpers.psm1 | 96 ++++++++++++++++++++++++++++ 20 files changed, 910 insertions(+), 8 deletions(-) create mode 100644 amazoncorretto-11/Dockerfile.windows create mode 100644 amazoncorretto-11/mvn-entrypoint.ps1 create mode 100644 amazoncorretto-8/Dockerfile.windows create mode 100644 amazoncorretto-8/mvn-entrypoint.ps1 create mode 100644 azulzulu-11/Dockerfile.windows create mode 100644 azulzulu-11/mvn-entrypoint.ps1 create mode 100644 jdk-11/Dockerfile.windows create mode 100644 jdk-11/mvn-entrypoint.ps1 create mode 100644 jdk-12/Dockerfile.windows create mode 100644 jdk-12/mvn-entrypoint.ps1 create mode 100644 jdk-13/Dockerfile.windows create mode 100644 jdk-13/mvn-entrypoint.ps1 create mode 100644 jdk-14/Dockerfile.windows create mode 100644 jdk-14/mvn-entrypoint.ps1 create mode 100644 jdk-8/Dockerfile.windows create mode 100644 jdk-8/mvn-entrypoint.ps1 create mode 100644 tests/Dockerfile.windows create mode 100644 tests/maven.Tests.ps1 create mode 100644 tests/test_helpers.psm1 diff --git a/README.md b/README.md index 8aac8dee..8fe16ec7 100644 --- a/README.md +++ b/README.md @@ -6,19 +6,26 @@ docker-maven See [Docker Hub](https://hub.docker.com/_/maven) for updated list of tags * [jdk-8](https://github.com/carlossg/docker-maven/blob/master/jdk-8/Dockerfile) +* [jdk-8-windows](https://github.com/carlossg/docker-maven/blob/master/jdk-8/Dockerfile.windows) * [jdk-8-slim](https://github.com/carlossg/docker-maven/blob/master/jdk-8-slim/Dockerfile) * [jdk-10](https://github.com/carlossg/docker-maven/blob/master/jdk-10/Dockerfile) * [jdk-10-slim](https://github.com/carlossg/docker-maven/blob/master/jdk-10-slim/Dockerfile) * [jdk-11](https://github.com/carlossg/docker-maven/blob/master/jdk-11/Dockerfile) +* [jdk-11-windows](https://github.com/carlossg/docker-maven/blob/master/jdk-11/Dockerfile.windows) * [jdk-11-slim](https://github.com/carlossg/docker-maven/blob/master/jdk-11-slim/Dockerfile) * [jdk-12](https://github.com/carlossg/docker-maven/blob/master/jdk-12/Dockerfile) +* [jdk-12-windows](https://github.com/carlossg/docker-maven/blob/master/jdk-12/Dockerfile.windows) * [jdk-13](https://github.com/carlossg/docker-maven/blob/master/jdk-13/Dockerfile) +* [jdk-13-windows](https://github.com/carlossg/docker-maven/blob/master/jdk-13/Dockerfile.windows) * [jdk-14](https://github.com/carlossg/docker-maven/blob/master/jdk-14/Dockerfile) * [ibmjava-8](https://github.com/carlossg/docker-maven/blob/master/ibmjava-8/Dockerfile) * [ibmjava-8-alpine](https://github.com/carlossg/docker-maven/blob/master/ibmjava-8-alpine/Dockerfile) * [amazoncorretto-8](https://github.com/carlossg/docker-maven/blob/master/amazoncorretto-8/Dockerfile) -* [amazoncorretto-11](https://github.com/carlossg/docker-maven/blob/master/amazoncorretto-11/ -* [azulzulu-11](https://github.com/carlossg/docker-maven/blob/master/azulzulu-11/ +* [amazoncorretto-8-windows](https://github.com/carlossg/docker-maven/blob/master/amazoncorretto-8/Dockerfile.windows) +* [amazoncorretto-11](https://github.com/carlossg/docker-maven/blob/master/amazoncorretto-11/Dockerfile) +* [amazoncorretto-11-windows](https://github.com/carlossg/docker-maven/blob/master/amazoncorretto-11/Dockerfile.windows) +* [azulzulu-11](https://github.com/carlossg/docker-maven/blob/master/azulzulu-11/) +* [azulzulu-11-windows](https://github.com/carlossg/docker-maven/blob/master/azulzulu-11/Dockerfile.windows) # What is Maven? @@ -33,14 +40,26 @@ reporting and documentation from a central piece of information. You can run a Maven project by using the Maven Docker image directly, passing a Maven command to `docker run`: +### Linux + docker run -it --rm --name my-maven-project -v "$(pwd)":/usr/src/mymaven -w /usr/src/mymaven maven:3.3-jdk-8 mvn clean install +### Windows + + docker run -it --rm --name my-maven-project -v "$(Get-Location)":C:/Src -w C:/Src maven:3.3-jdk-8-windows mvn clean install + ## Building local Docker image (optional) This is a base image that you can extend, so it has the bare minimum packages needed. If you add custom package(s) to the `Dockerfile`, then you can build your local Docker image like this: +### Linux + docker build --tag my_local_maven:3.6.0-jdk-8 . +### Windows + + docker build -f Dockerfile.windows --tag my_local_maven:3-jdk-9-windows --build-arg WINDOWS_DOCKER_TAG=1803 . + # Multi-stage Builds @@ -75,12 +94,15 @@ Or you can just use your home .m2 cache directory that you share e.g. with your # Packaging a local repository with the image -The `$MAVEN_CONFIG` dir (default to `/root/.m2`) could be configured as a volume so anything copied there in a Dockerfile at build time is lost. -For that reason the dir `/usr/share/maven/ref/` exists, and anything in that directory will be copied on container startup to `$MAVEN_CONFIG`. +The `$MAVEN_CONFIG` dir (default to `/root/.m2` or `C:\Users\ContainerAdministrator\.m2`) could be configured as a volume so anything copied there in a Dockerfile +at build time is lost. For that reason the dir `/usr/share/maven/ref/` (or `C:\ProgramData\Maven\Reference`) exists, and anything in that directory will be copied +on container startup to `$MAVEN_CONFIG`. To create a pre-packaged repository, create a `pom.xml` with the dependencies you need and use this in your `Dockerfile`. -`/usr/share/maven/ref/settings-docker.xml` is a settings file that changes the local repository to `/usr/share/maven/ref/repository`, -but you can use your own settings file as long as it uses `/usr/share/maven/ref/repository` as local repo. +`/usr/share/maven/ref/settings-docker.xml` (`C:\ProgramData\Maven\Reference\settings-docker.xml`) is a settings file that +changes the local repository to `/usr/share/maven/ref/repository` (`C:\Programdata\Maven\Reference\repository`), +but you can use your own settings file as long as it uses `/usr/share/maven/ref/repository` (`C:\ProgramData\Maven\Reference\repository`) +as local repo. COPY pom.xml /tmp/pom.xml RUN mvn -B -f /tmp/pom.xml -s /usr/share/maven/ref/settings-docker.xml dependency:resolve @@ -92,7 +114,7 @@ To add your custom `settings.xml` file to the image use For an example, check the `tests` dir -# Running as non-root +# Running as non-root (not supported on Windows) Maven needs the user home to download artifacts to, and if the user does not exist in the image an extra `user.home` Java property needs to be set. @@ -116,15 +138,25 @@ Build with the usual docker build -t maven . -Tests are written using [bats](https://github.com/sstephenson/bats) under the `tests` dir. +Tests are written using [bats](https://github.com/sstephenson/bats) for Linux images and [pester](https://github.com/pester/Pester) for Windows images +(requires Pester 4.x) under the `tests` dir. + Use the env var TAG to choose what image to run tests against. +### Linux TAG=jdk-11 bats tests +### Windows + $env:TAG="jdk-11" ; Invoke-Pester -Path tests + or run all the tests with +### Linux for dir in $(/bin/ls -1 -d */ | grep -v tests); do TAG=$(basename $dir) bats tests; done +### Windows + Get-ChildItem -Directory -Exclude tests,ibm*,*slim | ForEach-Object { Push-Location ; $env:TAG=$_.Name ; Invoke-Pester -Path tests ; Pop-Location } + Bats can be easily installed with `brew install bats` on OS X. Note that you may first need to: @@ -134,6 +166,8 @@ git submodule init git submodule update ``` +Pester comes with most modern Windows (Windows 10 and Windows Server 2019), but is an older version than required. You may need to follow [this tutorial](https://blog.damianflynn.com/Windows10-Pester/) on upgrading Pester to 4.x. + # License View [license information](https://www.apache.org/licenses/) for the software contained in this image. diff --git a/amazoncorretto-11/Dockerfile.windows b/amazoncorretto-11/Dockerfile.windows new file mode 100644 index 00000000..c8476544 --- /dev/null +++ b/amazoncorretto-11/Dockerfile.windows @@ -0,0 +1,46 @@ +# escape=` +ARG WINDOWS_DOCKER_TAG=ltsc2019 +FROM mcr.microsoft.com/windows/servercore:$WINDOWS_DOCKER_TAG + +SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] + +ARG zip=amazon-corretto-11.0.4.11.1-windows-x64.zip +ARG uri=https://d3pxv6yz143wms.cloudfront.net/11.0.4.11.1/ +ARG hash=707c839c3f56645454b8c8d31f255161 + +RUN Invoke-WebRequest -Uri $('{0}{1}' -f $env:uri,$env:zip) -OutFile C:/$env:zip ; ` + if((Get-FileHash C:/$env:zip -Algorithm MD5).Hash.ToLower() -ne $env:hash) { exit 1 } ; ` + Expand-Archive -Path C:/$env:zip -Destination C:/ProgramData ; ` + Remove-Item C:/${env:zip} + +ENV JAVA_HOME=C:/ProgramData/jdk11.0.4_10 + + +ARG MAVEN_VERSION=3.6.1 +ARG USER_HOME_DIR="C:/Users/ContainerAdministrator" +ARG SHA=51169366d7269ed316bad013d9cbfebe3a4ef1fda393ac4982d6dbc9af2d5cc359ee12838b8041cb998f236486e988b9c05372f4fdb29a96c1139f63c991e90e +ARG BASE_URL=https://apache.osuosl.org/maven/maven-3/${MAVEN_VERSION}/binaries + +RUN Invoke-WebRequest -Uri ${env:BASE_URL}/apache-maven-${env:MAVEN_VERSION}-bin.zip -OutFile ${env:TEMP}/apache-maven.zip ; ` + if((Get-FileHash -Algorithm SHA512 -Path ${env:TEMP}/apache-maven.zip).Hash.ToLower() -ne ${env:SHA}) { exit 1 } ; ` + Expand-Archive -Path ${env:TEMP}/apache-maven.zip -Destination C:/ProgramData ; ` + Move-Item C:/ProgramData/apache-maven-${env:MAVEN_VERSION} C:/ProgramData/Maven ; ` + New-Item -ItemType Directory -Path C:/ProgramData/Maven/Reference | Out-Null ; ` + Remove-Item ${env:TEMP}/apache-maven.zip + +ENV MAVEN_HOME C:/ProgramData/Maven +ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2" + +# Workaround https://github.com/corretto/corretto-8-docker/pull/32 +#ENV JAVA_HOME=/usr/lib/jvm/java-1.8.0-amazon-corretto + +COPY mvn-entrypoint.ps1 C:/ProgramData/Maven/mvn-entrypoint.ps1 +COPY settings-docker.xml C:/ProgramData/Maven/Reference/settings-docker.xml +RUN $content = Get-Content "C:/ProgramData/Maven/Reference/settings-docker.xml" ; ` + $content | ForEach-Object { $_ -replace '/usr/share/maven/ref/repository','C:\ProgramData\Maven\Reference\repository' } | ` + Set-Content -Path "C:/ProgramData/Maven/Reference/settings-docker.xml" + +RUN setx /M PATH $('{0};{1}' -f $env:PATH,'C:\ProgramData\Maven\bin') | Out-Null + +ENTRYPOINT ["powershell.exe", "-f", "C:/ProgramData/Maven/mvn-entrypoint.ps1"] +CMD ["mvn"] diff --git a/amazoncorretto-11/mvn-entrypoint.ps1 b/amazoncorretto-11/mvn-entrypoint.ps1 new file mode 100644 index 00000000..09d0f7b2 --- /dev/null +++ b/amazoncorretto-11/mvn-entrypoint.ps1 @@ -0,0 +1,48 @@ + +# Copy files from C:/ProgramData/Maven/Reference into ${MAVEN_CONFIG} +# So the initial ~/.m2 is set with expected content. +# Don't override, as this is just a reference setup + +function Copy-ReferenceFiles() { + $log = "${env:MAVEN_CONFIG}/copy_reference_file.log" + $ref = "C:/ProgramData/Maven/Reference" + + $repo = Join-Path $env:MAVEN_CONFIG 'repository' + + New-Item -Path $repo -ItemType Directory -Force | Out-Null + Write-Output $null > $log + if((Test-Path $repo) -and (Test-Path $log)) { + $count = (Get-ChildItem $repo | Measure-Object).Count + if($count -eq 0) { + # destination is empty... + Add-Content -Path $log -Value "--- Copying all files to ${env:MAVEN_CONFIG} at $(Get-Date)" + Copy-Item -Path "$ref\*" -Destination $env:MAVEN_CONFIG -Force -Recurse | Add-Content -Path $log + } else { + # destination is non-empty, copy file-by-file + Add-Content -Path $log -Value "--- Copying individual files to ${MAVEN_CONFIG} at $(Get-Date)" + Get-ChildItem -Path $ref -File | ForEach-Object { + Push-Location $ref + $rel = Resolve-Path -Path $($_.FullName) -Relative + Pop-Location + if(!(Test-Path (Join-Path $env:MAVEN_CONFIG $rel)) -or (Test-Path $('{0}.override' -f $_.FullName))) { + $dir = Join-Path $env:MAVEN_CONFIG $($rel.DirectoryName) + if(!(Test-Path $dir)) { + New-Item -Path $dir -ItemType Directory | Out-Null + } + Copy-Item -Path $_.FullName -Destination (Join-Path $env:MAVEN_CONFIG $rel) | Add-Content -Path $log + } + } + } + Add-Content -Path $log -Value "" + } else { + Write-Warning "Can not write to ${log}. Wrong volume permissions? Carrying on ..." + } +} + +Push-Location -StackName 'maven-entrypoint' +Copy-ReferenceFiles +Pop-Location -StackName 'maven-entrypoint' + +Remove-Item Env:\MAVEN_CONFIG + +Invoke-Expression "$args" diff --git a/amazoncorretto-8/Dockerfile.windows b/amazoncorretto-8/Dockerfile.windows new file mode 100644 index 00000000..6f851e5d --- /dev/null +++ b/amazoncorretto-8/Dockerfile.windows @@ -0,0 +1,46 @@ +# escape=` +ARG WINDOWS_DOCKER_TAG=ltsc2019 +FROM mcr.microsoft.com/windows/servercore:$WINDOWS_DOCKER_TAG + +SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] + +ARG zip=amazon-corretto-8.222.10.3-windows-x64-jdk.zip +ARG uri=https://d3pxv6yz143wms.cloudfront.net/8.222.10.1/ +ARG hash=9879a7f69c0bd7d8c1bbb916df7b5f82 + +RUN Invoke-WebRequest -Uri $('{0}{1}' -f $env:uri,$env:zip) -OutFile C:/$env:zip ; ` + if((Get-FileHash C:/$env:zip -Algorithm MD5).Hash.ToLower() -ne $env:hash) { exit 1 } ; ` + Expand-Archive -Path C:/$env:zip -Destination C:/ProgramData ; ` + Remove-Item C:/${env:zip} + +ENV JAVA_HOME=C:/ProgramData/jdk1.8.0_222 + + +ARG MAVEN_VERSION=3.6.1 +ARG USER_HOME_DIR="C:/Users/ContainerAdministrator" +ARG SHA=51169366d7269ed316bad013d9cbfebe3a4ef1fda393ac4982d6dbc9af2d5cc359ee12838b8041cb998f236486e988b9c05372f4fdb29a96c1139f63c991e90e +ARG BASE_URL=https://apache.osuosl.org/maven/maven-3/${MAVEN_VERSION}/binaries + +RUN Invoke-WebRequest -Uri ${env:BASE_URL}/apache-maven-${env:MAVEN_VERSION}-bin.zip -OutFile ${env:TEMP}/apache-maven.zip ; ` + if((Get-FileHash -Algorithm SHA512 -Path ${env:TEMP}/apache-maven.zip).Hash.ToLower() -ne ${env:SHA}) { exit 1 } ; ` + Expand-Archive -Path ${env:TEMP}/apache-maven.zip -Destination C:/ProgramData ; ` + Move-Item C:/ProgramData/apache-maven-${env:MAVEN_VERSION} C:/ProgramData/Maven ; ` + New-Item -ItemType Directory -Path C:/ProgramData/Maven/Reference | Out-Null ; ` + Remove-Item ${env:TEMP}/apache-maven.zip + +ENV MAVEN_HOME C:/ProgramData/Maven +ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2" + +# Workaround https://github.com/corretto/corretto-8-docker/pull/32 +#ENV JAVA_HOME=/usr/lib/jvm/java-1.8.0-amazon-corretto + +COPY mvn-entrypoint.ps1 C:/ProgramData/Maven/mvn-entrypoint.ps1 +COPY settings-docker.xml C:/ProgramData/Maven/Reference/settings-docker.xml +RUN $content = Get-Content "C:/ProgramData/Maven/Reference/settings-docker.xml" ; ` + $content | ForEach-Object { $_ -replace '/usr/share/maven/ref/repository','C:\ProgramData\Maven\Reference\repository' } | ` + Set-Content -Path "C:/ProgramData/Maven/Reference/settings-docker.xml" + +RUN setx /M PATH $('{0};{1}' -f $env:PATH,'C:\ProgramData\Maven\bin') | Out-Null + +ENTRYPOINT ["powershell.exe", "-f", "C:/ProgramData/Maven/mvn-entrypoint.ps1"] +CMD ["mvn"] diff --git a/amazoncorretto-8/mvn-entrypoint.ps1 b/amazoncorretto-8/mvn-entrypoint.ps1 new file mode 100644 index 00000000..09d0f7b2 --- /dev/null +++ b/amazoncorretto-8/mvn-entrypoint.ps1 @@ -0,0 +1,48 @@ + +# Copy files from C:/ProgramData/Maven/Reference into ${MAVEN_CONFIG} +# So the initial ~/.m2 is set with expected content. +# Don't override, as this is just a reference setup + +function Copy-ReferenceFiles() { + $log = "${env:MAVEN_CONFIG}/copy_reference_file.log" + $ref = "C:/ProgramData/Maven/Reference" + + $repo = Join-Path $env:MAVEN_CONFIG 'repository' + + New-Item -Path $repo -ItemType Directory -Force | Out-Null + Write-Output $null > $log + if((Test-Path $repo) -and (Test-Path $log)) { + $count = (Get-ChildItem $repo | Measure-Object).Count + if($count -eq 0) { + # destination is empty... + Add-Content -Path $log -Value "--- Copying all files to ${env:MAVEN_CONFIG} at $(Get-Date)" + Copy-Item -Path "$ref\*" -Destination $env:MAVEN_CONFIG -Force -Recurse | Add-Content -Path $log + } else { + # destination is non-empty, copy file-by-file + Add-Content -Path $log -Value "--- Copying individual files to ${MAVEN_CONFIG} at $(Get-Date)" + Get-ChildItem -Path $ref -File | ForEach-Object { + Push-Location $ref + $rel = Resolve-Path -Path $($_.FullName) -Relative + Pop-Location + if(!(Test-Path (Join-Path $env:MAVEN_CONFIG $rel)) -or (Test-Path $('{0}.override' -f $_.FullName))) { + $dir = Join-Path $env:MAVEN_CONFIG $($rel.DirectoryName) + if(!(Test-Path $dir)) { + New-Item -Path $dir -ItemType Directory | Out-Null + } + Copy-Item -Path $_.FullName -Destination (Join-Path $env:MAVEN_CONFIG $rel) | Add-Content -Path $log + } + } + } + Add-Content -Path $log -Value "" + } else { + Write-Warning "Can not write to ${log}. Wrong volume permissions? Carrying on ..." + } +} + +Push-Location -StackName 'maven-entrypoint' +Copy-ReferenceFiles +Pop-Location -StackName 'maven-entrypoint' + +Remove-Item Env:\MAVEN_CONFIG + +Invoke-Expression "$args" diff --git a/azulzulu-11/Dockerfile.windows b/azulzulu-11/Dockerfile.windows new file mode 100644 index 00000000..ee1ca529 --- /dev/null +++ b/azulzulu-11/Dockerfile.windows @@ -0,0 +1,46 @@ +# escape=` +ARG WINDOWS_DOCKER_TAG=ltsc2019 +FROM mcr.microsoft.com/windows/servercore:$WINDOWS_DOCKER_TAG + +SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] + +ARG zip=zulu11.33.15-ca-jdk11.0.4-win_x64.zip +ARG uri=https://cdn.azul.com/zulu/bin/ +ARG hash=ae13f3de1e7be9b3aa8d0afbfd5f2f9d6aba356276a39ccfcaf3511feb860f05 + +RUN Invoke-WebRequest -Uri $('{0}{1}' -f $env:uri,$env:zip) -OutFile C:/$env:zip ; ` + if((Get-FileHash C:/$env:zip -Algorithm SHA256).Hash.ToLower() -ne $env:hash) { exit 1 } ; ` + Expand-Archive -Path C:/$env:zip -Destination C:/ProgramData ; ` + Remove-Item C:/${env:zip} + +ENV JAVA_HOME=C:/ProgramData/zulu11.33.15-ca-jdk11.0.4-win_x64 + + +ARG MAVEN_VERSION=3.6.1 +ARG USER_HOME_DIR="C:/Users/ContainerAdministrator" +ARG SHA=51169366d7269ed316bad013d9cbfebe3a4ef1fda393ac4982d6dbc9af2d5cc359ee12838b8041cb998f236486e988b9c05372f4fdb29a96c1139f63c991e90e +ARG BASE_URL=https://apache.osuosl.org/maven/maven-3/${MAVEN_VERSION}/binaries + +RUN Invoke-WebRequest -Uri ${env:BASE_URL}/apache-maven-${env:MAVEN_VERSION}-bin.zip -OutFile ${env:TEMP}/apache-maven.zip ; ` + if((Get-FileHash -Algorithm SHA512 -Path ${env:TEMP}/apache-maven.zip).Hash.ToLower() -ne ${env:SHA}) { exit 1 } ; ` + Expand-Archive -Path ${env:TEMP}/apache-maven.zip -Destination C:/ProgramData ; ` + Move-Item C:/ProgramData/apache-maven-${env:MAVEN_VERSION} C:/ProgramData/Maven ; ` + New-Item -ItemType Directory -Path C:/ProgramData/Maven/Reference | Out-Null ; ` + Remove-Item ${env:TEMP}/apache-maven.zip + +ENV MAVEN_HOME C:/ProgramData/Maven +ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2" + +# Workaround https://github.com/corretto/corretto-8-docker/pull/32 +#ENV JAVA_HOME=/usr/lib/jvm/java-1.8.0-amazon-corretto + +COPY mvn-entrypoint.ps1 C:/ProgramData/Maven/mvn-entrypoint.ps1 +COPY settings-docker.xml C:/ProgramData/Maven/Reference/settings-docker.xml +RUN $content = Get-Content "C:/ProgramData/Maven/Reference/settings-docker.xml" ; ` + $content | ForEach-Object { $_ -replace '/usr/share/maven/ref/repository','C:\ProgramData\Maven\Reference\repository' } | ` + Set-Content -Path "C:/ProgramData/Maven/Reference/settings-docker.xml" + +RUN setx /M PATH $('{0};{1}' -f $env:PATH,'C:\ProgramData\Maven\bin') | Out-Null + +ENTRYPOINT ["powershell.exe", "-f", "C:/ProgramData/Maven/mvn-entrypoint.ps1"] +CMD ["mvn"] diff --git a/azulzulu-11/mvn-entrypoint.ps1 b/azulzulu-11/mvn-entrypoint.ps1 new file mode 100644 index 00000000..09d0f7b2 --- /dev/null +++ b/azulzulu-11/mvn-entrypoint.ps1 @@ -0,0 +1,48 @@ + +# Copy files from C:/ProgramData/Maven/Reference into ${MAVEN_CONFIG} +# So the initial ~/.m2 is set with expected content. +# Don't override, as this is just a reference setup + +function Copy-ReferenceFiles() { + $log = "${env:MAVEN_CONFIG}/copy_reference_file.log" + $ref = "C:/ProgramData/Maven/Reference" + + $repo = Join-Path $env:MAVEN_CONFIG 'repository' + + New-Item -Path $repo -ItemType Directory -Force | Out-Null + Write-Output $null > $log + if((Test-Path $repo) -and (Test-Path $log)) { + $count = (Get-ChildItem $repo | Measure-Object).Count + if($count -eq 0) { + # destination is empty... + Add-Content -Path $log -Value "--- Copying all files to ${env:MAVEN_CONFIG} at $(Get-Date)" + Copy-Item -Path "$ref\*" -Destination $env:MAVEN_CONFIG -Force -Recurse | Add-Content -Path $log + } else { + # destination is non-empty, copy file-by-file + Add-Content -Path $log -Value "--- Copying individual files to ${MAVEN_CONFIG} at $(Get-Date)" + Get-ChildItem -Path $ref -File | ForEach-Object { + Push-Location $ref + $rel = Resolve-Path -Path $($_.FullName) -Relative + Pop-Location + if(!(Test-Path (Join-Path $env:MAVEN_CONFIG $rel)) -or (Test-Path $('{0}.override' -f $_.FullName))) { + $dir = Join-Path $env:MAVEN_CONFIG $($rel.DirectoryName) + if(!(Test-Path $dir)) { + New-Item -Path $dir -ItemType Directory | Out-Null + } + Copy-Item -Path $_.FullName -Destination (Join-Path $env:MAVEN_CONFIG $rel) | Add-Content -Path $log + } + } + } + Add-Content -Path $log -Value "" + } else { + Write-Warning "Can not write to ${log}. Wrong volume permissions? Carrying on ..." + } +} + +Push-Location -StackName 'maven-entrypoint' +Copy-ReferenceFiles +Pop-Location -StackName 'maven-entrypoint' + +Remove-Item Env:\MAVEN_CONFIG + +Invoke-Expression "$args" diff --git a/jdk-11/Dockerfile.windows b/jdk-11/Dockerfile.windows new file mode 100644 index 00000000..a06a5b1b --- /dev/null +++ b/jdk-11/Dockerfile.windows @@ -0,0 +1,34 @@ +# escape=` +ARG WINDOWS_DOCKER_TAG=1809 +FROM openjdk:11-jdk-windowsservercore-$WINDOWS_DOCKER_TAG + +SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] + +ARG MAVEN_VERSION=3.6.1 +ARG USER_HOME_DIR="C:/Users/ContainerAdministrator" +ARG SHA=51169366d7269ed316bad013d9cbfebe3a4ef1fda393ac4982d6dbc9af2d5cc359ee12838b8041cb998f236486e988b9c05372f4fdb29a96c1139f63c991e90e +ARG BASE_URL=https://apache.osuosl.org/maven/maven-3/${MAVEN_VERSION}/binaries + +RUN Invoke-WebRequest -Uri ${env:BASE_URL}/apache-maven-${env:MAVEN_VERSION}-bin.zip -OutFile ${env:TEMP}/apache-maven.zip ; ` + if((Get-FileHash -Algorithm SHA512 -Path ${env:TEMP}/apache-maven.zip).Hash.ToLower() -ne ${env:SHA}) { exit 1 } ; ` + Expand-Archive -Path ${env:TEMP}/apache-maven.zip -Destination C:/ProgramData ; ` + Move-Item C:/ProgramData/apache-maven-${env:MAVEN_VERSION} C:/ProgramData/Maven ; ` + New-Item -ItemType Directory -Path C:/ProgramData/Maven/Reference | Out-Null ; ` + Remove-Item ${env:TEMP}/apache-maven.zip + +ENV MAVEN_HOME C:/ProgramData/Maven +ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2" + +# Workaround https://github.com/corretto/corretto-8-docker/pull/32 +#ENV JAVA_HOME=/usr/lib/jvm/java-1.8.0-amazon-corretto + +COPY mvn-entrypoint.ps1 C:/ProgramData/Maven/mvn-entrypoint.ps1 +COPY settings-docker.xml C:/ProgramData/Maven/Reference/settings-docker.xml +RUN $content = Get-Content "C:/ProgramData/Maven/Reference/settings-docker.xml" ; ` + $content | ForEach-Object { $_ -replace '/usr/share/maven/ref/repository','C:\ProgramData\Maven\Reference\repository' } | ` + Set-Content -Path "C:/ProgramData/Maven/Reference/settings-docker.xml" + +RUN setx /M PATH $('{0};{1}' -f $env:PATH,'C:\ProgramData\Maven\bin') | Out-Null + +ENTRYPOINT ["powershell.exe", "-f", "C:/ProgramData/Maven/mvn-entrypoint.ps1"] +CMD ["mvn"] diff --git a/jdk-11/mvn-entrypoint.ps1 b/jdk-11/mvn-entrypoint.ps1 new file mode 100644 index 00000000..09d0f7b2 --- /dev/null +++ b/jdk-11/mvn-entrypoint.ps1 @@ -0,0 +1,48 @@ + +# Copy files from C:/ProgramData/Maven/Reference into ${MAVEN_CONFIG} +# So the initial ~/.m2 is set with expected content. +# Don't override, as this is just a reference setup + +function Copy-ReferenceFiles() { + $log = "${env:MAVEN_CONFIG}/copy_reference_file.log" + $ref = "C:/ProgramData/Maven/Reference" + + $repo = Join-Path $env:MAVEN_CONFIG 'repository' + + New-Item -Path $repo -ItemType Directory -Force | Out-Null + Write-Output $null > $log + if((Test-Path $repo) -and (Test-Path $log)) { + $count = (Get-ChildItem $repo | Measure-Object).Count + if($count -eq 0) { + # destination is empty... + Add-Content -Path $log -Value "--- Copying all files to ${env:MAVEN_CONFIG} at $(Get-Date)" + Copy-Item -Path "$ref\*" -Destination $env:MAVEN_CONFIG -Force -Recurse | Add-Content -Path $log + } else { + # destination is non-empty, copy file-by-file + Add-Content -Path $log -Value "--- Copying individual files to ${MAVEN_CONFIG} at $(Get-Date)" + Get-ChildItem -Path $ref -File | ForEach-Object { + Push-Location $ref + $rel = Resolve-Path -Path $($_.FullName) -Relative + Pop-Location + if(!(Test-Path (Join-Path $env:MAVEN_CONFIG $rel)) -or (Test-Path $('{0}.override' -f $_.FullName))) { + $dir = Join-Path $env:MAVEN_CONFIG $($rel.DirectoryName) + if(!(Test-Path $dir)) { + New-Item -Path $dir -ItemType Directory | Out-Null + } + Copy-Item -Path $_.FullName -Destination (Join-Path $env:MAVEN_CONFIG $rel) | Add-Content -Path $log + } + } + } + Add-Content -Path $log -Value "" + } else { + Write-Warning "Can not write to ${log}. Wrong volume permissions? Carrying on ..." + } +} + +Push-Location -StackName 'maven-entrypoint' +Copy-ReferenceFiles +Pop-Location -StackName 'maven-entrypoint' + +Remove-Item Env:\MAVEN_CONFIG + +Invoke-Expression "$args" diff --git a/jdk-12/Dockerfile.windows b/jdk-12/Dockerfile.windows new file mode 100644 index 00000000..02ebd06d --- /dev/null +++ b/jdk-12/Dockerfile.windows @@ -0,0 +1,34 @@ +# escape=` +ARG WINDOWS_DOCKER_TAG=1809 +FROM openjdk:12-jdk-windowsservercore-$WINDOWS_DOCKER_TAG + +SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] + +ARG MAVEN_VERSION=3.6.1 +ARG USER_HOME_DIR="C:/Users/ContainerAdministrator" +ARG SHA=51169366d7269ed316bad013d9cbfebe3a4ef1fda393ac4982d6dbc9af2d5cc359ee12838b8041cb998f236486e988b9c05372f4fdb29a96c1139f63c991e90e +ARG BASE_URL=https://apache.osuosl.org/maven/maven-3/${MAVEN_VERSION}/binaries + +RUN Invoke-WebRequest -Uri ${env:BASE_URL}/apache-maven-${env:MAVEN_VERSION}-bin.zip -OutFile ${env:TEMP}/apache-maven.zip ; ` + if((Get-FileHash -Algorithm SHA512 -Path ${env:TEMP}/apache-maven.zip).Hash.ToLower() -ne ${env:SHA}) { exit 1 } ; ` + Expand-Archive -Path ${env:TEMP}/apache-maven.zip -Destination C:/ProgramData ; ` + Move-Item C:/ProgramData/apache-maven-${env:MAVEN_VERSION} C:/ProgramData/Maven ; ` + New-Item -ItemType Directory -Path C:/ProgramData/Maven/Reference | Out-Null ; ` + Remove-Item ${env:TEMP}/apache-maven.zip + +ENV MAVEN_HOME C:/ProgramData/Maven +ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2" + +# Workaround https://github.com/corretto/corretto-8-docker/pull/32 +#ENV JAVA_HOME=/usr/lib/jvm/java-1.8.0-amazon-corretto + +COPY mvn-entrypoint.ps1 C:/ProgramData/Maven/mvn-entrypoint.ps1 +COPY settings-docker.xml C:/ProgramData/Maven/Reference/settings-docker.xml +RUN $content = Get-Content "C:/ProgramData/Maven/Reference/settings-docker.xml" ; ` + $content | ForEach-Object { $_ -replace '/usr/share/maven/ref/repository','C:\ProgramData\Maven\Reference\repository' } | ` + Set-Content -Path "C:/ProgramData/Maven/Reference/settings-docker.xml" + +RUN setx /M PATH $('{0};{1}' -f $env:PATH,'C:\ProgramData\Maven\bin') | Out-Null + +ENTRYPOINT ["powershell.exe", "-f", "C:/ProgramData/Maven/mvn-entrypoint.ps1"] +CMD ["mvn"] diff --git a/jdk-12/mvn-entrypoint.ps1 b/jdk-12/mvn-entrypoint.ps1 new file mode 100644 index 00000000..09d0f7b2 --- /dev/null +++ b/jdk-12/mvn-entrypoint.ps1 @@ -0,0 +1,48 @@ + +# Copy files from C:/ProgramData/Maven/Reference into ${MAVEN_CONFIG} +# So the initial ~/.m2 is set with expected content. +# Don't override, as this is just a reference setup + +function Copy-ReferenceFiles() { + $log = "${env:MAVEN_CONFIG}/copy_reference_file.log" + $ref = "C:/ProgramData/Maven/Reference" + + $repo = Join-Path $env:MAVEN_CONFIG 'repository' + + New-Item -Path $repo -ItemType Directory -Force | Out-Null + Write-Output $null > $log + if((Test-Path $repo) -and (Test-Path $log)) { + $count = (Get-ChildItem $repo | Measure-Object).Count + if($count -eq 0) { + # destination is empty... + Add-Content -Path $log -Value "--- Copying all files to ${env:MAVEN_CONFIG} at $(Get-Date)" + Copy-Item -Path "$ref\*" -Destination $env:MAVEN_CONFIG -Force -Recurse | Add-Content -Path $log + } else { + # destination is non-empty, copy file-by-file + Add-Content -Path $log -Value "--- Copying individual files to ${MAVEN_CONFIG} at $(Get-Date)" + Get-ChildItem -Path $ref -File | ForEach-Object { + Push-Location $ref + $rel = Resolve-Path -Path $($_.FullName) -Relative + Pop-Location + if(!(Test-Path (Join-Path $env:MAVEN_CONFIG $rel)) -or (Test-Path $('{0}.override' -f $_.FullName))) { + $dir = Join-Path $env:MAVEN_CONFIG $($rel.DirectoryName) + if(!(Test-Path $dir)) { + New-Item -Path $dir -ItemType Directory | Out-Null + } + Copy-Item -Path $_.FullName -Destination (Join-Path $env:MAVEN_CONFIG $rel) | Add-Content -Path $log + } + } + } + Add-Content -Path $log -Value "" + } else { + Write-Warning "Can not write to ${log}. Wrong volume permissions? Carrying on ..." + } +} + +Push-Location -StackName 'maven-entrypoint' +Copy-ReferenceFiles +Pop-Location -StackName 'maven-entrypoint' + +Remove-Item Env:\MAVEN_CONFIG + +Invoke-Expression "$args" diff --git a/jdk-13/Dockerfile.windows b/jdk-13/Dockerfile.windows new file mode 100644 index 00000000..c2cd94ac --- /dev/null +++ b/jdk-13/Dockerfile.windows @@ -0,0 +1,34 @@ +# escape=` +ARG WINDOWS_DOCKER_TAG=1809 +FROM openjdk:13-jdk-windowsservercore-$WINDOWS_DOCKER_TAG + +SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] + +ARG MAVEN_VERSION=3.6.1 +ARG USER_HOME_DIR="C:/Users/ContainerAdministrator" +ARG SHA=51169366d7269ed316bad013d9cbfebe3a4ef1fda393ac4982d6dbc9af2d5cc359ee12838b8041cb998f236486e988b9c05372f4fdb29a96c1139f63c991e90e +ARG BASE_URL=https://apache.osuosl.org/maven/maven-3/${MAVEN_VERSION}/binaries + +RUN Invoke-WebRequest -Uri ${env:BASE_URL}/apache-maven-${env:MAVEN_VERSION}-bin.zip -OutFile ${env:TEMP}/apache-maven.zip ; ` + if((Get-FileHash -Algorithm SHA512 -Path ${env:TEMP}/apache-maven.zip).Hash.ToLower() -ne ${env:SHA}) { exit 1 } ; ` + Expand-Archive -Path ${env:TEMP}/apache-maven.zip -Destination C:/ProgramData ; ` + Move-Item C:/ProgramData/apache-maven-${env:MAVEN_VERSION} C:/ProgramData/Maven ; ` + New-Item -ItemType Directory -Path C:/ProgramData/Maven/Reference | Out-Null ; ` + Remove-Item ${env:TEMP}/apache-maven.zip + +ENV MAVEN_HOME C:/ProgramData/Maven +ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2" + +# Workaround https://github.com/corretto/corretto-8-docker/pull/32 +#ENV JAVA_HOME=/usr/lib/jvm/java-1.8.0-amazon-corretto + +COPY mvn-entrypoint.ps1 C:/ProgramData/Maven/mvn-entrypoint.ps1 +COPY settings-docker.xml C:/ProgramData/Maven/Reference/settings-docker.xml +RUN $content = Get-Content "C:/ProgramData/Maven/Reference/settings-docker.xml" ; ` + $content | ForEach-Object { $_ -replace '/usr/share/maven/ref/repository','C:\ProgramData\Maven\Reference\repository' } | ` + Set-Content -Path "C:/ProgramData/Maven/Reference/settings-docker.xml" + +RUN setx /M PATH $('{0};{1}' -f $env:PATH,'C:\ProgramData\Maven\bin') | Out-Null + +ENTRYPOINT ["powershell.exe", "-f", "C:/ProgramData/Maven/mvn-entrypoint.ps1"] +CMD ["mvn"] diff --git a/jdk-13/mvn-entrypoint.ps1 b/jdk-13/mvn-entrypoint.ps1 new file mode 100644 index 00000000..09d0f7b2 --- /dev/null +++ b/jdk-13/mvn-entrypoint.ps1 @@ -0,0 +1,48 @@ + +# Copy files from C:/ProgramData/Maven/Reference into ${MAVEN_CONFIG} +# So the initial ~/.m2 is set with expected content. +# Don't override, as this is just a reference setup + +function Copy-ReferenceFiles() { + $log = "${env:MAVEN_CONFIG}/copy_reference_file.log" + $ref = "C:/ProgramData/Maven/Reference" + + $repo = Join-Path $env:MAVEN_CONFIG 'repository' + + New-Item -Path $repo -ItemType Directory -Force | Out-Null + Write-Output $null > $log + if((Test-Path $repo) -and (Test-Path $log)) { + $count = (Get-ChildItem $repo | Measure-Object).Count + if($count -eq 0) { + # destination is empty... + Add-Content -Path $log -Value "--- Copying all files to ${env:MAVEN_CONFIG} at $(Get-Date)" + Copy-Item -Path "$ref\*" -Destination $env:MAVEN_CONFIG -Force -Recurse | Add-Content -Path $log + } else { + # destination is non-empty, copy file-by-file + Add-Content -Path $log -Value "--- Copying individual files to ${MAVEN_CONFIG} at $(Get-Date)" + Get-ChildItem -Path $ref -File | ForEach-Object { + Push-Location $ref + $rel = Resolve-Path -Path $($_.FullName) -Relative + Pop-Location + if(!(Test-Path (Join-Path $env:MAVEN_CONFIG $rel)) -or (Test-Path $('{0}.override' -f $_.FullName))) { + $dir = Join-Path $env:MAVEN_CONFIG $($rel.DirectoryName) + if(!(Test-Path $dir)) { + New-Item -Path $dir -ItemType Directory | Out-Null + } + Copy-Item -Path $_.FullName -Destination (Join-Path $env:MAVEN_CONFIG $rel) | Add-Content -Path $log + } + } + } + Add-Content -Path $log -Value "" + } else { + Write-Warning "Can not write to ${log}. Wrong volume permissions? Carrying on ..." + } +} + +Push-Location -StackName 'maven-entrypoint' +Copy-ReferenceFiles +Pop-Location -StackName 'maven-entrypoint' + +Remove-Item Env:\MAVEN_CONFIG + +Invoke-Expression "$args" diff --git a/jdk-14/Dockerfile.windows b/jdk-14/Dockerfile.windows new file mode 100644 index 00000000..1aaedcd7 --- /dev/null +++ b/jdk-14/Dockerfile.windows @@ -0,0 +1,34 @@ +# escape=` +ARG WINDOWS_DOCKER_TAG=1809 +FROM openjdk:14-jdk-windowsservercore-$WINDOWS_DOCKER_TAG + +SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] + +ARG MAVEN_VERSION=3.6.1 +ARG USER_HOME_DIR="C:/Users/ContainerAdministrator" +ARG SHA=51169366d7269ed316bad013d9cbfebe3a4ef1fda393ac4982d6dbc9af2d5cc359ee12838b8041cb998f236486e988b9c05372f4fdb29a96c1139f63c991e90e +ARG BASE_URL=https://apache.osuosl.org/maven/maven-3/${MAVEN_VERSION}/binaries + +RUN Invoke-WebRequest -Uri ${env:BASE_URL}/apache-maven-${env:MAVEN_VERSION}-bin.zip -OutFile ${env:TEMP}/apache-maven.zip ; ` + if((Get-FileHash -Algorithm SHA512 -Path ${env:TEMP}/apache-maven.zip).Hash.ToLower() -ne ${env:SHA}) { exit 1 } ; ` + Expand-Archive -Path ${env:TEMP}/apache-maven.zip -Destination C:/ProgramData ; ` + Move-Item C:/ProgramData/apache-maven-${env:MAVEN_VERSION} C:/ProgramData/Maven ; ` + New-Item -ItemType Directory -Path C:/ProgramData/Maven/Reference | Out-Null ; ` + Remove-Item ${env:TEMP}/apache-maven.zip + +ENV MAVEN_HOME C:/ProgramData/Maven +ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2" + +# Workaround https://github.com/corretto/corretto-8-docker/pull/32 +#ENV JAVA_HOME=/usr/lib/jvm/java-1.8.0-amazon-corretto + +COPY mvn-entrypoint.ps1 C:/ProgramData/Maven/mvn-entrypoint.ps1 +COPY settings-docker.xml C:/ProgramData/Maven/Reference/settings-docker.xml +RUN $content = Get-Content "C:/ProgramData/Maven/Reference/settings-docker.xml" ; ` + $content | ForEach-Object { $_ -replace '/usr/share/maven/ref/repository','C:\ProgramData\Maven\Reference\repository' } | ` + Set-Content -Path "C:/ProgramData/Maven/Reference/settings-docker.xml" + +RUN setx /M PATH $('{0};{1}' -f $env:PATH,'C:\ProgramData\Maven\bin') | Out-Null + +ENTRYPOINT ["powershell.exe", "-f", "C:/ProgramData/Maven/mvn-entrypoint.ps1"] +CMD ["mvn"] diff --git a/jdk-14/mvn-entrypoint.ps1 b/jdk-14/mvn-entrypoint.ps1 new file mode 100644 index 00000000..09d0f7b2 --- /dev/null +++ b/jdk-14/mvn-entrypoint.ps1 @@ -0,0 +1,48 @@ + +# Copy files from C:/ProgramData/Maven/Reference into ${MAVEN_CONFIG} +# So the initial ~/.m2 is set with expected content. +# Don't override, as this is just a reference setup + +function Copy-ReferenceFiles() { + $log = "${env:MAVEN_CONFIG}/copy_reference_file.log" + $ref = "C:/ProgramData/Maven/Reference" + + $repo = Join-Path $env:MAVEN_CONFIG 'repository' + + New-Item -Path $repo -ItemType Directory -Force | Out-Null + Write-Output $null > $log + if((Test-Path $repo) -and (Test-Path $log)) { + $count = (Get-ChildItem $repo | Measure-Object).Count + if($count -eq 0) { + # destination is empty... + Add-Content -Path $log -Value "--- Copying all files to ${env:MAVEN_CONFIG} at $(Get-Date)" + Copy-Item -Path "$ref\*" -Destination $env:MAVEN_CONFIG -Force -Recurse | Add-Content -Path $log + } else { + # destination is non-empty, copy file-by-file + Add-Content -Path $log -Value "--- Copying individual files to ${MAVEN_CONFIG} at $(Get-Date)" + Get-ChildItem -Path $ref -File | ForEach-Object { + Push-Location $ref + $rel = Resolve-Path -Path $($_.FullName) -Relative + Pop-Location + if(!(Test-Path (Join-Path $env:MAVEN_CONFIG $rel)) -or (Test-Path $('{0}.override' -f $_.FullName))) { + $dir = Join-Path $env:MAVEN_CONFIG $($rel.DirectoryName) + if(!(Test-Path $dir)) { + New-Item -Path $dir -ItemType Directory | Out-Null + } + Copy-Item -Path $_.FullName -Destination (Join-Path $env:MAVEN_CONFIG $rel) | Add-Content -Path $log + } + } + } + Add-Content -Path $log -Value "" + } else { + Write-Warning "Can not write to ${log}. Wrong volume permissions? Carrying on ..." + } +} + +Push-Location -StackName 'maven-entrypoint' +Copy-ReferenceFiles +Pop-Location -StackName 'maven-entrypoint' + +Remove-Item Env:\MAVEN_CONFIG + +Invoke-Expression "$args" diff --git a/jdk-8/Dockerfile.windows b/jdk-8/Dockerfile.windows new file mode 100644 index 00000000..3ee5929c --- /dev/null +++ b/jdk-8/Dockerfile.windows @@ -0,0 +1,34 @@ +# escape=` +ARG WINDOWS_DOCKER_TAG=1809 +FROM openjdk:8-jdk-windowsservercore-$WINDOWS_DOCKER_TAG + +SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] + +ARG MAVEN_VERSION=3.6.1 +ARG USER_HOME_DIR="C:/Users/ContainerAdministrator" +ARG SHA=51169366d7269ed316bad013d9cbfebe3a4ef1fda393ac4982d6dbc9af2d5cc359ee12838b8041cb998f236486e988b9c05372f4fdb29a96c1139f63c991e90e +ARG BASE_URL=https://apache.osuosl.org/maven/maven-3/${MAVEN_VERSION}/binaries + +RUN Invoke-WebRequest -Uri ${env:BASE_URL}/apache-maven-${env:MAVEN_VERSION}-bin.zip -OutFile ${env:TEMP}/apache-maven.zip ; ` + if((Get-FileHash -Algorithm SHA512 -Path ${env:TEMP}/apache-maven.zip).Hash.ToLower() -ne ${env:SHA}) { exit 1 } ; ` + Expand-Archive -Path ${env:TEMP}/apache-maven.zip -Destination C:/ProgramData ; ` + Move-Item C:/ProgramData/apache-maven-${env:MAVEN_VERSION} C:/ProgramData/Maven ; ` + New-Item -ItemType Directory -Path C:/ProgramData/Maven/Reference | Out-Null ; ` + Remove-Item ${env:TEMP}/apache-maven.zip + +ENV MAVEN_HOME C:/ProgramData/Maven +ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2" + +# Workaround https://github.com/corretto/corretto-8-docker/pull/32 +#ENV JAVA_HOME=/usr/lib/jvm/java-1.8.0-amazon-corretto + +COPY mvn-entrypoint.ps1 C:/ProgramData/Maven/mvn-entrypoint.ps1 +COPY settings-docker.xml C:/ProgramData/Maven/Reference/settings-docker.xml +RUN $content = Get-Content "C:/ProgramData/Maven/Reference/settings-docker.xml" ; ` + $content | ForEach-Object { $_ -replace '/usr/share/maven/ref/repository','C:\ProgramData\Maven\Reference\repository' } | ` + Set-Content -Path "C:/ProgramData/Maven/Reference/settings-docker.xml" + +RUN setx /M PATH $('{0};{1}' -f $env:PATH,'C:\ProgramData\Maven\bin') | Out-Null + +ENTRYPOINT ["powershell.exe", "-f", "C:/ProgramData/Maven/mvn-entrypoint.ps1"] +CMD ["mvn"] diff --git a/jdk-8/mvn-entrypoint.ps1 b/jdk-8/mvn-entrypoint.ps1 new file mode 100644 index 00000000..09d0f7b2 --- /dev/null +++ b/jdk-8/mvn-entrypoint.ps1 @@ -0,0 +1,48 @@ + +# Copy files from C:/ProgramData/Maven/Reference into ${MAVEN_CONFIG} +# So the initial ~/.m2 is set with expected content. +# Don't override, as this is just a reference setup + +function Copy-ReferenceFiles() { + $log = "${env:MAVEN_CONFIG}/copy_reference_file.log" + $ref = "C:/ProgramData/Maven/Reference" + + $repo = Join-Path $env:MAVEN_CONFIG 'repository' + + New-Item -Path $repo -ItemType Directory -Force | Out-Null + Write-Output $null > $log + if((Test-Path $repo) -and (Test-Path $log)) { + $count = (Get-ChildItem $repo | Measure-Object).Count + if($count -eq 0) { + # destination is empty... + Add-Content -Path $log -Value "--- Copying all files to ${env:MAVEN_CONFIG} at $(Get-Date)" + Copy-Item -Path "$ref\*" -Destination $env:MAVEN_CONFIG -Force -Recurse | Add-Content -Path $log + } else { + # destination is non-empty, copy file-by-file + Add-Content -Path $log -Value "--- Copying individual files to ${MAVEN_CONFIG} at $(Get-Date)" + Get-ChildItem -Path $ref -File | ForEach-Object { + Push-Location $ref + $rel = Resolve-Path -Path $($_.FullName) -Relative + Pop-Location + if(!(Test-Path (Join-Path $env:MAVEN_CONFIG $rel)) -or (Test-Path $('{0}.override' -f $_.FullName))) { + $dir = Join-Path $env:MAVEN_CONFIG $($rel.DirectoryName) + if(!(Test-Path $dir)) { + New-Item -Path $dir -ItemType Directory | Out-Null + } + Copy-Item -Path $_.FullName -Destination (Join-Path $env:MAVEN_CONFIG $rel) | Add-Content -Path $log + } + } + } + Add-Content -Path $log -Value "" + } else { + Write-Warning "Can not write to ${log}. Wrong volume permissions? Carrying on ..." + } +} + +Push-Location -StackName 'maven-entrypoint' +Copy-ReferenceFiles +Pop-Location -StackName 'maven-entrypoint' + +Remove-Item Env:\MAVEN_CONFIG + +Invoke-Expression "$args" diff --git a/tests/Dockerfile.windows b/tests/Dockerfile.windows new file mode 100644 index 00000000..33a724c8 --- /dev/null +++ b/tests/Dockerfile.windows @@ -0,0 +1,7 @@ +FROM pester-maven + +COPY settings.xml C:/ProgramData/Maven/Reference/ +COPY pom.xml C:/Temp/pom.xml +COPY src/ C:/Temp/src + +RUN mvn -B -f C:/Temp/pom.xml -s C:/ProgramData/Maven/Reference/settings-docker.xml dependency:resolve diff --git a/tests/maven.Tests.ps1 b/tests/maven.Tests.ps1 new file mode 100644 index 00000000..c3cc18a4 --- /dev/null +++ b/tests/maven.Tests.ps1 @@ -0,0 +1,73 @@ +$SUT_IMAGE="pester-maven" +$SUT_CONTAINER="pester-maven" +$SUT_TAG="jdk-8" +if(![System.String]::IsNullOrWhiteSpace($env:TAG)) { + $SUT_TAG=$env:TAG +} +$SUT_TEST_IMAGE="pester-maven-test" +$SUT_TEST_CONTAINER="pester-maven-test" + +Import-Module -Force -DisableNameChecking $PSScriptRoot/test_helpers.psm1 + +Describe "$SUT_TAG build image" { + BeforeEach { + Push-Location -StackName 'maven' -Path "$PSScriptRoot/../$SUT_TAG" + } + + It 'builds image' { + $exitCode, $stdout, $stderr = Build-Docker --pull -t $SUT_IMAGE + $lastExitCode | Should -Be 0 + } + + AfterEach { + Pop-Location -StackName 'maven' + } +} + +Describe "$SUT_TAG build test image" { + It 'builds image' { + Push-Location -StackName 'maven' -Path $PSScriptRoot + $exitCode, $stdout, $stderr = Build-Docker -t $SUT_TEST_IMAGE + $exitCode | Should -Be 0 + } +} + +Describe "$SUT_TAG create test container" { + It 'creates test container' { + $version = $(Get-Content -Path "$PSScriptRoot/../$SUT_TAG/Dockerfile.windows" | Select-String -Pattern 'ARG MAVEN_VERSION.*' | ForEach-Object { $_ -replace 'ARG MAVEN_VERSION=','' }) + $exitCode, $stdout, $stderr = Run-Program -Cmd "docker.exe" -Params "run --rm $SUT_IMAGE mvn -version" + $exitCode | Should -Be 0 + $stdout | Should -Match "Apache Maven $version" + } +} + +Describe "$SUT_TAG settings.xml is setup" { + It 'sets up settings.xml' { + $exitCode, $stdout, $stderr = Run-Program -Cmd "docker.exe" -Params "run --rm $SUT_TEST_IMAGE Get-Content C:/Users/ContainerAdministrator/.m2/settings.xml" + $exitCode | Should -Be 0 + "$PSScriptRoot/settings.xml" | Should -FileContentMatchMultiline $stdout + } +} + + +Describe "$SUT_TAG repository is created" { + It 'created repository' { + $exitCode, $stdout, $stderr = Run-Program -Cmd "docker.exe" -Params "run --rm $SUT_TEST_IMAGE if(Test-Path C:/Users/ContainerAdministrator/.m2/repository/junit/junit/3.8.1/junit-3.8.1.jar) { exit 0 } else {exit 1 }" + $exitCode | Should -Be 0 + } +} + + +Describe "$SUT_TAG run Maven" { + It 'runs maven' { + $exitCode, $stdout, $stderr = Run-Program -Cmd "docker.exe" -Params "run --rm $SUT_TEST_IMAGE mvn -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -f $env:TEMP install" + $exitCode | Should -Be 0 + } +} + +Describe "$SUT_TAG generate sample project" { + It 'generates sample project' { + $exitCode, $stdout, $stderr = Run-Program -Cmd "docker.exe" -Params "run --rm -it $SUT_TEST_IMAGE mvn -B archetype:generate -DgroupId=pester-testing -DartifactId=pester-test-project -DarchetypeArtifactId=maven-archetype-quickstart" + $exitCode | Should -Be 0 + } +} diff --git a/tests/test_helpers.psm1 b/tests/test_helpers.psm1 new file mode 100644 index 00000000..23b67e6a --- /dev/null +++ b/tests/test_helpers.psm1 @@ -0,0 +1,96 @@ + +function Test-CommandExists($command) { + $oldPreference = $ErrorActionPreference + $ErrorActionPreference = 'stop' + $res = $false + try { + if(Get-Command $command) { + $res = $true + } + } catch { + $res = $false + } finally { + $ErrorActionPreference=$oldPreference + } + return $res +} + +# check dependencies +if(-Not (Test-CommandExists docker)) { + Write-Error "docker is not available" +} + +function Run-Program($Cmd, $Params) { + $psi = New-Object System.Diagnostics.ProcessStartInfo + $psi.CreateNoWindow = $true + $psi.UseShellExecute = $false + $psi.RedirectStandardOutput = $true + $psi.RedirectStandardError = $true + $psi.WorkingDirectory = (Get-Location) + $psi.FileName = $Cmd + $psi.Arguments = $Params + $proc = New-Object System.Diagnostics.Process + $proc.StartInfo = $psi + [void]$proc.Start() + $stdout = $proc.StandardOutput.ReadToEnd() + $stderr = $proc.StandardError.ReadToEnd() + $proc.WaitForExit() + if($proc.ExitCode -ne 0) { + Write-Host "`n`nstdout:`n$stdout`n`nstderr:`n$stderr`n`n" + } + + return $proc.ExitCode, $stdout, $stderr +} + +function Build-Docker { + return (Run-Program 'docker.exe' "build -f Dockerfile.windows $args .") +} + +function Retry-Command { + [CmdletBinding()] + param ( + [parameter(Mandatory, ValueFromPipeline)] + [ValidateNotNullOrEmpty()] + [scriptblock] $ScriptBlock, + [int] $RetryCount = 3, + [int] $Delay = 30, + [string] $SuccessMessage = "Command executed successfuly!", + [string] $FailureMessage = "Failed to execute the command" + ) + + process { + $Attempt = 1 + $Flag = $true + + do { + try { + $PreviousPreference = $ErrorActionPreference + $ErrorActionPreference = 'Stop' + Invoke-Command -NoNewScope -ScriptBlock $ScriptBlock -OutVariable Result 4>&1 + $ErrorActionPreference = $PreviousPreference + + # flow control will execute the next line only if the command in the scriptblock executed without any errors + # if an error is thrown, flow control will go to the 'catch' block + Write-Verbose "$SuccessMessage `n" + $Flag = $false + } + catch { + if ($Attempt -gt $RetryCount) { + Write-Verbose "$FailureMessage! Total retry attempts: $RetryCount" + Write-Verbose "[Error Message] $($_.exception.message) `n" + $Flag = $false + } else { + Write-Verbose "[$Attempt/$RetryCount] $FailureMessage. Retrying in $Delay seconds..." + Start-Sleep -Seconds $Delay + $Attempt = $Attempt + 1 + } + } + } + While ($Flag) + } +} + +function Remove-Container($Container) { + docker kill "$Container" 2>&1 | Out-Null + docker rm -fv "$Container" 2>&1 | Out-Null +} From edbfbb7b51a5d0627555e54fba61c20897de220a Mon Sep 17 00:00:00 2001 From: Alex Earl Date: Fri, 23 Aug 2019 12:58:15 -0700 Subject: [PATCH 02/38] Update README.md Co-Authored-By: Jesse Glick --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8fe16ec7..bd693f78 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ See [Docker Hub](https://hub.docker.com/_/maven) for updated list of tags * [amazoncorretto-8-windows](https://github.com/carlossg/docker-maven/blob/master/amazoncorretto-8/Dockerfile.windows) * [amazoncorretto-11](https://github.com/carlossg/docker-maven/blob/master/amazoncorretto-11/Dockerfile) * [amazoncorretto-11-windows](https://github.com/carlossg/docker-maven/blob/master/amazoncorretto-11/Dockerfile.windows) -* [azulzulu-11](https://github.com/carlossg/docker-maven/blob/master/azulzulu-11/) +* [azulzulu-11](https://github.com/carlossg/docker-maven/blob/master/azulzulu-11/Dockerfile) * [azulzulu-11-windows](https://github.com/carlossg/docker-maven/blob/master/azulzulu-11/Dockerfile.windows) # What is Maven? From 5f50f0c914aeae361c2607edcaf49d81ff1949c1 Mon Sep 17 00:00:00 2001 From: Alex Earl Date: Fri, 23 Aug 2019 12:59:16 -0700 Subject: [PATCH 03/38] Update README.md Co-Authored-By: Jesse Glick --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index bd693f78..e584c236 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,9 @@ passing a Maven command to `docker run`: ### Windows - docker run -it --rm --name my-maven-project -v "$(Get-Location)":C:/Src -w C:/Src maven:3.3-jdk-8-windows mvn clean install +```powershell +docker run -it --rm --name my-maven-project -v "$(Get-Location)":C:/Src -w C:/Src maven:3.3-jdk-8-windows mvn clean install +``` ## Building local Docker image (optional) From 0243415562d9773081766bbb445190fe50598066 Mon Sep 17 00:00:00 2001 From: Alex Earl Date: Fri, 23 Aug 2019 13:01:16 -0700 Subject: [PATCH 04/38] Update README.md with recommendations Add powershell to syntax highlighting --- README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e584c236..e852e134 100644 --- a/README.md +++ b/README.md @@ -149,7 +149,9 @@ Use the env var TAG to choose what image to run tests against. TAG=jdk-11 bats tests ### Windows - $env:TAG="jdk-11" ; Invoke-Pester -Path tests +```powershell +$env:TAG="jdk-11" ; Invoke-Pester -Path tests +``` or run all the tests with @@ -157,7 +159,9 @@ or run all the tests with for dir in $(/bin/ls -1 -d */ | grep -v tests); do TAG=$(basename $dir) bats tests; done ### Windows - Get-ChildItem -Directory -Exclude tests,ibm*,*slim | ForEach-Object { Push-Location ; $env:TAG=$_.Name ; Invoke-Pester -Path tests ; Pop-Location } +```powershell +Get-ChildItem -Directory -Exclude tests,ibm*,*slim | ForEach-Object { Push-Location ; $env:TAG=$_.Name ; Invoke-Pester -Path tests ; Pop-Location } +``` Bats can be easily installed with `brew install bats` on OS X. From 7da432087b060fb74ea7bd3bf1061650160620c1 Mon Sep 17 00:00:00 2001 From: Alex Earl Date: Fri, 23 Aug 2019 13:07:15 -0700 Subject: [PATCH 05/38] Remove commented code --- jdk-8/Dockerfile.windows | 3 --- 1 file changed, 3 deletions(-) diff --git a/jdk-8/Dockerfile.windows b/jdk-8/Dockerfile.windows index 3ee5929c..12d67560 100644 --- a/jdk-8/Dockerfile.windows +++ b/jdk-8/Dockerfile.windows @@ -19,9 +19,6 @@ RUN Invoke-WebRequest -Uri ${env:BASE_URL}/apache-maven-${env:MAVEN_VERSION}-bin ENV MAVEN_HOME C:/ProgramData/Maven ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2" -# Workaround https://github.com/corretto/corretto-8-docker/pull/32 -#ENV JAVA_HOME=/usr/lib/jvm/java-1.8.0-amazon-corretto - COPY mvn-entrypoint.ps1 C:/ProgramData/Maven/mvn-entrypoint.ps1 COPY settings-docker.xml C:/ProgramData/Maven/Reference/settings-docker.xml RUN $content = Get-Content "C:/ProgramData/Maven/Reference/settings-docker.xml" ; ` From 1a7112d092edadba9032a8ef0df533a88876274d Mon Sep 17 00:00:00 2001 From: Alex Earl Date: Fri, 23 Aug 2019 13:08:05 -0700 Subject: [PATCH 06/38] Update tests/maven.Tests.ps1 Co-Authored-By: Jesse Glick --- tests/maven.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/maven.Tests.ps1 b/tests/maven.Tests.ps1 index c3cc18a4..c4c0a273 100644 --- a/tests/maven.Tests.ps1 +++ b/tests/maven.Tests.ps1 @@ -60,7 +60,7 @@ Describe "$SUT_TAG repository is created" { Describe "$SUT_TAG run Maven" { It 'runs maven' { - $exitCode, $stdout, $stderr = Run-Program -Cmd "docker.exe" -Params "run --rm $SUT_TEST_IMAGE mvn -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -f $env:TEMP install" + $exitCode, $stdout, $stderr = Run-Program -Cmd "docker.exe" -Params "run --rm $SUT_TEST_IMAGE mvn -B -ntp -f $env:TEMP install" $exitCode | Should -Be 0 } } From f26f19df452ffd2c26e596588bc9a05188c46762 Mon Sep 17 00:00:00 2001 From: Alex Earl Date: Fri, 23 Aug 2019 15:19:33 -0700 Subject: [PATCH 07/38] Refactor the directory structure for Windows images --- README.md | 2 +- amazoncorretto-8/mvn-entrypoint.ps1 | 48 ------------------- azulzulu-11/mvn-entrypoint.ps1 | 48 ------------------- jdk-11/mvn-entrypoint.ps1 | 48 ------------------- jdk-12/mvn-entrypoint.ps1 | 48 ------------------- jdk-13/mvn-entrypoint.ps1 | 48 ------------------- jdk-14/mvn-entrypoint.ps1 | 48 ------------------- jdk-8/mvn-entrypoint.ps1 | 48 ------------------- tests/maven.Tests.ps1 | 15 ++++-- tests/test_helpers.psm1 | 41 ++++++++-------- .../Dockerfile.windows-amazoncorretto-11 | 7 --- .../Dockerfile.windows-amazoncorretto-8 | 9 +--- .../Dockerfile.windows-azulzulu-11 | 3 +- .../Dockerfile.windows-jdk-11 | 0 .../Dockerfile.windows-jdk-12 | 0 .../Dockerfile.windows-jdk-13 | 0 .../Dockerfile.windows-jdk-14 | 0 .../Dockerfile.windows-jdk-8 | 3 -- .../mvn-entrypoint.ps1 | 0 windows/settings-docker.xml | 6 +++ 20 files changed, 42 insertions(+), 380 deletions(-) delete mode 100644 amazoncorretto-8/mvn-entrypoint.ps1 delete mode 100644 azulzulu-11/mvn-entrypoint.ps1 delete mode 100644 jdk-11/mvn-entrypoint.ps1 delete mode 100644 jdk-12/mvn-entrypoint.ps1 delete mode 100644 jdk-13/mvn-entrypoint.ps1 delete mode 100644 jdk-14/mvn-entrypoint.ps1 delete mode 100644 jdk-8/mvn-entrypoint.ps1 rename amazoncorretto-11/Dockerfile.windows => windows/Dockerfile.windows-amazoncorretto-11 (82%) rename amazoncorretto-8/Dockerfile.windows => windows/Dockerfile.windows-amazoncorretto-8 (80%) rename azulzulu-11/Dockerfile.windows => windows/Dockerfile.windows-azulzulu-11 (94%) rename jdk-11/Dockerfile.windows => windows/Dockerfile.windows-jdk-11 (100%) rename jdk-12/Dockerfile.windows => windows/Dockerfile.windows-jdk-12 (100%) rename jdk-13/Dockerfile.windows => windows/Dockerfile.windows-jdk-13 (100%) rename jdk-14/Dockerfile.windows => windows/Dockerfile.windows-jdk-14 (100%) rename jdk-8/Dockerfile.windows => windows/Dockerfile.windows-jdk-8 (83%) rename {amazoncorretto-11 => windows}/mvn-entrypoint.ps1 (100%) create mode 100644 windows/settings-docker.xml diff --git a/README.md b/README.md index e852e134..e9b64715 100644 --- a/README.md +++ b/README.md @@ -160,7 +160,7 @@ or run all the tests with ### Windows ```powershell -Get-ChildItem -Directory -Exclude tests,ibm*,*slim | ForEach-Object { Push-Location ; $env:TAG=$_.Name ; Invoke-Pester -Path tests ; Pop-Location } +Get-ChildItem -Path windows\* -File -Include "Dockerfile.windows-*" | ForEach-Object { Push-Location ; $env:TAG=$_.Name.Replace('Dockerfile.windows-', '') ; Invoke-Pester -Path tests ; Pop-Location } ``` Bats can be easily installed with `brew install bats` on OS X. diff --git a/amazoncorretto-8/mvn-entrypoint.ps1 b/amazoncorretto-8/mvn-entrypoint.ps1 deleted file mode 100644 index 09d0f7b2..00000000 --- a/amazoncorretto-8/mvn-entrypoint.ps1 +++ /dev/null @@ -1,48 +0,0 @@ - -# Copy files from C:/ProgramData/Maven/Reference into ${MAVEN_CONFIG} -# So the initial ~/.m2 is set with expected content. -# Don't override, as this is just a reference setup - -function Copy-ReferenceFiles() { - $log = "${env:MAVEN_CONFIG}/copy_reference_file.log" - $ref = "C:/ProgramData/Maven/Reference" - - $repo = Join-Path $env:MAVEN_CONFIG 'repository' - - New-Item -Path $repo -ItemType Directory -Force | Out-Null - Write-Output $null > $log - if((Test-Path $repo) -and (Test-Path $log)) { - $count = (Get-ChildItem $repo | Measure-Object).Count - if($count -eq 0) { - # destination is empty... - Add-Content -Path $log -Value "--- Copying all files to ${env:MAVEN_CONFIG} at $(Get-Date)" - Copy-Item -Path "$ref\*" -Destination $env:MAVEN_CONFIG -Force -Recurse | Add-Content -Path $log - } else { - # destination is non-empty, copy file-by-file - Add-Content -Path $log -Value "--- Copying individual files to ${MAVEN_CONFIG} at $(Get-Date)" - Get-ChildItem -Path $ref -File | ForEach-Object { - Push-Location $ref - $rel = Resolve-Path -Path $($_.FullName) -Relative - Pop-Location - if(!(Test-Path (Join-Path $env:MAVEN_CONFIG $rel)) -or (Test-Path $('{0}.override' -f $_.FullName))) { - $dir = Join-Path $env:MAVEN_CONFIG $($rel.DirectoryName) - if(!(Test-Path $dir)) { - New-Item -Path $dir -ItemType Directory | Out-Null - } - Copy-Item -Path $_.FullName -Destination (Join-Path $env:MAVEN_CONFIG $rel) | Add-Content -Path $log - } - } - } - Add-Content -Path $log -Value "" - } else { - Write-Warning "Can not write to ${log}. Wrong volume permissions? Carrying on ..." - } -} - -Push-Location -StackName 'maven-entrypoint' -Copy-ReferenceFiles -Pop-Location -StackName 'maven-entrypoint' - -Remove-Item Env:\MAVEN_CONFIG - -Invoke-Expression "$args" diff --git a/azulzulu-11/mvn-entrypoint.ps1 b/azulzulu-11/mvn-entrypoint.ps1 deleted file mode 100644 index 09d0f7b2..00000000 --- a/azulzulu-11/mvn-entrypoint.ps1 +++ /dev/null @@ -1,48 +0,0 @@ - -# Copy files from C:/ProgramData/Maven/Reference into ${MAVEN_CONFIG} -# So the initial ~/.m2 is set with expected content. -# Don't override, as this is just a reference setup - -function Copy-ReferenceFiles() { - $log = "${env:MAVEN_CONFIG}/copy_reference_file.log" - $ref = "C:/ProgramData/Maven/Reference" - - $repo = Join-Path $env:MAVEN_CONFIG 'repository' - - New-Item -Path $repo -ItemType Directory -Force | Out-Null - Write-Output $null > $log - if((Test-Path $repo) -and (Test-Path $log)) { - $count = (Get-ChildItem $repo | Measure-Object).Count - if($count -eq 0) { - # destination is empty... - Add-Content -Path $log -Value "--- Copying all files to ${env:MAVEN_CONFIG} at $(Get-Date)" - Copy-Item -Path "$ref\*" -Destination $env:MAVEN_CONFIG -Force -Recurse | Add-Content -Path $log - } else { - # destination is non-empty, copy file-by-file - Add-Content -Path $log -Value "--- Copying individual files to ${MAVEN_CONFIG} at $(Get-Date)" - Get-ChildItem -Path $ref -File | ForEach-Object { - Push-Location $ref - $rel = Resolve-Path -Path $($_.FullName) -Relative - Pop-Location - if(!(Test-Path (Join-Path $env:MAVEN_CONFIG $rel)) -or (Test-Path $('{0}.override' -f $_.FullName))) { - $dir = Join-Path $env:MAVEN_CONFIG $($rel.DirectoryName) - if(!(Test-Path $dir)) { - New-Item -Path $dir -ItemType Directory | Out-Null - } - Copy-Item -Path $_.FullName -Destination (Join-Path $env:MAVEN_CONFIG $rel) | Add-Content -Path $log - } - } - } - Add-Content -Path $log -Value "" - } else { - Write-Warning "Can not write to ${log}. Wrong volume permissions? Carrying on ..." - } -} - -Push-Location -StackName 'maven-entrypoint' -Copy-ReferenceFiles -Pop-Location -StackName 'maven-entrypoint' - -Remove-Item Env:\MAVEN_CONFIG - -Invoke-Expression "$args" diff --git a/jdk-11/mvn-entrypoint.ps1 b/jdk-11/mvn-entrypoint.ps1 deleted file mode 100644 index 09d0f7b2..00000000 --- a/jdk-11/mvn-entrypoint.ps1 +++ /dev/null @@ -1,48 +0,0 @@ - -# Copy files from C:/ProgramData/Maven/Reference into ${MAVEN_CONFIG} -# So the initial ~/.m2 is set with expected content. -# Don't override, as this is just a reference setup - -function Copy-ReferenceFiles() { - $log = "${env:MAVEN_CONFIG}/copy_reference_file.log" - $ref = "C:/ProgramData/Maven/Reference" - - $repo = Join-Path $env:MAVEN_CONFIG 'repository' - - New-Item -Path $repo -ItemType Directory -Force | Out-Null - Write-Output $null > $log - if((Test-Path $repo) -and (Test-Path $log)) { - $count = (Get-ChildItem $repo | Measure-Object).Count - if($count -eq 0) { - # destination is empty... - Add-Content -Path $log -Value "--- Copying all files to ${env:MAVEN_CONFIG} at $(Get-Date)" - Copy-Item -Path "$ref\*" -Destination $env:MAVEN_CONFIG -Force -Recurse | Add-Content -Path $log - } else { - # destination is non-empty, copy file-by-file - Add-Content -Path $log -Value "--- Copying individual files to ${MAVEN_CONFIG} at $(Get-Date)" - Get-ChildItem -Path $ref -File | ForEach-Object { - Push-Location $ref - $rel = Resolve-Path -Path $($_.FullName) -Relative - Pop-Location - if(!(Test-Path (Join-Path $env:MAVEN_CONFIG $rel)) -or (Test-Path $('{0}.override' -f $_.FullName))) { - $dir = Join-Path $env:MAVEN_CONFIG $($rel.DirectoryName) - if(!(Test-Path $dir)) { - New-Item -Path $dir -ItemType Directory | Out-Null - } - Copy-Item -Path $_.FullName -Destination (Join-Path $env:MAVEN_CONFIG $rel) | Add-Content -Path $log - } - } - } - Add-Content -Path $log -Value "" - } else { - Write-Warning "Can not write to ${log}. Wrong volume permissions? Carrying on ..." - } -} - -Push-Location -StackName 'maven-entrypoint' -Copy-ReferenceFiles -Pop-Location -StackName 'maven-entrypoint' - -Remove-Item Env:\MAVEN_CONFIG - -Invoke-Expression "$args" diff --git a/jdk-12/mvn-entrypoint.ps1 b/jdk-12/mvn-entrypoint.ps1 deleted file mode 100644 index 09d0f7b2..00000000 --- a/jdk-12/mvn-entrypoint.ps1 +++ /dev/null @@ -1,48 +0,0 @@ - -# Copy files from C:/ProgramData/Maven/Reference into ${MAVEN_CONFIG} -# So the initial ~/.m2 is set with expected content. -# Don't override, as this is just a reference setup - -function Copy-ReferenceFiles() { - $log = "${env:MAVEN_CONFIG}/copy_reference_file.log" - $ref = "C:/ProgramData/Maven/Reference" - - $repo = Join-Path $env:MAVEN_CONFIG 'repository' - - New-Item -Path $repo -ItemType Directory -Force | Out-Null - Write-Output $null > $log - if((Test-Path $repo) -and (Test-Path $log)) { - $count = (Get-ChildItem $repo | Measure-Object).Count - if($count -eq 0) { - # destination is empty... - Add-Content -Path $log -Value "--- Copying all files to ${env:MAVEN_CONFIG} at $(Get-Date)" - Copy-Item -Path "$ref\*" -Destination $env:MAVEN_CONFIG -Force -Recurse | Add-Content -Path $log - } else { - # destination is non-empty, copy file-by-file - Add-Content -Path $log -Value "--- Copying individual files to ${MAVEN_CONFIG} at $(Get-Date)" - Get-ChildItem -Path $ref -File | ForEach-Object { - Push-Location $ref - $rel = Resolve-Path -Path $($_.FullName) -Relative - Pop-Location - if(!(Test-Path (Join-Path $env:MAVEN_CONFIG $rel)) -or (Test-Path $('{0}.override' -f $_.FullName))) { - $dir = Join-Path $env:MAVEN_CONFIG $($rel.DirectoryName) - if(!(Test-Path $dir)) { - New-Item -Path $dir -ItemType Directory | Out-Null - } - Copy-Item -Path $_.FullName -Destination (Join-Path $env:MAVEN_CONFIG $rel) | Add-Content -Path $log - } - } - } - Add-Content -Path $log -Value "" - } else { - Write-Warning "Can not write to ${log}. Wrong volume permissions? Carrying on ..." - } -} - -Push-Location -StackName 'maven-entrypoint' -Copy-ReferenceFiles -Pop-Location -StackName 'maven-entrypoint' - -Remove-Item Env:\MAVEN_CONFIG - -Invoke-Expression "$args" diff --git a/jdk-13/mvn-entrypoint.ps1 b/jdk-13/mvn-entrypoint.ps1 deleted file mode 100644 index 09d0f7b2..00000000 --- a/jdk-13/mvn-entrypoint.ps1 +++ /dev/null @@ -1,48 +0,0 @@ - -# Copy files from C:/ProgramData/Maven/Reference into ${MAVEN_CONFIG} -# So the initial ~/.m2 is set with expected content. -# Don't override, as this is just a reference setup - -function Copy-ReferenceFiles() { - $log = "${env:MAVEN_CONFIG}/copy_reference_file.log" - $ref = "C:/ProgramData/Maven/Reference" - - $repo = Join-Path $env:MAVEN_CONFIG 'repository' - - New-Item -Path $repo -ItemType Directory -Force | Out-Null - Write-Output $null > $log - if((Test-Path $repo) -and (Test-Path $log)) { - $count = (Get-ChildItem $repo | Measure-Object).Count - if($count -eq 0) { - # destination is empty... - Add-Content -Path $log -Value "--- Copying all files to ${env:MAVEN_CONFIG} at $(Get-Date)" - Copy-Item -Path "$ref\*" -Destination $env:MAVEN_CONFIG -Force -Recurse | Add-Content -Path $log - } else { - # destination is non-empty, copy file-by-file - Add-Content -Path $log -Value "--- Copying individual files to ${MAVEN_CONFIG} at $(Get-Date)" - Get-ChildItem -Path $ref -File | ForEach-Object { - Push-Location $ref - $rel = Resolve-Path -Path $($_.FullName) -Relative - Pop-Location - if(!(Test-Path (Join-Path $env:MAVEN_CONFIG $rel)) -or (Test-Path $('{0}.override' -f $_.FullName))) { - $dir = Join-Path $env:MAVEN_CONFIG $($rel.DirectoryName) - if(!(Test-Path $dir)) { - New-Item -Path $dir -ItemType Directory | Out-Null - } - Copy-Item -Path $_.FullName -Destination (Join-Path $env:MAVEN_CONFIG $rel) | Add-Content -Path $log - } - } - } - Add-Content -Path $log -Value "" - } else { - Write-Warning "Can not write to ${log}. Wrong volume permissions? Carrying on ..." - } -} - -Push-Location -StackName 'maven-entrypoint' -Copy-ReferenceFiles -Pop-Location -StackName 'maven-entrypoint' - -Remove-Item Env:\MAVEN_CONFIG - -Invoke-Expression "$args" diff --git a/jdk-14/mvn-entrypoint.ps1 b/jdk-14/mvn-entrypoint.ps1 deleted file mode 100644 index 09d0f7b2..00000000 --- a/jdk-14/mvn-entrypoint.ps1 +++ /dev/null @@ -1,48 +0,0 @@ - -# Copy files from C:/ProgramData/Maven/Reference into ${MAVEN_CONFIG} -# So the initial ~/.m2 is set with expected content. -# Don't override, as this is just a reference setup - -function Copy-ReferenceFiles() { - $log = "${env:MAVEN_CONFIG}/copy_reference_file.log" - $ref = "C:/ProgramData/Maven/Reference" - - $repo = Join-Path $env:MAVEN_CONFIG 'repository' - - New-Item -Path $repo -ItemType Directory -Force | Out-Null - Write-Output $null > $log - if((Test-Path $repo) -and (Test-Path $log)) { - $count = (Get-ChildItem $repo | Measure-Object).Count - if($count -eq 0) { - # destination is empty... - Add-Content -Path $log -Value "--- Copying all files to ${env:MAVEN_CONFIG} at $(Get-Date)" - Copy-Item -Path "$ref\*" -Destination $env:MAVEN_CONFIG -Force -Recurse | Add-Content -Path $log - } else { - # destination is non-empty, copy file-by-file - Add-Content -Path $log -Value "--- Copying individual files to ${MAVEN_CONFIG} at $(Get-Date)" - Get-ChildItem -Path $ref -File | ForEach-Object { - Push-Location $ref - $rel = Resolve-Path -Path $($_.FullName) -Relative - Pop-Location - if(!(Test-Path (Join-Path $env:MAVEN_CONFIG $rel)) -or (Test-Path $('{0}.override' -f $_.FullName))) { - $dir = Join-Path $env:MAVEN_CONFIG $($rel.DirectoryName) - if(!(Test-Path $dir)) { - New-Item -Path $dir -ItemType Directory | Out-Null - } - Copy-Item -Path $_.FullName -Destination (Join-Path $env:MAVEN_CONFIG $rel) | Add-Content -Path $log - } - } - } - Add-Content -Path $log -Value "" - } else { - Write-Warning "Can not write to ${log}. Wrong volume permissions? Carrying on ..." - } -} - -Push-Location -StackName 'maven-entrypoint' -Copy-ReferenceFiles -Pop-Location -StackName 'maven-entrypoint' - -Remove-Item Env:\MAVEN_CONFIG - -Invoke-Expression "$args" diff --git a/jdk-8/mvn-entrypoint.ps1 b/jdk-8/mvn-entrypoint.ps1 deleted file mode 100644 index 09d0f7b2..00000000 --- a/jdk-8/mvn-entrypoint.ps1 +++ /dev/null @@ -1,48 +0,0 @@ - -# Copy files from C:/ProgramData/Maven/Reference into ${MAVEN_CONFIG} -# So the initial ~/.m2 is set with expected content. -# Don't override, as this is just a reference setup - -function Copy-ReferenceFiles() { - $log = "${env:MAVEN_CONFIG}/copy_reference_file.log" - $ref = "C:/ProgramData/Maven/Reference" - - $repo = Join-Path $env:MAVEN_CONFIG 'repository' - - New-Item -Path $repo -ItemType Directory -Force | Out-Null - Write-Output $null > $log - if((Test-Path $repo) -and (Test-Path $log)) { - $count = (Get-ChildItem $repo | Measure-Object).Count - if($count -eq 0) { - # destination is empty... - Add-Content -Path $log -Value "--- Copying all files to ${env:MAVEN_CONFIG} at $(Get-Date)" - Copy-Item -Path "$ref\*" -Destination $env:MAVEN_CONFIG -Force -Recurse | Add-Content -Path $log - } else { - # destination is non-empty, copy file-by-file - Add-Content -Path $log -Value "--- Copying individual files to ${MAVEN_CONFIG} at $(Get-Date)" - Get-ChildItem -Path $ref -File | ForEach-Object { - Push-Location $ref - $rel = Resolve-Path -Path $($_.FullName) -Relative - Pop-Location - if(!(Test-Path (Join-Path $env:MAVEN_CONFIG $rel)) -or (Test-Path $('{0}.override' -f $_.FullName))) { - $dir = Join-Path $env:MAVEN_CONFIG $($rel.DirectoryName) - if(!(Test-Path $dir)) { - New-Item -Path $dir -ItemType Directory | Out-Null - } - Copy-Item -Path $_.FullName -Destination (Join-Path $env:MAVEN_CONFIG $rel) | Add-Content -Path $log - } - } - } - Add-Content -Path $log -Value "" - } else { - Write-Warning "Can not write to ${log}. Wrong volume permissions? Carrying on ..." - } -} - -Push-Location -StackName 'maven-entrypoint' -Copy-ReferenceFiles -Pop-Location -StackName 'maven-entrypoint' - -Remove-Item Env:\MAVEN_CONFIG - -Invoke-Expression "$args" diff --git a/tests/maven.Tests.ps1 b/tests/maven.Tests.ps1 index c4c0a273..069c0f79 100644 --- a/tests/maven.Tests.ps1 +++ b/tests/maven.Tests.ps1 @@ -11,11 +11,11 @@ Import-Module -Force -DisableNameChecking $PSScriptRoot/test_helpers.psm1 Describe "$SUT_TAG build image" { BeforeEach { - Push-Location -StackName 'maven' -Path "$PSScriptRoot/../$SUT_TAG" + Push-Location -StackName 'maven' -Path "$PSScriptRoot/../windows" } It 'builds image' { - $exitCode, $stdout, $stderr = Build-Docker --pull -t $SUT_IMAGE + $exitCode, $stdout, $stderr = Build-Docker -ImageType $SUT_TAG --pull -t $SUT_IMAGE $lastExitCode | Should -Be 0 } @@ -25,16 +25,23 @@ Describe "$SUT_TAG build image" { } Describe "$SUT_TAG build test image" { + BeforeEach { + Push-Location -StackName 'maven' -Path "$PSScriptRoot" + } + It 'builds image' { - Push-Location -StackName 'maven' -Path $PSScriptRoot $exitCode, $stdout, $stderr = Build-Docker -t $SUT_TEST_IMAGE $exitCode | Should -Be 0 } + + AfterEach { + Pop-Location -StackName 'maven' + } } Describe "$SUT_TAG create test container" { It 'creates test container' { - $version = $(Get-Content -Path "$PSScriptRoot/../$SUT_TAG/Dockerfile.windows" | Select-String -Pattern 'ARG MAVEN_VERSION.*' | ForEach-Object { $_ -replace 'ARG MAVEN_VERSION=','' }) + $version = $(Get-Content -Path "$PSScriptRoot/../windows/Dockerfile.windows-$SUT_TAG" | Select-String -Pattern 'ARG MAVEN_VERSION.*' | ForEach-Object { $_ -replace 'ARG MAVEN_VERSION=','' }) $exitCode, $stdout, $stderr = Run-Program -Cmd "docker.exe" -Params "run --rm $SUT_IMAGE mvn -version" $exitCode | Should -Be 0 $stdout | Should -Match "Apache Maven $version" diff --git a/tests/test_helpers.psm1 b/tests/test_helpers.psm1 index 23b67e6a..4fb13dbf 100644 --- a/tests/test_helpers.psm1 +++ b/tests/test_helpers.psm1 @@ -4,52 +4,55 @@ function Test-CommandExists($command) { $ErrorActionPreference = 'stop' $res = $false try { - if(Get-Command $command) { - $res = $true + if(Get-Command $command) { + $res = $true } } catch { - $res = $false + $res = $false } finally { $ErrorActionPreference=$oldPreference } return $res } - + # check dependencies if(-Not (Test-CommandExists docker)) { Write-Error "docker is not available" } function Run-Program($Cmd, $Params) { - $psi = New-Object System.Diagnostics.ProcessStartInfo - $psi.CreateNoWindow = $true - $psi.UseShellExecute = $false - $psi.RedirectStandardOutput = $true + $psi = New-Object System.Diagnostics.ProcessStartInfo + $psi.CreateNoWindow = $true + $psi.UseShellExecute = $false + $psi.RedirectStandardOutput = $true $psi.RedirectStandardError = $true $psi.WorkingDirectory = (Get-Location) $psi.FileName = $Cmd $psi.Arguments = $Params - $proc = New-Object System.Diagnostics.Process - $proc.StartInfo = $psi + $proc = New-Object System.Diagnostics.Process + $proc.StartInfo = $psi [void]$proc.Start() - $stdout = $proc.StandardOutput.ReadToEnd() + $stdout = $proc.StandardOutput.ReadToEnd() $stderr = $proc.StandardError.ReadToEnd() - $proc.WaitForExit() + $proc.WaitForExit() if($proc.ExitCode -ne 0) { Write-Host "`n`nstdout:`n$stdout`n`nstderr:`n$stderr`n`n" } - + return $proc.ExitCode, $stdout, $stderr } -function Build-Docker { - return (Run-Program 'docker.exe' "build -f Dockerfile.windows $args .") +function Build-Docker($ImageType) { + if(![String]::IsNullOrWhitespace($ImageType) -and !$ImageType.StartsWith('-')) { + $ImageType = "-$ImageType" + } + return (Run-Program 'docker.exe' "build -f Dockerfile.windows$ImageType $args .") } function Retry-Command { [CmdletBinding()] param ( - [parameter(Mandatory, ValueFromPipeline)] + [parameter(Mandatory, ValueFromPipeline)] [ValidateNotNullOrEmpty()] [scriptblock] $ScriptBlock, [int] $RetryCount = 3, @@ -57,16 +60,16 @@ function Retry-Command { [string] $SuccessMessage = "Command executed successfuly!", [string] $FailureMessage = "Failed to execute the command" ) - + process { $Attempt = 1 $Flag = $true - + do { try { $PreviousPreference = $ErrorActionPreference $ErrorActionPreference = 'Stop' - Invoke-Command -NoNewScope -ScriptBlock $ScriptBlock -OutVariable Result 4>&1 + Invoke-Command -NoNewScope -ScriptBlock $ScriptBlock -OutVariable Result 4>&1 $ErrorActionPreference = $PreviousPreference # flow control will execute the next line only if the command in the scriptblock executed without any errors diff --git a/amazoncorretto-11/Dockerfile.windows b/windows/Dockerfile.windows-amazoncorretto-11 similarity index 82% rename from amazoncorretto-11/Dockerfile.windows rename to windows/Dockerfile.windows-amazoncorretto-11 index c8476544..73940cee 100644 --- a/amazoncorretto-11/Dockerfile.windows +++ b/windows/Dockerfile.windows-amazoncorretto-11 @@ -15,7 +15,6 @@ RUN Invoke-WebRequest -Uri $('{0}{1}' -f $env:uri,$env:zip) -OutFile C:/$env:zip ENV JAVA_HOME=C:/ProgramData/jdk11.0.4_10 - ARG MAVEN_VERSION=3.6.1 ARG USER_HOME_DIR="C:/Users/ContainerAdministrator" ARG SHA=51169366d7269ed316bad013d9cbfebe3a4ef1fda393ac4982d6dbc9af2d5cc359ee12838b8041cb998f236486e988b9c05372f4fdb29a96c1139f63c991e90e @@ -31,14 +30,8 @@ RUN Invoke-WebRequest -Uri ${env:BASE_URL}/apache-maven-${env:MAVEN_VERSION}-bin ENV MAVEN_HOME C:/ProgramData/Maven ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2" -# Workaround https://github.com/corretto/corretto-8-docker/pull/32 -#ENV JAVA_HOME=/usr/lib/jvm/java-1.8.0-amazon-corretto - COPY mvn-entrypoint.ps1 C:/ProgramData/Maven/mvn-entrypoint.ps1 COPY settings-docker.xml C:/ProgramData/Maven/Reference/settings-docker.xml -RUN $content = Get-Content "C:/ProgramData/Maven/Reference/settings-docker.xml" ; ` - $content | ForEach-Object { $_ -replace '/usr/share/maven/ref/repository','C:\ProgramData\Maven\Reference\repository' } | ` - Set-Content -Path "C:/ProgramData/Maven/Reference/settings-docker.xml" RUN setx /M PATH $('{0};{1}' -f $env:PATH,'C:\ProgramData\Maven\bin') | Out-Null diff --git a/amazoncorretto-8/Dockerfile.windows b/windows/Dockerfile.windows-amazoncorretto-8 similarity index 80% rename from amazoncorretto-8/Dockerfile.windows rename to windows/Dockerfile.windows-amazoncorretto-8 index 6f851e5d..9a6e3f0b 100644 --- a/amazoncorretto-8/Dockerfile.windows +++ b/windows/Dockerfile.windows-amazoncorretto-8 @@ -15,7 +15,6 @@ RUN Invoke-WebRequest -Uri $('{0}{1}' -f $env:uri,$env:zip) -OutFile C:/$env:zip ENV JAVA_HOME=C:/ProgramData/jdk1.8.0_222 - ARG MAVEN_VERSION=3.6.1 ARG USER_HOME_DIR="C:/Users/ContainerAdministrator" ARG SHA=51169366d7269ed316bad013d9cbfebe3a4ef1fda393ac4982d6dbc9af2d5cc359ee12838b8041cb998f236486e988b9c05372f4fdb29a96c1139f63c991e90e @@ -26,19 +25,13 @@ RUN Invoke-WebRequest -Uri ${env:BASE_URL}/apache-maven-${env:MAVEN_VERSION}-bin Expand-Archive -Path ${env:TEMP}/apache-maven.zip -Destination C:/ProgramData ; ` Move-Item C:/ProgramData/apache-maven-${env:MAVEN_VERSION} C:/ProgramData/Maven ; ` New-Item -ItemType Directory -Path C:/ProgramData/Maven/Reference | Out-Null ; ` - Remove-Item ${env:TEMP}/apache-maven.zip + Remove-Item ${env:TEMP}/apache-maven.zip ENV MAVEN_HOME C:/ProgramData/Maven ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2" -# Workaround https://github.com/corretto/corretto-8-docker/pull/32 -#ENV JAVA_HOME=/usr/lib/jvm/java-1.8.0-amazon-corretto - COPY mvn-entrypoint.ps1 C:/ProgramData/Maven/mvn-entrypoint.ps1 COPY settings-docker.xml C:/ProgramData/Maven/Reference/settings-docker.xml -RUN $content = Get-Content "C:/ProgramData/Maven/Reference/settings-docker.xml" ; ` - $content | ForEach-Object { $_ -replace '/usr/share/maven/ref/repository','C:\ProgramData\Maven\Reference\repository' } | ` - Set-Content -Path "C:/ProgramData/Maven/Reference/settings-docker.xml" RUN setx /M PATH $('{0};{1}' -f $env:PATH,'C:\ProgramData\Maven\bin') | Out-Null diff --git a/azulzulu-11/Dockerfile.windows b/windows/Dockerfile.windows-azulzulu-11 similarity index 94% rename from azulzulu-11/Dockerfile.windows rename to windows/Dockerfile.windows-azulzulu-11 index ee1ca529..fb81e300 100644 --- a/azulzulu-11/Dockerfile.windows +++ b/windows/Dockerfile.windows-azulzulu-11 @@ -31,8 +31,7 @@ RUN Invoke-WebRequest -Uri ${env:BASE_URL}/apache-maven-${env:MAVEN_VERSION}-bin ENV MAVEN_HOME C:/ProgramData/Maven ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2" -# Workaround https://github.com/corretto/corretto-8-docker/pull/32 -#ENV JAVA_HOME=/usr/lib/jvm/java-1.8.0-amazon-corretto +ENV JAVA_HOME=C:/ProgramData/zulu11.33.15-ca-jdk11.0.4-win_x64 COPY mvn-entrypoint.ps1 C:/ProgramData/Maven/mvn-entrypoint.ps1 COPY settings-docker.xml C:/ProgramData/Maven/Reference/settings-docker.xml diff --git a/jdk-11/Dockerfile.windows b/windows/Dockerfile.windows-jdk-11 similarity index 100% rename from jdk-11/Dockerfile.windows rename to windows/Dockerfile.windows-jdk-11 diff --git a/jdk-12/Dockerfile.windows b/windows/Dockerfile.windows-jdk-12 similarity index 100% rename from jdk-12/Dockerfile.windows rename to windows/Dockerfile.windows-jdk-12 diff --git a/jdk-13/Dockerfile.windows b/windows/Dockerfile.windows-jdk-13 similarity index 100% rename from jdk-13/Dockerfile.windows rename to windows/Dockerfile.windows-jdk-13 diff --git a/jdk-14/Dockerfile.windows b/windows/Dockerfile.windows-jdk-14 similarity index 100% rename from jdk-14/Dockerfile.windows rename to windows/Dockerfile.windows-jdk-14 diff --git a/jdk-8/Dockerfile.windows b/windows/Dockerfile.windows-jdk-8 similarity index 83% rename from jdk-8/Dockerfile.windows rename to windows/Dockerfile.windows-jdk-8 index 12d67560..0b2a6395 100644 --- a/jdk-8/Dockerfile.windows +++ b/windows/Dockerfile.windows-jdk-8 @@ -21,9 +21,6 @@ ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2" COPY mvn-entrypoint.ps1 C:/ProgramData/Maven/mvn-entrypoint.ps1 COPY settings-docker.xml C:/ProgramData/Maven/Reference/settings-docker.xml -RUN $content = Get-Content "C:/ProgramData/Maven/Reference/settings-docker.xml" ; ` - $content | ForEach-Object { $_ -replace '/usr/share/maven/ref/repository','C:\ProgramData\Maven\Reference\repository' } | ` - Set-Content -Path "C:/ProgramData/Maven/Reference/settings-docker.xml" RUN setx /M PATH $('{0};{1}' -f $env:PATH,'C:\ProgramData\Maven\bin') | Out-Null diff --git a/amazoncorretto-11/mvn-entrypoint.ps1 b/windows/mvn-entrypoint.ps1 similarity index 100% rename from amazoncorretto-11/mvn-entrypoint.ps1 rename to windows/mvn-entrypoint.ps1 diff --git a/windows/settings-docker.xml b/windows/settings-docker.xml new file mode 100644 index 00000000..9cd1a5ea --- /dev/null +++ b/windows/settings-docker.xml @@ -0,0 +1,6 @@ + + C:\ProgramData\Maven\Reference\repository + From 188e9f16210eb787da084b6f8d9d6e8ebda8c1ab Mon Sep 17 00:00:00 2001 From: Alex Earl Date: Mon, 26 Aug 2019 16:28:32 -0700 Subject: [PATCH 08/38] Capture failure code from expression --- jdk-8/mvn-entrypoint.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/jdk-8/mvn-entrypoint.ps1 b/jdk-8/mvn-entrypoint.ps1 index 09d0f7b2..13e3319b 100644 --- a/jdk-8/mvn-entrypoint.ps1 +++ b/jdk-8/mvn-entrypoint.ps1 @@ -46,3 +46,4 @@ Pop-Location -StackName 'maven-entrypoint' Remove-Item Env:\MAVEN_CONFIG Invoke-Expression "$args" +exit $lastExitCode From 6d4f058558fc8680bbcc42ad5de83ded0240095d Mon Sep 17 00:00:00 2001 From: Alex Earl Date: Mon, 26 Aug 2019 16:28:54 -0700 Subject: [PATCH 09/38] Capture failure code from expression --- jdk-11/mvn-entrypoint.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/jdk-11/mvn-entrypoint.ps1 b/jdk-11/mvn-entrypoint.ps1 index 09d0f7b2..13e3319b 100644 --- a/jdk-11/mvn-entrypoint.ps1 +++ b/jdk-11/mvn-entrypoint.ps1 @@ -46,3 +46,4 @@ Pop-Location -StackName 'maven-entrypoint' Remove-Item Env:\MAVEN_CONFIG Invoke-Expression "$args" +exit $lastExitCode From 2d1ce89d68829cd3d65abb925c42a1c4eeb3aa4a Mon Sep 17 00:00:00 2001 From: Alex Earl Date: Mon, 26 Aug 2019 16:29:09 -0700 Subject: [PATCH 10/38] Capture failure code from expression --- jdk-12/mvn-entrypoint.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/jdk-12/mvn-entrypoint.ps1 b/jdk-12/mvn-entrypoint.ps1 index 09d0f7b2..13e3319b 100644 --- a/jdk-12/mvn-entrypoint.ps1 +++ b/jdk-12/mvn-entrypoint.ps1 @@ -46,3 +46,4 @@ Pop-Location -StackName 'maven-entrypoint' Remove-Item Env:\MAVEN_CONFIG Invoke-Expression "$args" +exit $lastExitCode From 87864fb9495d3cab2d5071a95f3844fd6ed37f39 Mon Sep 17 00:00:00 2001 From: Alex Earl Date: Mon, 26 Aug 2019 16:29:23 -0700 Subject: [PATCH 11/38] Capture failure code from expression --- jdk-13/mvn-entrypoint.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/jdk-13/mvn-entrypoint.ps1 b/jdk-13/mvn-entrypoint.ps1 index 09d0f7b2..13e3319b 100644 --- a/jdk-13/mvn-entrypoint.ps1 +++ b/jdk-13/mvn-entrypoint.ps1 @@ -46,3 +46,4 @@ Pop-Location -StackName 'maven-entrypoint' Remove-Item Env:\MAVEN_CONFIG Invoke-Expression "$args" +exit $lastExitCode From 336b312258aef8a593a3334c996389b41c335b01 Mon Sep 17 00:00:00 2001 From: Alex Earl Date: Mon, 26 Aug 2019 16:29:40 -0700 Subject: [PATCH 12/38] Capture failure code from expression --- jdk-14/mvn-entrypoint.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/jdk-14/mvn-entrypoint.ps1 b/jdk-14/mvn-entrypoint.ps1 index 09d0f7b2..13e3319b 100644 --- a/jdk-14/mvn-entrypoint.ps1 +++ b/jdk-14/mvn-entrypoint.ps1 @@ -46,3 +46,4 @@ Pop-Location -StackName 'maven-entrypoint' Remove-Item Env:\MAVEN_CONFIG Invoke-Expression "$args" +exit $lastExitCode From 297328d30eb65f34648bd451604eea0460b9f99b Mon Sep 17 00:00:00 2001 From: Alex Earl Date: Mon, 26 Aug 2019 16:29:56 -0700 Subject: [PATCH 13/38] Capture failure code from expression --- azulzulu-11/mvn-entrypoint.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/azulzulu-11/mvn-entrypoint.ps1 b/azulzulu-11/mvn-entrypoint.ps1 index 09d0f7b2..13e3319b 100644 --- a/azulzulu-11/mvn-entrypoint.ps1 +++ b/azulzulu-11/mvn-entrypoint.ps1 @@ -46,3 +46,4 @@ Pop-Location -StackName 'maven-entrypoint' Remove-Item Env:\MAVEN_CONFIG Invoke-Expression "$args" +exit $lastExitCode From 2ee9fffa5e50cf8a61088a26f39de9d82fe5e269 Mon Sep 17 00:00:00 2001 From: Alex Earl Date: Mon, 26 Aug 2019 16:30:10 -0700 Subject: [PATCH 14/38] Capture failure code from expression --- amazoncorretto-8/mvn-entrypoint.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/amazoncorretto-8/mvn-entrypoint.ps1 b/amazoncorretto-8/mvn-entrypoint.ps1 index 09d0f7b2..13e3319b 100644 --- a/amazoncorretto-8/mvn-entrypoint.ps1 +++ b/amazoncorretto-8/mvn-entrypoint.ps1 @@ -46,3 +46,4 @@ Pop-Location -StackName 'maven-entrypoint' Remove-Item Env:\MAVEN_CONFIG Invoke-Expression "$args" +exit $lastExitCode From 929e16b66b90ef463934198c58fddb4710b26c63 Mon Sep 17 00:00:00 2001 From: Alex Earl Date: Mon, 26 Aug 2019 16:30:25 -0700 Subject: [PATCH 15/38] Capture failure code from expression --- amazoncorretto-11/mvn-entrypoint.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/amazoncorretto-11/mvn-entrypoint.ps1 b/amazoncorretto-11/mvn-entrypoint.ps1 index 09d0f7b2..13e3319b 100644 --- a/amazoncorretto-11/mvn-entrypoint.ps1 +++ b/amazoncorretto-11/mvn-entrypoint.ps1 @@ -46,3 +46,4 @@ Pop-Location -StackName 'maven-entrypoint' Remove-Item Env:\MAVEN_CONFIG Invoke-Expression "$args" +exit $lastExitCode From 4d2411c938952536321469044f547e4f0fb78e20 Mon Sep 17 00:00:00 2001 From: Alex Earl Date: Mon, 26 Aug 2019 16:30:52 -0700 Subject: [PATCH 16/38] Capture failure code from expression --- windows/mvn-entrypoint.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/windows/mvn-entrypoint.ps1 b/windows/mvn-entrypoint.ps1 index 09d0f7b2..13e3319b 100644 --- a/windows/mvn-entrypoint.ps1 +++ b/windows/mvn-entrypoint.ps1 @@ -46,3 +46,4 @@ Pop-Location -StackName 'maven-entrypoint' Remove-Item Env:\MAVEN_CONFIG Invoke-Expression "$args" +exit $lastExitCode From dc81bc7603335452706ca7d9ab60a495d1c3b1dd Mon Sep 17 00:00:00 2001 From: Alex Earl Date: Mon, 26 Aug 2019 16:36:43 -0700 Subject: [PATCH 17/38] Fix test --- tests/maven.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/maven.Tests.ps1 b/tests/maven.Tests.ps1 index 069c0f79..ba773003 100644 --- a/tests/maven.Tests.ps1 +++ b/tests/maven.Tests.ps1 @@ -67,7 +67,7 @@ Describe "$SUT_TAG repository is created" { Describe "$SUT_TAG run Maven" { It 'runs maven' { - $exitCode, $stdout, $stderr = Run-Program -Cmd "docker.exe" -Params "run --rm $SUT_TEST_IMAGE mvn -B -ntp -f $env:TEMP install" + $exitCode, $stdout, $stderr = Run-Program -Cmd "docker.exe" -Params "run --rm $SUT_TEST_IMAGE mvn -B -ntp -f C:/Temp install" $exitCode | Should -Be 0 } } From 5f26db8f5dd6a5f25a767c7f61fb1cb18aed6b6b Mon Sep 17 00:00:00 2001 From: Alex Earl Date: Mon, 26 Aug 2019 16:41:07 -0700 Subject: [PATCH 18/38] Fix test --- tests/maven.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/maven.Tests.ps1 b/tests/maven.Tests.ps1 index c4c0a273..f6ddb857 100644 --- a/tests/maven.Tests.ps1 +++ b/tests/maven.Tests.ps1 @@ -60,7 +60,7 @@ Describe "$SUT_TAG repository is created" { Describe "$SUT_TAG run Maven" { It 'runs maven' { - $exitCode, $stdout, $stderr = Run-Program -Cmd "docker.exe" -Params "run --rm $SUT_TEST_IMAGE mvn -B -ntp -f $env:TEMP install" + $exitCode, $stdout, $stderr = Run-Program -Cmd "docker.exe" -Params "run --rm $SUT_TEST_IMAGE mvn -B -ntp -f C:/Temp install" $exitCode | Should -Be 0 } } From cc45372982eb1916ae704fd3e122da70abef4226 Mon Sep 17 00:00:00 2001 From: Alex Earl Date: Wed, 23 Oct 2019 12:54:38 -0700 Subject: [PATCH 19/38] Remove update of settings-docker.xml --- windows/Dockerfile.windows-azulzulu-11 | 3 --- windows/Dockerfile.windows-jdk-11 | 3 --- windows/Dockerfile.windows-jdk-12 | 3 --- windows/Dockerfile.windows-jdk-13 | 3 --- windows/Dockerfile.windows-jdk-14 | 3 --- 5 files changed, 15 deletions(-) diff --git a/windows/Dockerfile.windows-azulzulu-11 b/windows/Dockerfile.windows-azulzulu-11 index fb81e300..d1ee0a24 100644 --- a/windows/Dockerfile.windows-azulzulu-11 +++ b/windows/Dockerfile.windows-azulzulu-11 @@ -35,9 +35,6 @@ ENV JAVA_HOME=C:/ProgramData/zulu11.33.15-ca-jdk11.0.4-win_x64 COPY mvn-entrypoint.ps1 C:/ProgramData/Maven/mvn-entrypoint.ps1 COPY settings-docker.xml C:/ProgramData/Maven/Reference/settings-docker.xml -RUN $content = Get-Content "C:/ProgramData/Maven/Reference/settings-docker.xml" ; ` - $content | ForEach-Object { $_ -replace '/usr/share/maven/ref/repository','C:\ProgramData\Maven\Reference\repository' } | ` - Set-Content -Path "C:/ProgramData/Maven/Reference/settings-docker.xml" RUN setx /M PATH $('{0};{1}' -f $env:PATH,'C:\ProgramData\Maven\bin') | Out-Null diff --git a/windows/Dockerfile.windows-jdk-11 b/windows/Dockerfile.windows-jdk-11 index a06a5b1b..e5001cfe 100644 --- a/windows/Dockerfile.windows-jdk-11 +++ b/windows/Dockerfile.windows-jdk-11 @@ -24,9 +24,6 @@ ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2" COPY mvn-entrypoint.ps1 C:/ProgramData/Maven/mvn-entrypoint.ps1 COPY settings-docker.xml C:/ProgramData/Maven/Reference/settings-docker.xml -RUN $content = Get-Content "C:/ProgramData/Maven/Reference/settings-docker.xml" ; ` - $content | ForEach-Object { $_ -replace '/usr/share/maven/ref/repository','C:\ProgramData\Maven\Reference\repository' } | ` - Set-Content -Path "C:/ProgramData/Maven/Reference/settings-docker.xml" RUN setx /M PATH $('{0};{1}' -f $env:PATH,'C:\ProgramData\Maven\bin') | Out-Null diff --git a/windows/Dockerfile.windows-jdk-12 b/windows/Dockerfile.windows-jdk-12 index 02ebd06d..8f16aea2 100644 --- a/windows/Dockerfile.windows-jdk-12 +++ b/windows/Dockerfile.windows-jdk-12 @@ -24,9 +24,6 @@ ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2" COPY mvn-entrypoint.ps1 C:/ProgramData/Maven/mvn-entrypoint.ps1 COPY settings-docker.xml C:/ProgramData/Maven/Reference/settings-docker.xml -RUN $content = Get-Content "C:/ProgramData/Maven/Reference/settings-docker.xml" ; ` - $content | ForEach-Object { $_ -replace '/usr/share/maven/ref/repository','C:\ProgramData\Maven\Reference\repository' } | ` - Set-Content -Path "C:/ProgramData/Maven/Reference/settings-docker.xml" RUN setx /M PATH $('{0};{1}' -f $env:PATH,'C:\ProgramData\Maven\bin') | Out-Null diff --git a/windows/Dockerfile.windows-jdk-13 b/windows/Dockerfile.windows-jdk-13 index c2cd94ac..9c521321 100644 --- a/windows/Dockerfile.windows-jdk-13 +++ b/windows/Dockerfile.windows-jdk-13 @@ -24,9 +24,6 @@ ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2" COPY mvn-entrypoint.ps1 C:/ProgramData/Maven/mvn-entrypoint.ps1 COPY settings-docker.xml C:/ProgramData/Maven/Reference/settings-docker.xml -RUN $content = Get-Content "C:/ProgramData/Maven/Reference/settings-docker.xml" ; ` - $content | ForEach-Object { $_ -replace '/usr/share/maven/ref/repository','C:\ProgramData\Maven\Reference\repository' } | ` - Set-Content -Path "C:/ProgramData/Maven/Reference/settings-docker.xml" RUN setx /M PATH $('{0};{1}' -f $env:PATH,'C:\ProgramData\Maven\bin') | Out-Null diff --git a/windows/Dockerfile.windows-jdk-14 b/windows/Dockerfile.windows-jdk-14 index 1aaedcd7..7d49f12d 100644 --- a/windows/Dockerfile.windows-jdk-14 +++ b/windows/Dockerfile.windows-jdk-14 @@ -24,9 +24,6 @@ ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2" COPY mvn-entrypoint.ps1 C:/ProgramData/Maven/mvn-entrypoint.ps1 COPY settings-docker.xml C:/ProgramData/Maven/Reference/settings-docker.xml -RUN $content = Get-Content "C:/ProgramData/Maven/Reference/settings-docker.xml" ; ` - $content | ForEach-Object { $_ -replace '/usr/share/maven/ref/repository','C:\ProgramData\Maven\Reference\repository' } | ` - Set-Content -Path "C:/ProgramData/Maven/Reference/settings-docker.xml" RUN setx /M PATH $('{0};{1}' -f $env:PATH,'C:\ProgramData\Maven\bin') | Out-Null From e6ca0dbf47b15982767c9b51376b2a5841a01863 Mon Sep 17 00:00:00 2001 From: Alex Earl Date: Thu, 24 Oct 2019 06:20:08 -0700 Subject: [PATCH 20/38] Windows support updates --- .github/workflows/main.yml | 55 ++++++++++++++++++++ .gitignore | 4 ++ README.md | 3 +- tests/maven.Tests.ps1 | 4 +- windows/Dockerfile.windows-amazoncorretto-11 | 19 ++++--- windows/Dockerfile.windows-amazoncorretto-8 | 15 +++--- windows/Dockerfile.windows-azulzulu-11 | 20 +++---- windows/Dockerfile.windows-jdk-11 | 14 ++--- windows/Dockerfile.windows-jdk-11-nanoserver | 45 ++++++++++++++++ windows/Dockerfile.windows-jdk-12 | 14 ++--- windows/Dockerfile.windows-jdk-13 | 14 ++--- windows/Dockerfile.windows-jdk-14 | 14 ++--- windows/Dockerfile.windows-jdk-8 | 11 ++-- windows/Dockerfile.windows-jdk-8-nanoserver | 45 ++++++++++++++++ 14 files changed, 218 insertions(+), 59 deletions(-) create mode 100644 .github/workflows/main.yml create mode 100644 .gitignore create mode 100644 windows/Dockerfile.windows-jdk-11-nanoserver create mode 100644 windows/Dockerfile.windows-jdk-8-nanoserver diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..04c6a348 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,55 @@ +name: Windows Docker Image CI + +on: [push, pull_request] + +jobs: + build: + + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [windows-2019, windows-2016] + + steps: + - uses: actions/checkout@v1 + - name: Build Images + run: | + $tags = @('3.6.2', '3.6', '3') + Get-ChildItem -Path windows\* -File -Include "Dockerfile.windows-*" | ForEach-Object { + Push-Location + $dockerfile = $_ + + $windowsType = 'windows-servercore' + $windowsDockerTag = ('ltsc{0}' -f '${{ matrix.os }}'.Replace('windows-', '')) + + if($dockerfile.Name.Contains('nanoserver')) { + # No nanoserver for 2016 + if('${{ matrix.os }}' -eq 'windows-2016') { + continue + } + $windowsType = 'windows-nanoserver' + $windowsDockerTag = '1809' + } + + # run tests + Push-Location + $env:TAG=$dockerfile.Name.Replace('Dockerfile.windows-', '') + $env:WINDOWS_DOCKER_TAG=$windowsDockerTag + Invoke-Pester -Path tests + Remove-Item env:\TAG + Remove-Item env:\WINDOWS_DOCKER_TAG + Pop-Location + + $tags | ForEach-Object { + $tag = ('maven:{0}-{1}-{2}-{3}' -f $_,$dockerfile.Name.Replace('Dockerfile.windows-', ''),$windowsType,$windowsDockerTag) + docker build -f $dockerfile --tag $tag --build-arg WINDOWS_DOCKER_TAG=${windowsDockerTag} . + + if('${{ github.event_name }}' -eq 'push') { + Write-Host 'YOU ARE IN A PUSH OPERATION' + # '${{ secrets.DOCKER_PASSWORD }}' | docker login --username ${{ secrets.DOCKER_USERNAME }} --password-stdin + # & docker push $tag + } + } + Pop-Location + } + shell: pwsh \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..94739099 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +/tests/.classpath +/tests/.project +/tests/.settings/ +/tests/target/ diff --git a/README.md b/README.md index ab1351f1..d37924ef 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,7 @@ Or you can just use your home .m2 cache directory that you share e.g. with your # Packaging a local repository with the image -The `$MAVEN_CONFIG` dir (default to `/root/.m2` or `C:\Users\ContainerAdministrator\.m2`) could be configured as a volume so anything copied there in a Dockerfile +The `$MAVEN_CONFIG` dir (default to `/root/.m2` or `C:\Users\ContainerUser\.m2`) could be configured as a volume so anything copied there in a Dockerfile at build time is lost. For that reason the dir `/usr/share/maven/ref/` (or `C:\ProgramData\Maven\Reference`) exists, and anything in that directory will be copied on container startup to `$MAVEN_CONFIG`. @@ -172,7 +172,6 @@ git submodule init git submodule update ``` - Pester comes with most modern Windows (Windows 10 and Windows Server 2019), but is an older version than required. You may need to follow [this tutorial](https://blog.damianflynn.com/Windows10-Pester/) on upgrading Pester to 4.x. diff --git a/tests/maven.Tests.ps1 b/tests/maven.Tests.ps1 index ba773003..ab88a0b6 100644 --- a/tests/maven.Tests.ps1 +++ b/tests/maven.Tests.ps1 @@ -50,7 +50,7 @@ Describe "$SUT_TAG create test container" { Describe "$SUT_TAG settings.xml is setup" { It 'sets up settings.xml' { - $exitCode, $stdout, $stderr = Run-Program -Cmd "docker.exe" -Params "run --rm $SUT_TEST_IMAGE Get-Content C:/Users/ContainerAdministrator/.m2/settings.xml" + $exitCode, $stdout, $stderr = Run-Program -Cmd "docker.exe" -Params "run --rm $SUT_TEST_IMAGE Get-Content C:/Users/ContainerUser/.m2/settings.xml" $exitCode | Should -Be 0 "$PSScriptRoot/settings.xml" | Should -FileContentMatchMultiline $stdout } @@ -59,7 +59,7 @@ Describe "$SUT_TAG settings.xml is setup" { Describe "$SUT_TAG repository is created" { It 'created repository' { - $exitCode, $stdout, $stderr = Run-Program -Cmd "docker.exe" -Params "run --rm $SUT_TEST_IMAGE if(Test-Path C:/Users/ContainerAdministrator/.m2/repository/junit/junit/3.8.1/junit-3.8.1.jar) { exit 0 } else {exit 1 }" + $exitCode, $stdout, $stderr = Run-Program -Cmd "docker.exe" -Params "run --rm $SUT_TEST_IMAGE if(Test-Path C:/Users/ContainerUser/.m2/repository/junit/junit/3.8.1/junit-3.8.1.jar) { exit 0 } else {exit 1 }" $exitCode | Should -Be 0 } } diff --git a/windows/Dockerfile.windows-amazoncorretto-11 b/windows/Dockerfile.windows-amazoncorretto-11 index 73940cee..e42af24e 100644 --- a/windows/Dockerfile.windows-amazoncorretto-11 +++ b/windows/Dockerfile.windows-amazoncorretto-11 @@ -4,20 +4,20 @@ FROM mcr.microsoft.com/windows/servercore:$WINDOWS_DOCKER_TAG SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] -ARG zip=amazon-corretto-11.0.4.11.1-windows-x64.zip -ARG uri=https://d3pxv6yz143wms.cloudfront.net/11.0.4.11.1/ -ARG hash=707c839c3f56645454b8c8d31f255161 +ARG zip=amazon-corretto-11.0.5.10.1-windows-x64.zip +ARG uri=https://d3pxv6yz143wms.cloudfront.net/11.0.5.10.1/ +ARG hash=741d0fcee20754e17dd230d7eaf5dff3 RUN Invoke-WebRequest -Uri $('{0}{1}' -f $env:uri,$env:zip) -OutFile C:/$env:zip ; ` if((Get-FileHash C:/$env:zip -Algorithm MD5).Hash.ToLower() -ne $env:hash) { exit 1 } ; ` Expand-Archive -Path C:/$env:zip -Destination C:/ProgramData ; ` Remove-Item C:/${env:zip} -ENV JAVA_HOME=C:/ProgramData/jdk11.0.4_10 +ENV JAVA_HOME=C:/ProgramData/jdk11.0.5_10 -ARG MAVEN_VERSION=3.6.1 -ARG USER_HOME_DIR="C:/Users/ContainerAdministrator" -ARG SHA=51169366d7269ed316bad013d9cbfebe3a4ef1fda393ac4982d6dbc9af2d5cc359ee12838b8041cb998f236486e988b9c05372f4fdb29a96c1139f63c991e90e +ARG USER_HOME_DIR="C:/Users/ContainerUser" +ARG MAVEN_VERSION=3.6.2 +ARG SHA=4bb0e0bb1fb74f1b990ba9a6493cc6345873d9188fc7613df16ab0d5bd2017de5a3917af4502792f0bad1fcc95785dcc6660f7add53548e0ec4bfb30ce4b1da7 ARG BASE_URL=https://apache.osuosl.org/maven/maven-3/${MAVEN_VERSION}/binaries RUN Invoke-WebRequest -Uri ${env:BASE_URL}/apache-maven-${env:MAVEN_VERSION}-bin.zip -OutFile ${env:TEMP}/apache-maven.zip ; ` @@ -25,7 +25,7 @@ RUN Invoke-WebRequest -Uri ${env:BASE_URL}/apache-maven-${env:MAVEN_VERSION}-bin Expand-Archive -Path ${env:TEMP}/apache-maven.zip -Destination C:/ProgramData ; ` Move-Item C:/ProgramData/apache-maven-${env:MAVEN_VERSION} C:/ProgramData/Maven ; ` New-Item -ItemType Directory -Path C:/ProgramData/Maven/Reference | Out-Null ; ` - Remove-Item ${env:TEMP}/apache-maven.zip + Remove-Item ${env:TEMP}/apache-maven.zip ENV MAVEN_HOME C:/ProgramData/Maven ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2" @@ -35,5 +35,8 @@ COPY settings-docker.xml C:/ProgramData/Maven/Reference/settings-docker.xml RUN setx /M PATH $('{0};{1}' -f $env:PATH,'C:\ProgramData\Maven\bin') | Out-Null +USER ContainerUser +ENV JAVA_HOME=${JAVA_HOME} + ENTRYPOINT ["powershell.exe", "-f", "C:/ProgramData/Maven/mvn-entrypoint.ps1"] CMD ["mvn"] diff --git a/windows/Dockerfile.windows-amazoncorretto-8 b/windows/Dockerfile.windows-amazoncorretto-8 index 9a6e3f0b..4caf5f47 100644 --- a/windows/Dockerfile.windows-amazoncorretto-8 +++ b/windows/Dockerfile.windows-amazoncorretto-8 @@ -4,9 +4,9 @@ FROM mcr.microsoft.com/windows/servercore:$WINDOWS_DOCKER_TAG SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] -ARG zip=amazon-corretto-8.222.10.3-windows-x64-jdk.zip -ARG uri=https://d3pxv6yz143wms.cloudfront.net/8.222.10.1/ -ARG hash=9879a7f69c0bd7d8c1bbb916df7b5f82 +ARG zip=amazon-corretto-8.232.09.1-windows-x64-jdk.zip +ARG uri=https://d3pxv6yz143wms.cloudfront.net/8.232.09.1/ +ARG hash=b0d375cbcfcda6d04e87888c6c6763d3 RUN Invoke-WebRequest -Uri $('{0}{1}' -f $env:uri,$env:zip) -OutFile C:/$env:zip ; ` if((Get-FileHash C:/$env:zip -Algorithm MD5).Hash.ToLower() -ne $env:hash) { exit 1 } ; ` @@ -15,9 +15,9 @@ RUN Invoke-WebRequest -Uri $('{0}{1}' -f $env:uri,$env:zip) -OutFile C:/$env:zip ENV JAVA_HOME=C:/ProgramData/jdk1.8.0_222 -ARG MAVEN_VERSION=3.6.1 -ARG USER_HOME_DIR="C:/Users/ContainerAdministrator" -ARG SHA=51169366d7269ed316bad013d9cbfebe3a4ef1fda393ac4982d6dbc9af2d5cc359ee12838b8041cb998f236486e988b9c05372f4fdb29a96c1139f63c991e90e +ARG USER_HOME_DIR="C:/Users/ContainerUser" +ARG MAVEN_VERSION=3.6.2 +ARG SHA=4bb0e0bb1fb74f1b990ba9a6493cc6345873d9188fc7613df16ab0d5bd2017de5a3917af4502792f0bad1fcc95785dcc6660f7add53548e0ec4bfb30ce4b1da7 ARG BASE_URL=https://apache.osuosl.org/maven/maven-3/${MAVEN_VERSION}/binaries RUN Invoke-WebRequest -Uri ${env:BASE_URL}/apache-maven-${env:MAVEN_VERSION}-bin.zip -OutFile ${env:TEMP}/apache-maven.zip ; ` @@ -35,5 +35,8 @@ COPY settings-docker.xml C:/ProgramData/Maven/Reference/settings-docker.xml RUN setx /M PATH $('{0};{1}' -f $env:PATH,'C:\ProgramData\Maven\bin') | Out-Null +USER ContainerUser +ENV JAVA_HOME=${JAVA_HOME} + ENTRYPOINT ["powershell.exe", "-f", "C:/ProgramData/Maven/mvn-entrypoint.ps1"] CMD ["mvn"] diff --git a/windows/Dockerfile.windows-azulzulu-11 b/windows/Dockerfile.windows-azulzulu-11 index d1ee0a24..5a682c7e 100644 --- a/windows/Dockerfile.windows-azulzulu-11 +++ b/windows/Dockerfile.windows-azulzulu-11 @@ -4,21 +4,20 @@ FROM mcr.microsoft.com/windows/servercore:$WINDOWS_DOCKER_TAG SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] -ARG zip=zulu11.33.15-ca-jdk11.0.4-win_x64.zip +ARG zip=/zulu11.35.13-ca-jdk11.0.5-win_x64.zip ARG uri=https://cdn.azul.com/zulu/bin/ -ARG hash=ae13f3de1e7be9b3aa8d0afbfd5f2f9d6aba356276a39ccfcaf3511feb860f05 +ARG hash=ac2d5f8a1e60b2dcb35323c8039ab117b539514f5610fe3602da65f74bad16b8 RUN Invoke-WebRequest -Uri $('{0}{1}' -f $env:uri,$env:zip) -OutFile C:/$env:zip ; ` if((Get-FileHash C:/$env:zip -Algorithm SHA256).Hash.ToLower() -ne $env:hash) { exit 1 } ; ` Expand-Archive -Path C:/$env:zip -Destination C:/ProgramData ; ` Remove-Item C:/${env:zip} -ENV JAVA_HOME=C:/ProgramData/zulu11.33.15-ca-jdk11.0.4-win_x64 +ENV JAVA_HOME=C:/ProgramData/zulu11.35.13-ca-jdk11.0.5-win_x64 - -ARG MAVEN_VERSION=3.6.1 -ARG USER_HOME_DIR="C:/Users/ContainerAdministrator" -ARG SHA=51169366d7269ed316bad013d9cbfebe3a4ef1fda393ac4982d6dbc9af2d5cc359ee12838b8041cb998f236486e988b9c05372f4fdb29a96c1139f63c991e90e +ARG USER_HOME_DIR="C:/Users/ContainerUser" +ARG MAVEN_VERSION=3.6.2 +ARG SHA=4bb0e0bb1fb74f1b990ba9a6493cc6345873d9188fc7613df16ab0d5bd2017de5a3917af4502792f0bad1fcc95785dcc6660f7add53548e0ec4bfb30ce4b1da7 ARG BASE_URL=https://apache.osuosl.org/maven/maven-3/${MAVEN_VERSION}/binaries RUN Invoke-WebRequest -Uri ${env:BASE_URL}/apache-maven-${env:MAVEN_VERSION}-bin.zip -OutFile ${env:TEMP}/apache-maven.zip ; ` @@ -26,17 +25,20 @@ RUN Invoke-WebRequest -Uri ${env:BASE_URL}/apache-maven-${env:MAVEN_VERSION}-bin Expand-Archive -Path ${env:TEMP}/apache-maven.zip -Destination C:/ProgramData ; ` Move-Item C:/ProgramData/apache-maven-${env:MAVEN_VERSION} C:/ProgramData/Maven ; ` New-Item -ItemType Directory -Path C:/ProgramData/Maven/Reference | Out-Null ; ` - Remove-Item ${env:TEMP}/apache-maven.zip + Remove-Item ${env:TEMP}/apache-maven.zip ENV MAVEN_HOME C:/ProgramData/Maven ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2" -ENV JAVA_HOME=C:/ProgramData/zulu11.33.15-ca-jdk11.0.4-win_x64 +ENV JAVA_HOME=C:/ProgramData/zulu11.35.13-ca-jdk11.0.5-win_x64 COPY mvn-entrypoint.ps1 C:/ProgramData/Maven/mvn-entrypoint.ps1 COPY settings-docker.xml C:/ProgramData/Maven/Reference/settings-docker.xml RUN setx /M PATH $('{0};{1}' -f $env:PATH,'C:\ProgramData\Maven\bin') | Out-Null +USER ContainerUser +ENV JAVA_HOME=${JAVA_HOME} + ENTRYPOINT ["powershell.exe", "-f", "C:/ProgramData/Maven/mvn-entrypoint.ps1"] CMD ["mvn"] diff --git a/windows/Dockerfile.windows-jdk-11 b/windows/Dockerfile.windows-jdk-11 index e5001cfe..6d4b84d0 100644 --- a/windows/Dockerfile.windows-jdk-11 +++ b/windows/Dockerfile.windows-jdk-11 @@ -4,9 +4,9 @@ FROM openjdk:11-jdk-windowsservercore-$WINDOWS_DOCKER_TAG SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] -ARG MAVEN_VERSION=3.6.1 -ARG USER_HOME_DIR="C:/Users/ContainerAdministrator" -ARG SHA=51169366d7269ed316bad013d9cbfebe3a4ef1fda393ac4982d6dbc9af2d5cc359ee12838b8041cb998f236486e988b9c05372f4fdb29a96c1139f63c991e90e +ARG USER_HOME_DIR="C:/Users/ContainerUser" +ARG MAVEN_VERSION=3.6.2 +ARG SHA=4bb0e0bb1fb74f1b990ba9a6493cc6345873d9188fc7613df16ab0d5bd2017de5a3917af4502792f0bad1fcc95785dcc6660f7add53548e0ec4bfb30ce4b1da7 ARG BASE_URL=https://apache.osuosl.org/maven/maven-3/${MAVEN_VERSION}/binaries RUN Invoke-WebRequest -Uri ${env:BASE_URL}/apache-maven-${env:MAVEN_VERSION}-bin.zip -OutFile ${env:TEMP}/apache-maven.zip ; ` @@ -14,18 +14,18 @@ RUN Invoke-WebRequest -Uri ${env:BASE_URL}/apache-maven-${env:MAVEN_VERSION}-bin Expand-Archive -Path ${env:TEMP}/apache-maven.zip -Destination C:/ProgramData ; ` Move-Item C:/ProgramData/apache-maven-${env:MAVEN_VERSION} C:/ProgramData/Maven ; ` New-Item -ItemType Directory -Path C:/ProgramData/Maven/Reference | Out-Null ; ` - Remove-Item ${env:TEMP}/apache-maven.zip + Remove-Item ${env:TEMP}/apache-maven.zip ENV MAVEN_HOME C:/ProgramData/Maven ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2" -# Workaround https://github.com/corretto/corretto-8-docker/pull/32 -#ENV JAVA_HOME=/usr/lib/jvm/java-1.8.0-amazon-corretto - COPY mvn-entrypoint.ps1 C:/ProgramData/Maven/mvn-entrypoint.ps1 COPY settings-docker.xml C:/ProgramData/Maven/Reference/settings-docker.xml RUN setx /M PATH $('{0};{1}' -f $env:PATH,'C:\ProgramData\Maven\bin') | Out-Null +USER ContainerUser +ENV JAVA_HOME=${JAVA_HOME} + ENTRYPOINT ["powershell.exe", "-f", "C:/ProgramData/Maven/mvn-entrypoint.ps1"] CMD ["mvn"] diff --git a/windows/Dockerfile.windows-jdk-11-nanoserver b/windows/Dockerfile.windows-jdk-11-nanoserver new file mode 100644 index 00000000..69d4bbfa --- /dev/null +++ b/windows/Dockerfile.windows-jdk-11-nanoserver @@ -0,0 +1,45 @@ +# escape=` +ARG WINDOWS_DOCKER_TAG=1809 +ARG JAVA_VERSION=11.0.5 +# we use the latest stable if nothing is passed +ARG POWERSHELL_VERSION= + +FROM openjdk:${JAVA_VERSION}-windowsservercore-${WINDOWS_DOCKER_TAG} as openjdk + +FROM mcr.microsoft.com/powershell:${POWERSHELL_VERSION}nanoserver-$WINDOWS_DOCKER_TAG + +SHELL ["pwsh", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] + +USER ContainerAdministrator + +ENV JAVA_HOME=C:\openjdk-11 + +COPY --from=openjdk $JAVA_HOME $JAVA_HOME + +ENV ProgramFiles="C:\Program Files" +ENV WindowsPATH="C:\Windows\system32;C:\Windows" + +ARG USER_HOME_DIR="C:/Users/ContainerUser" +ARG MAVEN_VERSION=3.6.2 +ARG SHA=4bb0e0bb1fb74f1b990ba9a6493cc6345873d9188fc7613df16ab0d5bd2017de5a3917af4502792f0bad1fcc95785dcc6660f7add53548e0ec4bfb30ce4b1da7 +ARG BASE_URL=https://apache.osuosl.org/maven/maven-3/${MAVEN_VERSION}/binaries + +RUN Invoke-WebRequest -Uri ${env:BASE_URL}/apache-maven-${env:MAVEN_VERSION}-bin.zip -OutFile ${env:TEMP}/apache-maven.zip ; ` + if((Get-FileHash -Algorithm SHA512 -Path ${env:TEMP}/apache-maven.zip).Hash.ToLower() -ne ${env:SHA}) { exit 1 } ; ` + Expand-Archive -Path ${env:TEMP}/apache-maven.zip -Destination C:/ProgramData ; ` + Move-Item C:/ProgramData/apache-maven-${env:MAVEN_VERSION} C:/ProgramData/Maven ; ` + New-Item -ItemType Directory -Path C:/ProgramData/Maven/Reference | Out-Null ; ` + Remove-Item ${env:TEMP}/apache-maven.zip + +ENV MAVEN_HOME C:/ProgramData/Maven +ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2" + +COPY mvn-entrypoint.ps1 C:/ProgramData/Maven/mvn-entrypoint.ps1 +COPY settings-docker.xml C:/ProgramData/Maven/Reference/settings-docker.xml + +USER ContainerUser + +ENV PATH="${WindowsPATH};${ProgramFiles}\PowerShell;${JAVA_HOME}\bin;${MAVEN_HOME}\bin" + +ENTRYPOINT ["pwsh", "-f", "C:/ProgramData/Maven/mvn-entrypoint.ps1"] +CMD ["mvn"] diff --git a/windows/Dockerfile.windows-jdk-12 b/windows/Dockerfile.windows-jdk-12 index 8f16aea2..002dc050 100644 --- a/windows/Dockerfile.windows-jdk-12 +++ b/windows/Dockerfile.windows-jdk-12 @@ -4,9 +4,9 @@ FROM openjdk:12-jdk-windowsservercore-$WINDOWS_DOCKER_TAG SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] -ARG MAVEN_VERSION=3.6.1 -ARG USER_HOME_DIR="C:/Users/ContainerAdministrator" -ARG SHA=51169366d7269ed316bad013d9cbfebe3a4ef1fda393ac4982d6dbc9af2d5cc359ee12838b8041cb998f236486e988b9c05372f4fdb29a96c1139f63c991e90e +ARG USER_HOME_DIR="C:/Users/ContainerUser" +ARG MAVEN_VERSION=3.6.2 +ARG SHA=4bb0e0bb1fb74f1b990ba9a6493cc6345873d9188fc7613df16ab0d5bd2017de5a3917af4502792f0bad1fcc95785dcc6660f7add53548e0ec4bfb30ce4b1da7 ARG BASE_URL=https://apache.osuosl.org/maven/maven-3/${MAVEN_VERSION}/binaries RUN Invoke-WebRequest -Uri ${env:BASE_URL}/apache-maven-${env:MAVEN_VERSION}-bin.zip -OutFile ${env:TEMP}/apache-maven.zip ; ` @@ -14,18 +14,18 @@ RUN Invoke-WebRequest -Uri ${env:BASE_URL}/apache-maven-${env:MAVEN_VERSION}-bin Expand-Archive -Path ${env:TEMP}/apache-maven.zip -Destination C:/ProgramData ; ` Move-Item C:/ProgramData/apache-maven-${env:MAVEN_VERSION} C:/ProgramData/Maven ; ` New-Item -ItemType Directory -Path C:/ProgramData/Maven/Reference | Out-Null ; ` - Remove-Item ${env:TEMP}/apache-maven.zip + Remove-Item ${env:TEMP}/apache-maven.zip ENV MAVEN_HOME C:/ProgramData/Maven ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2" -# Workaround https://github.com/corretto/corretto-8-docker/pull/32 -#ENV JAVA_HOME=/usr/lib/jvm/java-1.8.0-amazon-corretto - COPY mvn-entrypoint.ps1 C:/ProgramData/Maven/mvn-entrypoint.ps1 COPY settings-docker.xml C:/ProgramData/Maven/Reference/settings-docker.xml RUN setx /M PATH $('{0};{1}' -f $env:PATH,'C:\ProgramData\Maven\bin') | Out-Null +USER ContainerUser +ENV JAVA_HOME=${JAVA_HOME} + ENTRYPOINT ["powershell.exe", "-f", "C:/ProgramData/Maven/mvn-entrypoint.ps1"] CMD ["mvn"] diff --git a/windows/Dockerfile.windows-jdk-13 b/windows/Dockerfile.windows-jdk-13 index 9c521321..92047168 100644 --- a/windows/Dockerfile.windows-jdk-13 +++ b/windows/Dockerfile.windows-jdk-13 @@ -4,9 +4,9 @@ FROM openjdk:13-jdk-windowsservercore-$WINDOWS_DOCKER_TAG SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] -ARG MAVEN_VERSION=3.6.1 -ARG USER_HOME_DIR="C:/Users/ContainerAdministrator" -ARG SHA=51169366d7269ed316bad013d9cbfebe3a4ef1fda393ac4982d6dbc9af2d5cc359ee12838b8041cb998f236486e988b9c05372f4fdb29a96c1139f63c991e90e +ARG USER_HOME_DIR="C:/User/ContainerUser" +ARG MAVEN_VERSION=3.6.2 +ARG SHA=4bb0e0bb1fb74f1b990ba9a6493cc6345873d9188fc7613df16ab0d5bd2017de5a3917af4502792f0bad1fcc95785dcc6660f7add53548e0ec4bfb30ce4b1da7 ARG BASE_URL=https://apache.osuosl.org/maven/maven-3/${MAVEN_VERSION}/binaries RUN Invoke-WebRequest -Uri ${env:BASE_URL}/apache-maven-${env:MAVEN_VERSION}-bin.zip -OutFile ${env:TEMP}/apache-maven.zip ; ` @@ -14,18 +14,18 @@ RUN Invoke-WebRequest -Uri ${env:BASE_URL}/apache-maven-${env:MAVEN_VERSION}-bin Expand-Archive -Path ${env:TEMP}/apache-maven.zip -Destination C:/ProgramData ; ` Move-Item C:/ProgramData/apache-maven-${env:MAVEN_VERSION} C:/ProgramData/Maven ; ` New-Item -ItemType Directory -Path C:/ProgramData/Maven/Reference | Out-Null ; ` - Remove-Item ${env:TEMP}/apache-maven.zip + Remove-Item ${env:TEMP}/apache-maven.zip ENV MAVEN_HOME C:/ProgramData/Maven ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2" -# Workaround https://github.com/corretto/corretto-8-docker/pull/32 -#ENV JAVA_HOME=/usr/lib/jvm/java-1.8.0-amazon-corretto - COPY mvn-entrypoint.ps1 C:/ProgramData/Maven/mvn-entrypoint.ps1 COPY settings-docker.xml C:/ProgramData/Maven/Reference/settings-docker.xml RUN setx /M PATH $('{0};{1}' -f $env:PATH,'C:\ProgramData\Maven\bin') | Out-Null +USER ContainerUser +ENV JAVA_HOME=${JAVA_HOME} + ENTRYPOINT ["powershell.exe", "-f", "C:/ProgramData/Maven/mvn-entrypoint.ps1"] CMD ["mvn"] diff --git a/windows/Dockerfile.windows-jdk-14 b/windows/Dockerfile.windows-jdk-14 index 7d49f12d..bebc5769 100644 --- a/windows/Dockerfile.windows-jdk-14 +++ b/windows/Dockerfile.windows-jdk-14 @@ -4,9 +4,9 @@ FROM openjdk:14-jdk-windowsservercore-$WINDOWS_DOCKER_TAG SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] -ARG MAVEN_VERSION=3.6.1 -ARG USER_HOME_DIR="C:/Users/ContainerAdministrator" -ARG SHA=51169366d7269ed316bad013d9cbfebe3a4ef1fda393ac4982d6dbc9af2d5cc359ee12838b8041cb998f236486e988b9c05372f4fdb29a96c1139f63c991e90e +ARG USER_HOME_DIR="C:/Users/ContainerUser" +ARG MAVEN_VERSION=3.6.2 +ARG SHA=4bb0e0bb1fb74f1b990ba9a6493cc6345873d9188fc7613df16ab0d5bd2017de5a3917af4502792f0bad1fcc95785dcc6660f7add53548e0ec4bfb30ce4b1da7 ARG BASE_URL=https://apache.osuosl.org/maven/maven-3/${MAVEN_VERSION}/binaries RUN Invoke-WebRequest -Uri ${env:BASE_URL}/apache-maven-${env:MAVEN_VERSION}-bin.zip -OutFile ${env:TEMP}/apache-maven.zip ; ` @@ -14,18 +14,18 @@ RUN Invoke-WebRequest -Uri ${env:BASE_URL}/apache-maven-${env:MAVEN_VERSION}-bin Expand-Archive -Path ${env:TEMP}/apache-maven.zip -Destination C:/ProgramData ; ` Move-Item C:/ProgramData/apache-maven-${env:MAVEN_VERSION} C:/ProgramData/Maven ; ` New-Item -ItemType Directory -Path C:/ProgramData/Maven/Reference | Out-Null ; ` - Remove-Item ${env:TEMP}/apache-maven.zip + Remove-Item ${env:TEMP}/apache-maven.zip ENV MAVEN_HOME C:/ProgramData/Maven ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2" -# Workaround https://github.com/corretto/corretto-8-docker/pull/32 -#ENV JAVA_HOME=/usr/lib/jvm/java-1.8.0-amazon-corretto - COPY mvn-entrypoint.ps1 C:/ProgramData/Maven/mvn-entrypoint.ps1 COPY settings-docker.xml C:/ProgramData/Maven/Reference/settings-docker.xml RUN setx /M PATH $('{0};{1}' -f $env:PATH,'C:\ProgramData\Maven\bin') | Out-Null +USER ContainerUser +ENV JAVA_HOME=${JAVA_HOME} + ENTRYPOINT ["powershell.exe", "-f", "C:/ProgramData/Maven/mvn-entrypoint.ps1"] CMD ["mvn"] diff --git a/windows/Dockerfile.windows-jdk-8 b/windows/Dockerfile.windows-jdk-8 index 0b2a6395..f5898b70 100644 --- a/windows/Dockerfile.windows-jdk-8 +++ b/windows/Dockerfile.windows-jdk-8 @@ -4,9 +4,9 @@ FROM openjdk:8-jdk-windowsservercore-$WINDOWS_DOCKER_TAG SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] -ARG MAVEN_VERSION=3.6.1 -ARG USER_HOME_DIR="C:/Users/ContainerAdministrator" -ARG SHA=51169366d7269ed316bad013d9cbfebe3a4ef1fda393ac4982d6dbc9af2d5cc359ee12838b8041cb998f236486e988b9c05372f4fdb29a96c1139f63c991e90e +ARG USER_HOME_DIR="C:/Users/ContainerUser" +ARG MAVEN_VERSION=3.6.2 +ARG SHA=4bb0e0bb1fb74f1b990ba9a6493cc6345873d9188fc7613df16ab0d5bd2017de5a3917af4502792f0bad1fcc95785dcc6660f7add53548e0ec4bfb30ce4b1da7 ARG BASE_URL=https://apache.osuosl.org/maven/maven-3/${MAVEN_VERSION}/binaries RUN Invoke-WebRequest -Uri ${env:BASE_URL}/apache-maven-${env:MAVEN_VERSION}-bin.zip -OutFile ${env:TEMP}/apache-maven.zip ; ` @@ -14,7 +14,7 @@ RUN Invoke-WebRequest -Uri ${env:BASE_URL}/apache-maven-${env:MAVEN_VERSION}-bin Expand-Archive -Path ${env:TEMP}/apache-maven.zip -Destination C:/ProgramData ; ` Move-Item C:/ProgramData/apache-maven-${env:MAVEN_VERSION} C:/ProgramData/Maven ; ` New-Item -ItemType Directory -Path C:/ProgramData/Maven/Reference | Out-Null ; ` - Remove-Item ${env:TEMP}/apache-maven.zip + Remove-Item ${env:TEMP}/apache-maven.zip ENV MAVEN_HOME C:/ProgramData/Maven ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2" @@ -24,5 +24,8 @@ COPY settings-docker.xml C:/ProgramData/Maven/Reference/settings-docker.xml RUN setx /M PATH $('{0};{1}' -f $env:PATH,'C:\ProgramData\Maven\bin') | Out-Null +USER ContainerUser +ENV JAVA_HOME=${JAVA_HOME} + ENTRYPOINT ["powershell.exe", "-f", "C:/ProgramData/Maven/mvn-entrypoint.ps1"] CMD ["mvn"] diff --git a/windows/Dockerfile.windows-jdk-8-nanoserver b/windows/Dockerfile.windows-jdk-8-nanoserver new file mode 100644 index 00000000..be77bd31 --- /dev/null +++ b/windows/Dockerfile.windows-jdk-8-nanoserver @@ -0,0 +1,45 @@ +# escape=` +ARG WINDOWS_DOCKER_TAG=1809 +ARG JAVA_VERSION=8u232 +# we use the latest stable if nothing is passed +ARG POWERSHELL_VERSION= + +FROM openjdk:${JAVA_VERSION}-windowsservercore-${WINDOWS_DOCKER_TAG} as openjdk + +FROM mcr.microsoft.com/powershell:${POWERSHELL_VERSION}nanoserver-$WINDOWS_DOCKER_TAG + +SHELL ["pwsh", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] + +USER ContainerAdministrator + +ENV JAVA_HOME=C:\openjdk-8 + +COPY --from=openjdk $JAVA_HOME $JAVA_HOME + +ENV ProgramFiles="C:\Program Files" +ENV WindowsPATH="C:\Windows\system32;C:\Windows" + +ARG USER_HOME_DIR="C:/Users/ContainerUser" +ARG MAVEN_VERSION=3.6.2 +ARG SHA=4bb0e0bb1fb74f1b990ba9a6493cc6345873d9188fc7613df16ab0d5bd2017de5a3917af4502792f0bad1fcc95785dcc6660f7add53548e0ec4bfb30ce4b1da7 +ARG BASE_URL=https://apache.osuosl.org/maven/maven-3/${MAVEN_VERSION}/binaries + +RUN Invoke-WebRequest -Uri ${env:BASE_URL}/apache-maven-${env:MAVEN_VERSION}-bin.zip -OutFile ${env:TEMP}/apache-maven.zip ; ` + if((Get-FileHash -Algorithm SHA512 -Path ${env:TEMP}/apache-maven.zip).Hash.ToLower() -ne ${env:SHA}) { exit 1 } ; ` + Expand-Archive -Path ${env:TEMP}/apache-maven.zip -Destination C:/ProgramData ; ` + Move-Item C:/ProgramData/apache-maven-${env:MAVEN_VERSION} C:/ProgramData/Maven ; ` + New-Item -ItemType Directory -Path C:/ProgramData/Maven/Reference | Out-Null ; ` + Remove-Item ${env:TEMP}/apache-maven.zip + +ENV MAVEN_HOME C:/ProgramData/Maven +ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2" + +COPY mvn-entrypoint.ps1 C:/ProgramData/Maven/mvn-entrypoint.ps1 +COPY settings-docker.xml C:/ProgramData/Maven/Reference/settings-docker.xml + +USER ContainerUser + +ENV PATH="${WindowsPATH};${ProgramFiles}\PowerShell;${JAVA_HOME}\bin;${MAVEN_HOME}\bin" + +ENTRYPOINT ["pwsh", "-f", "C:/ProgramData/Maven/mvn-entrypoint.ps1"] +CMD ["mvn"] From d3b32bca073b235da2e02302b29776cc0ad04686 Mon Sep 17 00:00:00 2001 From: Alex Earl Date: Thu, 24 Oct 2019 06:44:45 -0700 Subject: [PATCH 21/38] Only build on windows-2019 --- .github/workflows/main.yml | 10 +--------- windows/Dockerfile.windows-jdk-13 | 2 +- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 04c6a348..71063268 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -5,11 +5,7 @@ on: [push, pull_request] jobs: build: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [windows-2019, windows-2016] - + runs-on: windows-2019 steps: - uses: actions/checkout@v1 - name: Build Images @@ -23,10 +19,6 @@ jobs: $windowsDockerTag = ('ltsc{0}' -f '${{ matrix.os }}'.Replace('windows-', '')) if($dockerfile.Name.Contains('nanoserver')) { - # No nanoserver for 2016 - if('${{ matrix.os }}' -eq 'windows-2016') { - continue - } $windowsType = 'windows-nanoserver' $windowsDockerTag = '1809' } diff --git a/windows/Dockerfile.windows-jdk-13 b/windows/Dockerfile.windows-jdk-13 index 92047168..d004d13c 100644 --- a/windows/Dockerfile.windows-jdk-13 +++ b/windows/Dockerfile.windows-jdk-13 @@ -4,7 +4,7 @@ FROM openjdk:13-jdk-windowsservercore-$WINDOWS_DOCKER_TAG SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] -ARG USER_HOME_DIR="C:/User/ContainerUser" +ARG USER_HOME_DIR="C:/Users/ContainerUser" ARG MAVEN_VERSION=3.6.2 ARG SHA=4bb0e0bb1fb74f1b990ba9a6493cc6345873d9188fc7613df16ab0d5bd2017de5a3917af4502792f0bad1fcc95785dcc6660f7add53548e0ec4bfb30ce4b1da7 ARG BASE_URL=https://apache.osuosl.org/maven/maven-3/${MAVEN_VERSION}/binaries From e9cf9a4e938d884f154fb252410776cce563d569 Mon Sep 17 00:00:00 2001 From: Alex Earl Date: Thu, 24 Oct 2019 06:47:16 -0700 Subject: [PATCH 22/38] Install Pester --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 71063268..8bac25a8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,6 +10,7 @@ jobs: - uses: actions/checkout@v1 - name: Build Images run: | + Find-Module -Name Pester | Install-Module $tags = @('3.6.2', '3.6', '3') Get-ChildItem -Path windows\* -File -Include "Dockerfile.windows-*" | ForEach-Object { Push-Location From 4324f84c9d37043f1489dd40920e0f3a9c72d89c Mon Sep 17 00:00:00 2001 From: Alex Earl Date: Thu, 24 Oct 2019 06:49:35 -0700 Subject: [PATCH 23/38] Install-module only --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8bac25a8..e7c77343 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,7 +10,7 @@ jobs: - uses: actions/checkout@v1 - name: Build Images run: | - Find-Module -Name Pester | Install-Module + Install-Module -Name Pester -Force -Version 4.9.0 $tags = @('3.6.2', '3.6', '3') Get-ChildItem -Path windows\* -File -Include "Dockerfile.windows-*" | ForEach-Object { Push-Location From facd6b8bd8c54a6a3a89e209230af6f80c143f3e Mon Sep 17 00:00:00 2001 From: Alex Earl Date: Thu, 24 Oct 2019 06:54:39 -0700 Subject: [PATCH 24/38] Fix parameter --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e7c77343..2b6c1a62 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,7 +10,7 @@ jobs: - uses: actions/checkout@v1 - name: Build Images run: | - Install-Module -Name Pester -Force -Version 4.9.0 + Install-Module -Name Pester -Force -RequiredVersion 4.9.0 $tags = @('3.6.2', '3.6', '3') Get-ChildItem -Path windows\* -File -Include "Dockerfile.windows-*" | ForEach-Object { Push-Location From db697b58faadfcebe72da96f459fc456e071a7a7 Mon Sep 17 00:00:00 2001 From: Alex Earl Date: Thu, 24 Oct 2019 07:02:23 -0700 Subject: [PATCH 25/38] Don't use matrix.os --- .github/workflows/main.yml | 4 ++-- tests/test_helpers.psm1 | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2b6c1a62..fdb6e170 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,11 +17,11 @@ jobs: $dockerfile = $_ $windowsType = 'windows-servercore' - $windowsDockerTag = ('ltsc{0}' -f '${{ matrix.os }}'.Replace('windows-', '')) + $windowsDockerTag = 'ltsc2019' if($dockerfile.Name.Contains('nanoserver')) { $windowsType = 'windows-nanoserver' - $windowsDockerTag = '1809' + $windowsDockerTag = $('{0}' -f (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' -Name ReleaseID | Select-Object ReleaseID).ReleaseID)) } # run tests diff --git a/tests/test_helpers.psm1 b/tests/test_helpers.psm1 index 4fb13dbf..469dd59a 100644 --- a/tests/test_helpers.psm1 +++ b/tests/test_helpers.psm1 @@ -46,7 +46,12 @@ function Build-Docker($ImageType) { if(![String]::IsNullOrWhitespace($ImageType) -and !$ImageType.StartsWith('-')) { $ImageType = "-$ImageType" } - return (Run-Program 'docker.exe' "build -f Dockerfile.windows$ImageType $args .") + + $windowsDockerTag='' + if(![String]::IsNullOrWhiteSpace(($env:WINDOWS_DOCKER_TAG)) { + $windowsDockerTag = "--build-arg WINDOWS_DOCKER_TAG=$env:WINDOWS_DOCKER_TAG" + } + return (Run-Program 'docker.exe' "build -f Dockerfile.windows$ImageType $windowsDockerTag $args .") } function Retry-Command { From be83b14b745655198f93f26a511226bc6168d817 Mon Sep 17 00:00:00 2001 From: Alex Earl Date: Thu, 24 Oct 2019 07:14:23 -0700 Subject: [PATCH 26/38] Fix paren --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fdb6e170..337c818b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -21,7 +21,7 @@ jobs: if($dockerfile.Name.Contains('nanoserver')) { $windowsType = 'windows-nanoserver' - $windowsDockerTag = $('{0}' -f (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' -Name ReleaseID | Select-Object ReleaseID).ReleaseID)) + $windowsDockerTag = $('{0}' -f (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' -Name ReleaseID | Select-Object ReleaseID).ReleaseID) } # run tests @@ -45,4 +45,4 @@ jobs: } Pop-Location } - shell: pwsh \ No newline at end of file + shell: pwsh From b5305223b15547a5d4d24a46b82fa9bd624d0832 Mon Sep 17 00:00:00 2001 From: Alex Earl Date: Thu, 24 Oct 2019 07:23:28 -0700 Subject: [PATCH 27/38] Fix other paren --- tests/test_helpers.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_helpers.psm1 b/tests/test_helpers.psm1 index 469dd59a..39db6478 100644 --- a/tests/test_helpers.psm1 +++ b/tests/test_helpers.psm1 @@ -48,7 +48,7 @@ function Build-Docker($ImageType) { } $windowsDockerTag='' - if(![String]::IsNullOrWhiteSpace(($env:WINDOWS_DOCKER_TAG)) { + if(![String]::IsNullOrWhiteSpace($env:WINDOWS_DOCKER_TAG)) { $windowsDockerTag = "--build-arg WINDOWS_DOCKER_TAG=$env:WINDOWS_DOCKER_TAG" } return (Run-Program 'docker.exe' "build -f Dockerfile.windows$ImageType $windowsDockerTag $args .") From 156ed006fd79c13ebef44bdcc8854ed04307fd99 Mon Sep 17 00:00:00 2001 From: Alex Earl Date: Thu, 24 Oct 2019 07:30:00 -0700 Subject: [PATCH 28/38] Add push/pop location --- .github/workflows/main.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 337c818b..c873a158 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -34,6 +34,7 @@ jobs: Pop-Location $tags | ForEach-Object { + Push-Location windows $tag = ('maven:{0}-{1}-{2}-{3}' -f $_,$dockerfile.Name.Replace('Dockerfile.windows-', ''),$windowsType,$windowsDockerTag) docker build -f $dockerfile --tag $tag --build-arg WINDOWS_DOCKER_TAG=${windowsDockerTag} . @@ -42,6 +43,7 @@ jobs: # '${{ secrets.DOCKER_PASSWORD }}' | docker login --username ${{ secrets.DOCKER_USERNAME }} --password-stdin # & docker push $tag } + Pop-Location } Pop-Location } From dc69b46afe8c828fed66d16de78c1ff6df5cdd9e Mon Sep 17 00:00:00 2001 From: Alex Earl Date: Thu, 24 Oct 2019 08:05:18 -0700 Subject: [PATCH 29/38] Fix tags and JAVA_HOME --- .github/workflows/main.yml | 8 ++++++-- windows/Dockerfile.windows-amazoncorretto-8 | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fdb6e170..abaf6b9b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,11 +16,15 @@ jobs: Push-Location $dockerfile = $_ - $windowsType = 'windows-servercore' + $windowsType = 'windowsservercore' $windowsDockerTag = 'ltsc2019' if($dockerfile.Name.Contains('nanoserver')) { - $windowsType = 'windows-nanoserver' + $windowsType = 'windowsnanoserver' + $windowsDockerTag = $('{0}' -f (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' -Name ReleaseID | Select-Object ReleaseID).ReleaseID)) + } + + if($dockerfile.Name.Contains('jdk-')) { $windowsDockerTag = $('{0}' -f (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' -Name ReleaseID | Select-Object ReleaseID).ReleaseID)) } diff --git a/windows/Dockerfile.windows-amazoncorretto-8 b/windows/Dockerfile.windows-amazoncorretto-8 index 4caf5f47..fca1808b 100644 --- a/windows/Dockerfile.windows-amazoncorretto-8 +++ b/windows/Dockerfile.windows-amazoncorretto-8 @@ -13,7 +13,7 @@ RUN Invoke-WebRequest -Uri $('{0}{1}' -f $env:uri,$env:zip) -OutFile C:/$env:zip Expand-Archive -Path C:/$env:zip -Destination C:/ProgramData ; ` Remove-Item C:/${env:zip} -ENV JAVA_HOME=C:/ProgramData/jdk1.8.0_222 +ENV JAVA_HOME=C:/ProgramData/jdk1.8.0_232 ARG USER_HOME_DIR="C:/Users/ContainerUser" ARG MAVEN_VERSION=3.6.2 From 12473caeec01cda45c0193d99a7859c9deefe379 Mon Sep 17 00:00:00 2001 From: Alex Earl Date: Thu, 24 Oct 2019 08:16:07 -0700 Subject: [PATCH 30/38] Fix test check --- tests/maven.Tests.ps1 | 2 +- tests/test_helpers.psm1 | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/maven.Tests.ps1 b/tests/maven.Tests.ps1 index ab88a0b6..49a25b7a 100644 --- a/tests/maven.Tests.ps1 +++ b/tests/maven.Tests.ps1 @@ -16,7 +16,7 @@ Describe "$SUT_TAG build image" { It 'builds image' { $exitCode, $stdout, $stderr = Build-Docker -ImageType $SUT_TAG --pull -t $SUT_IMAGE - $lastExitCode | Should -Be 0 + $exitCode | Should -Be 0 } AfterEach { diff --git a/tests/test_helpers.psm1 b/tests/test_helpers.psm1 index 39db6478..dfac0e7a 100644 --- a/tests/test_helpers.psm1 +++ b/tests/test_helpers.psm1 @@ -38,7 +38,6 @@ function Run-Program($Cmd, $Params) { if($proc.ExitCode -ne 0) { Write-Host "`n`nstdout:`n$stdout`n`nstderr:`n$stderr`n`n" } - return $proc.ExitCode, $stdout, $stderr } From 9c0a865a70d8e44b739c15668da878ed1630d696 Mon Sep 17 00:00:00 2001 From: Alex Earl Date: Thu, 24 Oct 2019 08:23:16 -0700 Subject: [PATCH 31/38] Remove '-it' for CI --- tests/maven.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/maven.Tests.ps1 b/tests/maven.Tests.ps1 index 49a25b7a..2618612f 100644 --- a/tests/maven.Tests.ps1 +++ b/tests/maven.Tests.ps1 @@ -74,7 +74,7 @@ Describe "$SUT_TAG run Maven" { Describe "$SUT_TAG generate sample project" { It 'generates sample project' { - $exitCode, $stdout, $stderr = Run-Program -Cmd "docker.exe" -Params "run --rm -it $SUT_TEST_IMAGE mvn -B archetype:generate -DgroupId=pester-testing -DartifactId=pester-test-project -DarchetypeArtifactId=maven-archetype-quickstart" + $exitCode, $stdout, $stderr = Run-Program -Cmd "docker.exe" -Params "run --rm $SUT_TEST_IMAGE mvn -B archetype:generate -DgroupId=pester-testing -DartifactId=pester-test-project -DarchetypeArtifactId=maven-archetype-quickstart" $exitCode | Should -Be 0 } } From 2c43c9ae301d300e4d41da59c8d04582d81203ec Mon Sep 17 00:00:00 2001 From: Alex Earl Date: Thu, 24 Oct 2019 08:44:32 -0700 Subject: [PATCH 32/38] Switch up to slideomix repo for now --- .github/workflows/main.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c33d0668..9015e39b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -39,13 +39,12 @@ jobs: $tags | ForEach-Object { Push-Location windows - $tag = ('maven:{0}-{1}-{2}-{3}' -f $_,$dockerfile.Name.Replace('Dockerfile.windows-', ''),$windowsType,$windowsDockerTag) + $tag = ('slideomix/maven:{0}-{1}-{2}-{3}' -f $_,$dockerfile.Name.Replace('Dockerfile.windows-', ''),$windowsType,$windowsDockerTag) docker build -f $dockerfile --tag $tag --build-arg WINDOWS_DOCKER_TAG=${windowsDockerTag} . if('${{ github.event_name }}' -eq 'push') { - Write-Host 'YOU ARE IN A PUSH OPERATION' - # '${{ secrets.DOCKER_PASSWORD }}' | docker login --username ${{ secrets.DOCKER_USERNAME }} --password-stdin - # & docker push $tag + '${{ secrets.DOCKER_PASSWORD }}' | docker login --username ${{ secrets.DOCKER_USERNAME }} --password-stdin + & docker push $tag } Pop-Location } From 9a959414720ec9c9a3d8520603df430f5ae15e4d Mon Sep 17 00:00:00 2001 From: Alex Earl Date: Thu, 24 Oct 2019 08:57:25 -0700 Subject: [PATCH 33/38] ErrorAction --- .github/workflows/main.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9015e39b..381ff205 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -43,7 +43,9 @@ jobs: docker build -f $dockerfile --tag $tag --build-arg WINDOWS_DOCKER_TAG=${windowsDockerTag} . if('${{ github.event_name }}' -eq 'push') { - '${{ secrets.DOCKER_PASSWORD }}' | docker login --username ${{ secrets.DOCKER_USERNAME }} --password-stdin + $ErrorActionPreference = 'SilentlyContinue' + '${{ secrets.DOCKER_PASSWORD }}' | & docker login --username slideomix --password-stdin + $ErrorActionPreference = 'Stop' & docker push $tag } Pop-Location From 02c975e681cc132dc15a434d475d09d800611eac Mon Sep 17 00:00:00 2001 From: Alex Earl Date: Thu, 24 Oct 2019 09:39:27 -0700 Subject: [PATCH 34/38] One last mod before PR --- .github/workflows/main.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 381ff205..96ad4692 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -18,14 +18,15 @@ jobs: $windowsType = 'windowsservercore' $windowsDockerTag = 'ltsc2019' + $windowsReleaseId = $(Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' -Name ReleaseID | Select-Object ReleaseID).ReleaseID) if($dockerfile.Name.Contains('nanoserver')) { $windowsType = 'windowsnanoserver' - $windowsDockerTag = $('{0}' -f (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' -Name ReleaseID | Select-Object ReleaseID).ReleaseID) + $windowsDockerTag = $('{0}' -f $windowsReleaseId) } if($dockerfile.Name.Contains('jdk-')) { - $windowsDockerTag = $('{0}' -f (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' -Name ReleaseID | Select-Object ReleaseID).ReleaseID) + $windowsDockerTag = $('{0}' -f $windowsReleaseId) } # run tests @@ -43,9 +44,11 @@ jobs: docker build -f $dockerfile --tag $tag --build-arg WINDOWS_DOCKER_TAG=${windowsDockerTag} . if('${{ github.event_name }}' -eq 'push') { + # docker login with cause a warning which will cause this to fail unless we SilentlyContinue $ErrorActionPreference = 'SilentlyContinue' - '${{ secrets.DOCKER_PASSWORD }}' | & docker login --username slideomix --password-stdin + '${{ secrets.DOCKER_PASSWORD }}' | & docker login --username ${{ secrets.DOCKER_USERNAME }} --password-stdin $ErrorActionPreference = 'Stop' + Write-Host "Pushing $tag" & docker push $tag } Pop-Location From 7d2f6471e495506b2cb38a4109d2230d09262fa6 Mon Sep 17 00:00:00 2001 From: Alex Earl Date: Thu, 24 Oct 2019 09:40:13 -0700 Subject: [PATCH 35/38] Simplify --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 96ad4692..b20c0935 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -22,11 +22,11 @@ jobs: if($dockerfile.Name.Contains('nanoserver')) { $windowsType = 'windowsnanoserver' - $windowsDockerTag = $('{0}' -f $windowsReleaseId) + $windowsDockerTag = $windowsReleaseId } if($dockerfile.Name.Contains('jdk-')) { - $windowsDockerTag = $('{0}' -f $windowsReleaseId) + $windowsDockerTag = $windowsReleaseId } # run tests From a041da50ab653193ac381e8cde6f54a19ea11311 Mon Sep 17 00:00:00 2001 From: Alex Earl Date: Thu, 24 Oct 2019 09:42:29 -0700 Subject: [PATCH 36/38] Fix rhs --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b20c0935..feea9d09 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -18,7 +18,7 @@ jobs: $windowsType = 'windowsservercore' $windowsDockerTag = 'ltsc2019' - $windowsReleaseId = $(Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' -Name ReleaseID | Select-Object ReleaseID).ReleaseID) + $windowsReleaseId = (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' -Name ReleaseID | Select-Object ReleaseID).ReleaseID if($dockerfile.Name.Contains('nanoserver')) { $windowsType = 'windowsnanoserver' From 1c4e0b4a50d77926cbedcc53b78f4358c99ec913 Mon Sep 17 00:00:00 2001 From: Alex Earl Date: Thu, 24 Oct 2019 10:11:14 -0700 Subject: [PATCH 37/38] Switch to official repo --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index feea9d09..deae6f27 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -40,7 +40,7 @@ jobs: $tags | ForEach-Object { Push-Location windows - $tag = ('slideomix/maven:{0}-{1}-{2}-{3}' -f $_,$dockerfile.Name.Replace('Dockerfile.windows-', ''),$windowsType,$windowsDockerTag) + $tag = ('maven:{0}-{1}-{2}-{3}' -f $_,$dockerfile.Name.Replace('Dockerfile.windows-', ''),$windowsType,$windowsDockerTag) docker build -f $dockerfile --tag $tag --build-arg WINDOWS_DOCKER_TAG=${windowsDockerTag} . if('${{ github.event_name }}' -eq 'push') { From 5483ceda3490f941e562347b34ec96972b8a8caf Mon Sep 17 00:00:00 2001 From: Carlos Sanchez Date: Sat, 2 Nov 2019 00:50:57 +0100 Subject: [PATCH 38/38] Remove jdk 12 no longer available --- windows/Dockerfile.windows-jdk-12 | 31 ------------------------------- 1 file changed, 31 deletions(-) delete mode 100644 windows/Dockerfile.windows-jdk-12 diff --git a/windows/Dockerfile.windows-jdk-12 b/windows/Dockerfile.windows-jdk-12 deleted file mode 100644 index 002dc050..00000000 --- a/windows/Dockerfile.windows-jdk-12 +++ /dev/null @@ -1,31 +0,0 @@ -# escape=` -ARG WINDOWS_DOCKER_TAG=1809 -FROM openjdk:12-jdk-windowsservercore-$WINDOWS_DOCKER_TAG - -SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] - -ARG USER_HOME_DIR="C:/Users/ContainerUser" -ARG MAVEN_VERSION=3.6.2 -ARG SHA=4bb0e0bb1fb74f1b990ba9a6493cc6345873d9188fc7613df16ab0d5bd2017de5a3917af4502792f0bad1fcc95785dcc6660f7add53548e0ec4bfb30ce4b1da7 -ARG BASE_URL=https://apache.osuosl.org/maven/maven-3/${MAVEN_VERSION}/binaries - -RUN Invoke-WebRequest -Uri ${env:BASE_URL}/apache-maven-${env:MAVEN_VERSION}-bin.zip -OutFile ${env:TEMP}/apache-maven.zip ; ` - if((Get-FileHash -Algorithm SHA512 -Path ${env:TEMP}/apache-maven.zip).Hash.ToLower() -ne ${env:SHA}) { exit 1 } ; ` - Expand-Archive -Path ${env:TEMP}/apache-maven.zip -Destination C:/ProgramData ; ` - Move-Item C:/ProgramData/apache-maven-${env:MAVEN_VERSION} C:/ProgramData/Maven ; ` - New-Item -ItemType Directory -Path C:/ProgramData/Maven/Reference | Out-Null ; ` - Remove-Item ${env:TEMP}/apache-maven.zip - -ENV MAVEN_HOME C:/ProgramData/Maven -ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2" - -COPY mvn-entrypoint.ps1 C:/ProgramData/Maven/mvn-entrypoint.ps1 -COPY settings-docker.xml C:/ProgramData/Maven/Reference/settings-docker.xml - -RUN setx /M PATH $('{0};{1}' -f $env:PATH,'C:\ProgramData\Maven\bin') | Out-Null - -USER ContainerUser -ENV JAVA_HOME=${JAVA_HOME} - -ENTRYPOINT ["powershell.exe", "-f", "C:/ProgramData/Maven/mvn-entrypoint.ps1"] -CMD ["mvn"]