diff --git a/windows/Dockerfile b/windows/Dockerfile new file mode 100644 index 0000000..c33d3a1 --- /dev/null +++ b/windows/Dockerfile @@ -0,0 +1,30 @@ +# escape=` + +FROM mcr.microsoft.com/windows/servercore:1803 + +# Install the Visual C++ Build tools +# +# Error code 3010 indicates a restart is required to complete installation, but +# the command was otherwise successful. +SHELL ["cmd", "/S", "/C"] +ADD https://aka.ms/vs/15/release/vs_buildtools.exe C:\TEMP\vs_buildtools.exe +RUN C:\TEMP\vs_buildtools.exe --quiet --wait --norestart --nocache ` + --add "Microsoft.VisualStudio.Workload.VCTools" ` + --includeRecommended ` + || IF "%ERRORLEVEL%"=="3010" EXIT 0 + +SHELL ["powershell", "-Command"] + +# Install vcpkg +ADD https://github.com/Microsoft/vcpkg/archive/master.zip C:\TEMP\vcpkg-master.zip +RUN $ErrorActionPreference = 'Stop'; ` + Expand-Archive -Path C:\TEMP\vcpkg-master.zip -DestinationPath .; ` + cd .\vcpkg-master; ` + .\bootstrap-vcpkg.bat; ` + .\vcpkg integrate install + +# Install packages +COPY vc-packages.txt C:\ +RUN .\vcpkg-master\vcpkg install @(Get-Content C:\vc-packages.txt) + +CMD ["powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass"] diff --git a/windows/README.md b/windows/README.md new file mode 100644 index 0000000..4521739 --- /dev/null +++ b/windows/README.md @@ -0,0 +1,44 @@ +# Windows build environment for rust crates + +This repository contains the source of a Docker container the Rust project uses +to build third-party crates on Windows. It is based on **Windows Server Core, +version 1803**, and contains all the native dependencies used by the Rust +crates we know of. + +## Dependencies + +All dependencies listed in `vc-packages.txt` will be installed into the +image with `vcpkg`. + +## Using the docker image + +This image must be run on a Windows host with both containerization and Hyper-V +enabled (Windows 10 Pro or Windows Server >=2016). If you wish to run `crater` +on an Azure VM, this requires a virtual machine image tagged with "v3". + + +Hyper-V can be enabled in [the GUI][hyperv] or in `Powershell` with: + +```powershell +Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All +``` + +A reboot is required for this to take effect. + +[hyperv]: https://docs.microsoft.com/en-us/virtualization/hyper-v-on-windows/quick-start/enable-hyper-v#enable-the-hyper-v-role-through-settings + + +The Docker host must have a [build number][build] equal to that of the image +you wish to run (presently `mcr.microsoft.com/windows/servercore:1803`). + +[Docker Desktop][] is required to run native Windows containers; this image +will not work with Docker Toolbox. Once installed, ensure that Docker Desktop +is configured to run Windows containers by right-clicking the icon in the +dock, or by running the following in `Powershell`: + +```powershell +$Env:ProgramFiles\Docker\Docker\DockerCli.exe -SwitchDaemon . +``` + +[Docker Desktop]: https://hub.docker.com/editions/community/docker-ce-desktop-windows +[build]: https://docs.microsoft.com/en-us/virtualization/windowscontainers/deploy-containers/version-compatibility diff --git a/windows/vc-packages.txt b/windows/vc-packages.txt new file mode 100644 index 0000000..f22003e --- /dev/null +++ b/windows/vc-packages.txt @@ -0,0 +1 @@ +zlib