From 5718313edebd70fa2ec4db35424ce656575be348 Mon Sep 17 00:00:00 2001 From: Michael Simons Date: Tue, 27 Jun 2017 18:50:46 -0500 Subject: [PATCH] Adding 2.0.0-preview2 Dockerfiles (#260) * Adding 2.0.0-preview2 Dockerfiles * Add stretch Dockerfiles --- 2.0/runtime-deps/stretch/Dockerfile | 19 ++++++++ 2.0/runtime/jessie/Dockerfile | 8 ++-- 2.0/runtime/nanoserver/Dockerfile | 10 ++++- 2.0/runtime/stretch/Dockerfile | 18 ++++++++ 2.0/sdk/jessie/Dockerfile | 6 ++- 2.0/sdk/nanoserver/Dockerfile | 10 ++++- 2.0/sdk/stretch/Dockerfile | 38 ++++++++++++++++ LICENSE | 3 +- README.md | 19 ++++---- build-and-test.ps1 | 62 +++++++++++++------------- manifest.json | 62 ++++++++++++++++++++------ test/Dockerfile.test | 2 +- test/run-test.ps1 | 67 +++++++++++++++++------------ 13 files changed, 230 insertions(+), 94 deletions(-) create mode 100644 2.0/runtime-deps/stretch/Dockerfile create mode 100644 2.0/runtime/stretch/Dockerfile create mode 100644 2.0/sdk/stretch/Dockerfile diff --git a/2.0/runtime-deps/stretch/Dockerfile b/2.0/runtime-deps/stretch/Dockerfile new file mode 100644 index 0000000000..12615b5bbb --- /dev/null +++ b/2.0/runtime-deps/stretch/Dockerfile @@ -0,0 +1,19 @@ +FROM debian:stretch + +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + ca-certificates \ + \ +# .NET Core dependencies + libc6 \ + libcurl3 \ + libgcc1 \ + libgssapi-krb5-2 \ + libicu57 \ + liblttng-ust0 \ + libssl1.0.2 \ + libstdc++6 \ + libunwind8 \ + libuuid1 \ + zlib1g \ + && rm -rf /var/lib/apt/lists/* diff --git a/2.0/runtime/jessie/Dockerfile b/2.0/runtime/jessie/Dockerfile index 00caadd39f..945b6a8d5a 100644 --- a/2.0/runtime/jessie/Dockerfile +++ b/2.0/runtime/jessie/Dockerfile @@ -1,4 +1,4 @@ -FROM microsoft/dotnet:2.0-runtime-deps +FROM microsoft/dotnet:2.0-runtime-deps-jessie RUN apt-get update \ && apt-get install -y --no-install-recommends \ @@ -6,10 +6,12 @@ RUN apt-get update \ && rm -rf /var/lib/apt/lists/* # Install .NET Core -ENV DOTNET_VERSION 2.0.0-preview1-002111-00 -ENV DOTNET_DOWNLOAD_URL https://dotnetcli.blob.core.windows.net/dotnet/release/2.0.0/Binaries/$DOTNET_VERSION/dotnet-linux-x64.$DOTNET_VERSION-portable.tar.gz +ENV DOTNET_VERSION 2.0.0-preview2-25407-01 +ENV DOTNET_DOWNLOAD_URL https://dotnetcli.blob.core.windows.net/dotnet/Runtime/$DOTNET_VERSION/dotnet-runtime-$DOTNET_VERSION-linux-x64.tar.gz +ENV DOTNET_DOWNLOAD_SHA 72AA9ABAE8BC818EEB742AFFB943D6AF33B009F84696E6DE7C5316B8975FCC9B4303CB0B80652727BB1FFEE1A025E0C7A43CFE1771D11FE6DEE2D36B002A7EDC RUN curl -SL $DOTNET_DOWNLOAD_URL --output dotnet.tar.gz \ + && echo "$DOTNET_DOWNLOAD_SHA dotnet.tar.gz" | sha512sum -c - \ && mkdir -p /usr/share/dotnet \ && tar -zxf dotnet.tar.gz -C /usr/share/dotnet \ && rm dotnet.tar.gz \ diff --git a/2.0/runtime/nanoserver/Dockerfile b/2.0/runtime/nanoserver/Dockerfile index b09b040d90..4d55071700 100644 --- a/2.0/runtime/nanoserver/Dockerfile +++ b/2.0/runtime/nanoserver/Dockerfile @@ -3,10 +3,16 @@ FROM microsoft/nanoserver:10.0.14393.1358 SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] # Install .NET Core -ENV DOTNET_VERSION 2.0.0-preview1-002111-00 -ENV DOTNET_DOWNLOAD_URL https://dotnetcli.blob.core.windows.net/dotnet/release/2.0.0/Binaries/$DOTNET_VERSION/dotnet-win-x64.$DOTNET_VERSION-portable.zip +ENV DOTNET_VERSION 2.0.0-preview2-25407-01 +ENV DOTNET_DOWNLOAD_URL https://dotnetcli.blob.core.windows.net/dotnet/Runtime/$DOTNET_VERSION/dotnet-runtime-$DOTNET_VERSION-win-x64.zip +ENV DOTNET_DOWNLOAD_SHA 234F702025C292C6A432F2F93439294EE164F294485343027B952CEA2085B871064A92E6AED335DA7E05FCEA99AC303E81B750021D7782ACECA867F6D789F3DC RUN Invoke-WebRequest $Env:DOTNET_DOWNLOAD_URL -OutFile dotnet.zip; \ + if ((Get-FileHash dotnet.zip -Algorithm sha512).Hash -ne $Env:DOTNET_DOWNLOAD_SHA) { \ + Write-Host 'CHECKSUM VERIFICATION FAILED!'; \ + exit 1; \ + }; \ + \ Expand-Archive dotnet.zip -DestinationPath $Env:ProgramFiles\dotnet; \ Remove-Item -Force dotnet.zip diff --git a/2.0/runtime/stretch/Dockerfile b/2.0/runtime/stretch/Dockerfile new file mode 100644 index 0000000000..14419979c3 --- /dev/null +++ b/2.0/runtime/stretch/Dockerfile @@ -0,0 +1,18 @@ +FROM microsoft/dotnet:2.0-runtime-deps + +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + curl \ + && rm -rf /var/lib/apt/lists/* + +# Install .NET Core +ENV DOTNET_VERSION 2.0.0-preview2-25407-01 +ENV DOTNET_DOWNLOAD_URL https://dotnetcli.blob.core.windows.net/dotnet/Runtime/$DOTNET_VERSION/dotnet-runtime-$DOTNET_VERSION-linux-x64.tar.gz +ENV DOTNET_DOWNLOAD_SHA 72AA9ABAE8BC818EEB742AFFB943D6AF33B009F84696E6DE7C5316B8975FCC9B4303CB0B80652727BB1FFEE1A025E0C7A43CFE1771D11FE6DEE2D36B002A7EDC + +RUN curl -SL $DOTNET_DOWNLOAD_URL --output dotnet.tar.gz \ + && echo "$DOTNET_DOWNLOAD_SHA dotnet.tar.gz" | sha512sum -c - \ + && mkdir -p /usr/share/dotnet \ + && tar -zxf dotnet.tar.gz -C /usr/share/dotnet \ + && rm dotnet.tar.gz \ + && ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet diff --git a/2.0/sdk/jessie/Dockerfile b/2.0/sdk/jessie/Dockerfile index f497855bda..f9730c8741 100644 --- a/2.0/sdk/jessie/Dockerfile +++ b/2.0/sdk/jessie/Dockerfile @@ -17,10 +17,12 @@ RUN apt-get update \ && rm -rf /var/lib/apt/lists/* # Install .NET Core SDK -ENV DOTNET_SDK_VERSION 2.0.0-preview1-005977 -ENV DOTNET_SDK_DOWNLOAD_URL https://dotnetcli.blob.core.windows.net/dotnet/Sdk/$DOTNET_SDK_VERSION/dotnet-dev-linux-x64.$DOTNET_SDK_VERSION.tar.gz +ENV DOTNET_SDK_VERSION 2.0.0-preview2-006497 +ENV DOTNET_SDK_DOWNLOAD_URL https://dotnetcli.blob.core.windows.net/dotnet/Sdk/$DOTNET_SDK_VERSION/dotnet-sdk-$DOTNET_SDK_VERSION-linux-x64.tar.gz +ENV DOTNET_SDK_DOWNLOAD_SHA 0664FE726EB07650D9C036B0E5E6D33AA8B10DB89DADA4A5E85FB5757FD1FAE1570AF0D526484014976761C829B1E55A70EF9966EECE877A56C2C426090896EB RUN curl -SL $DOTNET_SDK_DOWNLOAD_URL --output dotnet.tar.gz \ + && echo "$DOTNET_SDK_DOWNLOAD_SHA dotnet.tar.gz" | sha512sum -c - \ && mkdir -p /usr/share/dotnet \ && tar -zxf dotnet.tar.gz -C /usr/share/dotnet \ && rm dotnet.tar.gz \ diff --git a/2.0/sdk/nanoserver/Dockerfile b/2.0/sdk/nanoserver/Dockerfile index ef737a8712..d847b50801 100644 --- a/2.0/sdk/nanoserver/Dockerfile +++ b/2.0/sdk/nanoserver/Dockerfile @@ -3,10 +3,16 @@ FROM microsoft/nanoserver:10.0.14393.1358 SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] # Install .NET Core SDK -ENV DOTNET_SDK_VERSION 2.0.0-preview1-005977 -ENV DOTNET_SDK_DOWNLOAD_URL https://dotnetcli.blob.core.windows.net/dotnet/Sdk/$DOTNET_SDK_VERSION/dotnet-dev-win-x64.$DOTNET_SDK_VERSION.zip +ENV DOTNET_SDK_VERSION 2.0.0-preview2-006497 +ENV DOTNET_SDK_DOWNLOAD_URL https://dotnetcli.blob.core.windows.net/dotnet/Sdk/$DOTNET_SDK_VERSION/dotnet-sdk-$DOTNET_SDK_VERSION-win-x64.zip +ENV DOTNET_SDK_DOWNLOAD_SHA 176F0E743BAEA13359F744C6BA443C7D64397800E71B8119185FAA68252CB1EECFF964D1E5E2D44408EEDE94A9EC6D8AC160117B210388FC750CD04CBE786C07 RUN Invoke-WebRequest $Env:DOTNET_SDK_DOWNLOAD_URL -OutFile dotnet.zip; \ + if ((Get-FileHash dotnet.zip -Algorithm sha512).Hash -ne $Env:DOTNET_SDK_DOWNLOAD_SHA) { \ + Write-Host 'CHECKSUM VERIFICATION FAILED!'; \ + exit 1; \ + }; \ + \ Expand-Archive dotnet.zip -DestinationPath $Env:ProgramFiles\dotnet; \ Remove-Item -Force dotnet.zip diff --git a/2.0/sdk/stretch/Dockerfile b/2.0/sdk/stretch/Dockerfile new file mode 100644 index 0000000000..544048fef2 --- /dev/null +++ b/2.0/sdk/stretch/Dockerfile @@ -0,0 +1,38 @@ +FROM buildpack-deps:stretch-scm + +# Install .NET CLI dependencies +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + libc6 \ + libcurl3 \ + libgcc1 \ + libgssapi-krb5-2 \ + libicu57 \ + liblttng-ust0 \ + libssl1.0.2 \ + libstdc++6 \ + libunwind8 \ + libuuid1 \ + zlib1g \ + && rm -rf /var/lib/apt/lists/* + +# Install .NET Core SDK +ENV DOTNET_SDK_VERSION 2.0.0-preview2-006497 +ENV DOTNET_SDK_DOWNLOAD_URL https://dotnetcli.blob.core.windows.net/dotnet/Sdk/$DOTNET_SDK_VERSION/dotnet-sdk-$DOTNET_SDK_VERSION-linux-x64.tar.gz +ENV DOTNET_SDK_DOWNLOAD_SHA 0664FE726EB07650D9C036B0E5E6D33AA8B10DB89DADA4A5E85FB5757FD1FAE1570AF0D526484014976761C829B1E55A70EF9966EECE877A56C2C426090896EB + +RUN curl -SL $DOTNET_SDK_DOWNLOAD_URL --output dotnet.tar.gz \ + && echo "$DOTNET_SDK_DOWNLOAD_SHA dotnet.tar.gz" | sha512sum -c - \ + && mkdir -p /usr/share/dotnet \ + && tar -zxf dotnet.tar.gz -C /usr/share/dotnet \ + && rm dotnet.tar.gz \ + && ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet + +# Trigger the population of the local package cache +ENV NUGET_XMLDOC_MODE skip +RUN mkdir warmup \ + && cd warmup \ + && dotnet new \ + && cd .. \ + && rm -rf warmup \ + && rm -rf /tmp/NuGetScratch diff --git a/LICENSE b/LICENSE index cd10d6977b..80857b24c3 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2015 .NET Foundation +Copyright (c) 2016 .NET Foundation Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -19,4 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - diff --git a/README.md b/README.md index 6bac692842..204da582ac 100644 --- a/README.md +++ b/README.md @@ -16,14 +16,17 @@ - `1.1.2-sdk`, `1.1-sdk`, `1-sdk`, `sdk`, `latest`: - [`1.1.2-sdk-jessie` (*1.1/sdk/jessie/Dockerfile*)](https://github.com/dotnet/dotnet-docker/blob/master/1.1/sdk/jessie/Dockerfile) - [`1.1.2-sdk-nanoserver` (*1.1/sdk/nanoserver/Dockerfile*)](https://github.com/dotnet/dotnet-docker/blob/master/1.1/sdk/nanoserver/Dockerfile) -- `2.0.0-preview1-runtime`, `2.0-runtime`, `2-runtime`: - - [`2.0.0-preview1-runtime-jessie` (*2.0/runtime/jessie/Dockerfile*)](https://github.com/dotnet/dotnet-docker/blob/master/2.0/runtime/jessie/Dockerfile) - - [`2.0.0-preview1-runtime-nanoserver` (*2.0/runtime/nanoserver/Dockerfile*)](https://github.com/dotnet/dotnet-docker/blob/master/2.0/runtime/nanoserver/Dockerfile) -- `2.0.0-preview1-runtime-deps`, `2.0-runtime-deps`, `2-runtime-deps`: - - [`2.0.0-preview1-runtime-deps-jessie` (*2.0/runtime-deps/jessie/Dockerfile*)](https://github.com/dotnet/dotnet-docker/blob/master/2.0/runtime-deps/jessie/Dockerfile) -- `2.0.0-preview1-sdk`, `2.0-sdk`, `2-sdk`: - - [`2.0.0-preview1-sdk-jessie` (*2.0/sdk/jessie/Dockerfile*)](https://github.com/dotnet/dotnet-docker/blob/master/2.0/sdk/jessie/Dockerfile) - - [`2.0.0-preview1-sdk-nanoserver` (*2.0/sdk/nanoserver/Dockerfile*)](https://github.com/dotnet/dotnet-docker/blob/master/2.0/sdk/nanoserver/Dockerfile) +- `2.0.0-preview2-runtime`, `2.0-runtime`, `2-runtime`: + - [`2.0.0-preview2-runtime-stretch` (*2.0/runtime/stretch/Dockerfile*)](https://github.com/dotnet/dotnet-docker/blob/master/2.0/runtime/stretch/Dockerfile) + - [`2.0.0-preview2-runtime-nanoserver` (*2.0/runtime/nanoserver/Dockerfile*)](https://github.com/dotnet/dotnet-docker/blob/master/2.0/runtime/nanoserver/Dockerfile) +- [`2.0.0-preview2-runtime-jessie`, `2.0-runtime-jessie`, `2-runtime-jessie` (*2.0/runtime/jessie/Dockerfile*)](https://github.com/dotnet/dotnet-docker/blob/master/2.0/runtime/jessie/Dockerfile) +- `2.0.0-preview2-runtime-deps`, `2.0-runtime-deps`, `2-runtime-deps`: + - [`2.0.0-preview2-runtime-deps-stretch` (*2.0/runtime-deps/stretch/Dockerfile*)](https://github.com/dotnet/dotnet-docker/blob/master/2.0/runtime-deps/stretch/Dockerfile) +- [`2.0.0-preview2-runtime-deps-jessie`, `2.0-runtime-deps-jessie`, `2-runtime-deps-jessie` (*2.0/runtime-deps/jessie/Dockerfile*)](https://github.com/dotnet/dotnet-docker/blob/master/2.0/runtime-deps/jessie/Dockerfile) +- `2.0.0-preview2-sdk`, `2.0-sdk`, `2-sdk`: + - [`2.0.0-preview2-sdk-stretch` (*2.0/sdk/stretch/Dockerfile*)](https://github.com/dotnet/dotnet-docker/blob/master/2.0/sdk/stretch/Dockerfile) + - [`2.0.0-preview2-sdk-nanoserver` (*2.0/sdk/nanoserver/Dockerfile*)](https://github.com/dotnet/dotnet-docker/blob/master/2.0/sdk/nanoserver/Dockerfile) +- [`2.0.0-preview2-sdk-jessie`, `2.0-sdk-jessie`, `2-sdk-jessie` (*2.0/sdk/jessie/Dockerfile*)](https://github.com/dotnet/dotnet-docker/blob/master/2.0/sdk/jessie/Dockerfile) >**Note:** The latest tag no longer uses the project.json project format, but has now been updated to be csproj/MSBuild-based. If you do not wish to [migrate](https://docs.microsoft.com/en-us/dotnet/articles/core/preview3/tools/dotnet-migrate) your existing projects to MSBuild simply change your Dockerfile to use the `1.1.0-sdk-projectjson` or `1.1.0-sdk-projectjson-nanoserver` tag. Going forward, new .NET Core sdk images will be MSBuild-based. diff --git a/build-and-test.ps1 b/build-and-test.ps1 index b2e41dffd5..14db2aa340 100644 --- a/build-and-test.ps1 +++ b/build-and-test.ps1 @@ -6,9 +6,6 @@ param( Set-StrictMode -Version Latest $ErrorActionPreference = 'Stop' -$dirSeparator = [IO.Path]::DirectorySeparatorChar -$dockerRepo = (Get-Content "manifest.json" | ConvertFrom-Json).Repos[0].Name - if ($UseImageCache) { $optionalDockerBuildArgs = "" } @@ -16,38 +13,37 @@ else { $optionalDockerBuildArgs = "--no-cache" } +$manifest = Get-Content "manifest.json" | ConvertFrom-Json +$manifestRepo = $manifest.Repos[0] $platform = docker version -f "{{ .Server.Os }}" - -if ($platform -eq "windows") { - $imageOs = "nanoserver" -} -else { - $imageOs = "jessie" -} - -pushd $PSScriptRoot - -$tags = [System.Collections.ArrayList]@() -Get-ChildItem -Recurse -Filter Dockerfile | - where {$_.DirectoryName.TrimStart($PSScriptRoot) -like "*$dirSeparator$imageOs*"} | - # sort in descending order to ensure runtime-deps get built before runtime to satisfy dependency - Sort-Object {$_.DirectoryName} -Descending | - foreach { - $tag = "${dockerRepo}:" + - $_.DirectoryName. - Replace("$PSScriptRoot$dirSeparator", ''). - Replace("$dirSeparator$imageOs", ''). - Replace($dirSeparator, '-') - $tags.Add($tag) | Out-Null - Write-Host "--- Building $tag from $($_.DirectoryName) ---" - docker build $optionalDockerBuildArgs -t $tag $_.DirectoryName - if (-NOT $?) { - throw "Failed building $tag" - } +$builtTags = @() + +$manifestRepo.Images | + ForEach-Object { + $images = $_ + $_.Platforms | + Where-Object {[bool]($_.PSobject.Properties.name -match $platform)} | + ForEach-Object { + $dockerfilePath = $_.$platform.dockerfile + $tags = $_.$platform.Tags + if ([bool]($images.PSobject.Properties.name -match "sharedTags")) { + $tags += $images.sharedTags + } + + $qualifiedTags = $tags | ForEach-Object { + $manifestRepo.Name + ':' + $_.Replace('$(nanoServerVersion)', $manifest.TagVariables.NanoServerVersion) + } + $formattedTags = $qualifiedTags -join ', ' + Write-Host "--- Building $formattedTags from $dockerfilePath ---" + Invoke-Expression "docker build $optionalDockerBuildArgs -t $($qualifiedTags -join ' -t ') $dockerfilePath" + if ($LastExitCode -ne 0) { + throw "Failed building $formattedTags" + } + + $builtTags += $formattedTags + } } -popd - ./test/run-test.ps1 -UseImageCache:$UseImageCache -Write-Host "Tags built and tested:`n$($tags | Out-String)" +Write-Host "Tags built and tested:`n$($builtTags | Out-String)" diff --git a/manifest.json b/manifest.json index 3b83cd26f5..bc22ef885d 100644 --- a/manifest.json +++ b/manifest.json @@ -169,37 +169,37 @@ }, { "sharedTags": [ - "2.0.0-preview1-runtime-deps", + "2.0.0-preview2-runtime-deps", "2.0-runtime-deps", "2-runtime-deps" ], "platforms": { "linux": { - "dockerfile": "2.0/runtime-deps/jessie", + "dockerfile": "2.0/runtime-deps/stretch", "tags": [ - "2.0.0-preview1-runtime-deps-jessie" + "2.0.0-preview2-runtime-deps-stretch" ] } } }, { "sharedTags": [ - "2.0.0-preview1-runtime", + "2.0.0-preview2-runtime", "2.0-runtime", "2-runtime" ], "platforms": { "linux": { - "dockerfile": "2.0/runtime/jessie", + "dockerfile": "2.0/runtime/stretch", "tags": [ - "2.0.0-preview1-runtime-jessie" + "2.0.0-preview2-runtime-stretch" ] }, "windows": { "dockerfile": "2.0/runtime/nanoserver", "tags": [ - "2.0.0-preview1-runtime-nanoserver", - "2.0.0-preview1-runtime-nanoserver-$(nanoServerVersion)", + "2.0.0-preview2-runtime-nanoserver", + "2.0.0-preview2-runtime-nanoserver-$(nanoServerVersion)", "2.0-runtime-nanoserver", "2.0-runtime-nanoserver-$(nanoServerVersion)", "2-runtime-nanoserver", @@ -210,22 +210,22 @@ }, { "sharedTags": [ - "2.0.0-preview1-sdk", + "2.0.0-preview2-sdk", "2.0-sdk", "2-sdk" ], "platforms": { "linux": { - "dockerfile": "2.0/sdk/jessie", + "dockerfile": "2.0/sdk/stretch", "tags": [ - "2.0.0-preview1-sdk-jessie" + "2.0.0-preview2-sdk-stretch" ] }, "windows": { "dockerfile": "2.0/sdk/nanoserver", "tags": [ - "2.0.0-preview1-sdk-nanoserver", - "2.0.0-preview1-sdk-nanoserver-$(nanoServerVersion)", + "2.0.0-preview2-sdk-nanoserver", + "2.0.0-preview2-sdk-nanoserver-$(nanoServerVersion)", "2.0-sdk-nanoserver", "2.0-sdk-nanoserver-$(nanoServerVersion)", "2-sdk-nanoserver", @@ -233,6 +233,42 @@ ] } } + }, + { + "platforms": { + "linux": { + "dockerfile": "2.0/runtime-deps/jessie", + "tags": [ + "2.0.0-preview2-runtime-deps-jessie", + "2.0-runtime-deps-jessie", + "2-runtime-deps-jessie" + ] + } + } + }, + { + "platforms": { + "linux": { + "dockerfile": "2.0/runtime/jessie", + "tags": [ + "2.0.0-preview2-runtime-jessie", + "2.0-runtime-jessie", + "2-runtime-jessie" + ] + } + } + }, + { + "platforms": { + "linux": { + "dockerfile": "2.0/sdk/jessie", + "tags": [ + "2.0.0-preview2-sdk-jessie", + "2.0-sdk-jessie", + "2-sdk-jessie" + ] + } + } } ] } diff --git a/test/Dockerfile.test b/test/Dockerfile.test index a7536cbd4e..b4959890f4 100644 --- a/test/Dockerfile.test +++ b/test/Dockerfile.test @@ -2,5 +2,5 @@ FROM {image} WORKDIR test RUN dotnet new {dotnetNewParam} -RUN dotnet restore +RUN dotnet restore {optionalRestoreParams} RUN dotnet build diff --git a/test/run-test.ps1 b/test/run-test.ps1 index 0f89d0a887..ad91565120 100644 --- a/test/run-test.ps1 +++ b/test/run-test.ps1 @@ -3,6 +3,9 @@ param( [switch]$UseImageCache ) +Set-StrictMode -Version Latest +$ErrorActionPreference = 'Stop' + function Exec([scriptblock]$cmd, [string]$errorMessage = "Error executing command: " + $cmd) { & $cmd if ($LastExitCode -ne 0) { @@ -10,11 +13,21 @@ function Exec([scriptblock]$cmd, [string]$errorMessage = "Error executing comman } } -Set-StrictMode -Version Latest -$ErrorActionPreference = 'Stop' +function Get-ActivePlatformImages([PSCustomObject]$manifestRepo, [string]$platform) { + return $manifestRepo.Images | + ForEach-Object {$_.Platforms} | + Where-Object {[bool]($_.PSobject.Properties.name -match $platform)} +} + +function Get-RuntimeTag([string]$sdkDockerfilePath, [string]$runtimeType, [string]$platform, [PSCustomObject]$manifestRepo) { + $runtimeDockerfilePath = $sdkDockerfilePath.Replace("sdk", $runtimeType) + $platforms = Get-ActivePlatformImages $manifestRepo $platform | + Where-Object {$_.$platform.Dockerfile -eq $runtimeDockerfilePath} + return $manifestRepo.Name + ':' + $platforms[0].$platform.Tags[0] +} if ($UseImageCache) { - $optionalDockerBuildArgs="" + $optionalDockerBuildArgs = "" } else { $optionalDockerBuildArgs = "--no-cache" @@ -23,7 +36,7 @@ else { $dirSeparator = [IO.Path]::DirectorySeparatorChar $repoRoot = Split-Path -Parent $PSScriptRoot $manifestPath = [IO.Path]::combine(${repoRoot}, "manifest.json") -$dockerRepo = (Get-Content $manifestPath | ConvertFrom-Json).Repos[0].Name +$manifestRepo = (Get-Content $manifestPath | ConvertFrom-Json).Repos[0] $testFilesPath = "$PSScriptRoot$dirSeparator" $platform = docker version -f "{{ .Server.Os }}" @@ -31,34 +44,37 @@ $platform = docker version -f "{{ .Server.Os }}" $includePrereleasePackageSourceForSdkTag = $null if ($platform -eq "windows") { - $imageOs = "nanoserver" $containerRoot = "C:\" $platformDirSeparator = '\' } else { - $imageOs = "jessie" $containerRoot = "/" $platformDirSeparator = '/' } # Loop through each sdk Dockerfile in the repo and test the sdk and runtime images. -Get-ChildItem -Path $repoRoot -Recurse -Filter Dockerfile | - where DirectoryName -like "*${dirSeparator}sdk${dirSeparator}${imageOs}" | - foreach { - $sdkTag = $_.DirectoryName. - Replace("$repoRoot$dirSeparator", ''). - Replace("$dirSeparator$imageOs", ''). - Replace($dirSeparator, '-') - $fullSdkTag = "${dockerRepo}:${sdkTag}" +Get-ActivePlatformImages $manifestRepo $platform | + Where-Object {$_.$platform.Dockerfile.Contains('sdk')} | + ForEach-Object { + $sdkTag = $_.$platform.Tags[0] + $fullSdkTag = "$($manifestRepo.Name):${sdkTag}" $timeStamp = Get-Date -Format FileDateTime $appName = "app$timeStamp".ToLower() $buildImage = "sdk-build-$appName" - $dotnetNewParam = "console --framework netcoreapp$($sdkTag.Split('-')[0])" + $dotnetNewParam = "console --framework netcoreapp$($sdkTag.Split('-')[0].Substring(0,3))" + + $optionalRestoreParams = "" + if ($sdkTag -like $includePrereleasePackageSourceForSdkTag) { + $optionalRestoreParams = "-s https://dotnet.myget.org/F/dotnet-core/api/v3/index.json -s https://api.nuget.org/v3/index.json" + } Write-Host "----- Testing create, restore and build with $fullSdkTag with image $buildImage -----" Try { - exec { (Get-Content ${testFilesPath}Dockerfile.test).Replace("{image}", $fullSdkTag).Replace("{dotnetNewParam}", $dotnetNewParam) ` + exec { (Get-Content ${testFilesPath}Dockerfile.test). + Replace("{image}", $fullSdkTag). + Replace("{dotnetNewParam}", $dotnetNewParam). + Replace("{optionalRestoreParams}", $optionalRestoreParams) ` | docker build $optionalDockerBuildArgs -t $buildImage - } @@ -74,11 +90,11 @@ Get-ChildItem -Path $repoRoot -Recurse -Filter Dockerfile | dotnet publish -o ${containerRoot}volume } - $runtimeTag = $fullSdkTag.Replace("sdk", "runtime") - Write-Host "----- Testing on $runtimeTag with $sdkTag framework-dependent app -----" + $fullRuntimeTag = Get-RuntimeTag $_.$platform.Dockerfile "runtime" $platform $manifestRepo + Write-Host "----- Testing on $fullRuntimeTag with $sdkTag framework-dependent app -----" exec { docker run --rm ` -v ${framworkDepVol}":${containerRoot}volume" ` - "$runtimeTag" ` + "$fullRuntimeTag" ` dotnet "${containerRoot}volume${platformDirSeparator}test.dll" } } @@ -88,11 +104,6 @@ Get-ChildItem -Path $repoRoot -Recurse -Filter Dockerfile | if ($platform -eq "linux") { $selfContainedImage = "self-contained-build-${buildImage}" - $optionalRestoreParams = "" - if ($sdkTag -like $includePrereleasePackageSourceForSdkTag) { - $optionalRestoreParams = "-s https://dotnet.myget.org/F/dotnet-core/api/v3/index.json -s https://api.nuget.org/v3/index.json" - } - Write-Host "----- Creating publish-image for self-contained app built on $fullSdkTag -----" Try { exec { (Get-Content ${testFilesPath}Dockerfile.linux.publish). @@ -110,7 +121,7 @@ Get-ChildItem -Path $repoRoot -Recurse -Filter Dockerfile | dotnet publish -r debian.8-x64 -o ${containerRoot}volume } - if ($sdkTag -like "2.0-sdk") { + if ($sdkTag -like "2.0*-sdk*") { # Temporary workaround https://github.com/dotnet/corefx/blob/master/Documentation/project-docs/dogfooding.md#option-2-self-contained exec { docker run --rm ` -v ${selfContainedVol}":${containerRoot}volume" ` @@ -119,11 +130,11 @@ Get-ChildItem -Path $repoRoot -Recurse -Filter Dockerfile | } } - $runtimeDepsTag = $fullSdkTag.Replace("sdk", "runtime-deps") - Write-Host "----- Testing $runtimeDepsTag with $sdkTag self-contained app -----" + $fullRuntimeDepsTag = Get-RuntimeTag $_.$platform.Dockerfile "runtime-deps" $platform $manifestRepo + Write-Host "----- Testing $fullRuntimeDepsTag with $sdkTag self-contained app -----" exec { docker run -t --rm ` -v ${selfContainedVol}":${containerRoot}volume" ` - $runtimeDepsTag ` + $fullRuntimeDepsTag ` ${containerRoot}volume${platformDirSeparator}test } }