|
| 1 | +# escape=` |
| 2 | + |
| 3 | +# IMAGES BUILT FROM THIS DOCKERFILE ARE NOT TO BE SHARED ON PUBLIC DOCKER HUBs. |
| 4 | +# |
| 5 | +# WARNING: NON-FREE AND DISTRIBUTION RESTRICTED ENCUMBERED SOFTWARE IN IMAGE. |
| 6 | +# |
| 7 | +# The VS Build Tools are very encumbered. |
| 8 | +# |
| 9 | +# IMAGE SHOULD ONLY BE BUILT BY USERS WHO CAN FOLLOW THESE TERMS: |
| 10 | +# https://visualstudio.microsoft.com/license-terms/mlt553512/ |
| 11 | +# |
| 12 | +# See the fourth paragraph of this blog post for a warning from a Microsoftie: |
| 13 | +# https://blogs.msdn.microsoft.com/vcblog/2018/08/13/using-msvc-in-a-docker-container-for-your-c-projects/ |
| 14 | +# |
| 15 | +# """ |
| 16 | +# The VS Build Tools are licensed as a supplement to your existing Visual Studio license. |
| 17 | +# Any images built with these tools should be for your personal use or for use in your |
| 18 | +# organization in accordance with your existing Visual Studio and Windows licenses. |
| 19 | +# Please don’t share these images on a public Docker hub. |
| 20 | +# """ |
| 21 | +# |
| 22 | +# That said, this Dockerfile will be built in a CI system for validation and testing in the project |
| 23 | +# but most definitely will skip deployment. |
| 24 | + |
| 25 | +FROM mcr.microsoft.com/windows/servercore:%%WINDOWS-VERSION%% |
| 26 | + |
| 27 | +SHELL ["powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] |
| 28 | + |
| 29 | +RUN $url = 'https://download.visualstudio.microsoft.com/download/pr/20130c62-1bc8-43d6-b4f0-c20bb7c79113/7276a7355219f7988c480d198e23c2973bbb7ab971c4f0415c26cab2955344e5/vs_BuildTools.exe'; ` |
| 30 | + $sha256 = '7276A7355219F7988C480D198E23C2973BBB7AB971C4F0415C26CAB2955344E5'; ` |
| 31 | + Invoke-WebRequest -Uri $url -OutFile C:\vs_BuildTools.exe; ` |
| 32 | + $actual256 = (Get-FileHash vs_BuildTools.exe -Algorithm sha256).Hash; ` |
| 33 | + if ($actual256 -ne $sha256) { ` |
| 34 | + Write-Host 'FAILED!'; ` |
| 35 | + Write-Host ('expected: {0}' -f $sha256); ` |
| 36 | + Write-Host ('got: {0}' -f $actual256); ` |
| 37 | + exit 1; ` |
| 38 | + }; ` |
| 39 | + Start-Process -filepath C:\vs_BuildTools.exe -wait -argumentlist ' ` |
| 40 | + --quiet --wait --norestart --nocache ` |
| 41 | + --installPath C:\BuildTools ` |
| 42 | + --add Microsoft.Component.MSBuild ` |
| 43 | + --add Microsoft.VisualStudio.Component.Windows10SDK.%%SDK-BUILD%% ` |
| 44 | + --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64'; ` |
| 45 | + Remove-Item 'C:\\vs_BuildTools.exe'; ` |
| 46 | + Remove-Item -Force -Recurse 'C:\\Program Files (x86)\\Microsoft Visual Studio\\Installer'; ` |
| 47 | + [Environment]::SetEnvironmentVariable('__VSCMD_ARG_NO_LOGO', '1', [EnvironmentVariableTarget]::Machine) |
| 48 | + |
| 49 | +ENV RUSTUP_HOME=C:\rustup ` |
| 50 | + CARGO_HOME=C:\cargo ` |
| 51 | + RUST_VERSION=%%RUST-VERSION%% |
| 52 | + |
| 53 | +RUN [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12; ` |
| 54 | + $url = 'https://static.rust-lang.org/rustup/archive/%%RUSTUP-VERSION%%/x86_64-pc-windows-msvc/rustup-init.exe'; ` |
| 55 | + $sha256 = '%%RUSTUP-SHA256%%'; ` |
| 56 | + Invoke-WebRequest -Uri $url -OutFile C:\rustup-init.exe; ` |
| 57 | + $actual256 = (Get-FileHash rustup-init.exe -Algorithm sha256).Hash; ` |
| 58 | + if ($actual256 -ne $sha256) { ` |
| 59 | + Write-Host 'FAILED!'; ` |
| 60 | + Write-Host ('expected: {0}' -f $sha256); ` |
| 61 | + Write-Host ('got: {0}' -f $actual256); ` |
| 62 | + exit 1; ` |
| 63 | + }; ` |
| 64 | + New-Item ${env:CARGO_HOME}\bin -type directory | Out-Null; ` |
| 65 | + $newPath = ('{0}\bin;{1}' -f ${env:CARGO_HOME}, ${env:PATH}); ` |
| 66 | + [Environment]::SetEnvironmentVariable('PATH', $newPath, [EnvironmentVariableTarget]::Machine); ` |
| 67 | + [Environment]::SetEnvironmentVariable('PATH', $newPath, [EnvironmentVariableTarget]::Process); ` |
| 68 | + C:\rustup-init.exe -y -v --no-modify-path --default-toolchain ${env:RUST_VERSION} --default-host x86_64-pc-windows-msvc; ` |
| 69 | + Remove-Item C:\rustup-init.exe; ` |
| 70 | + rustup -V; ` |
| 71 | + cargo -V; ` |
| 72 | + rustc -V |
0 commit comments