Skip to content

Commit 85c036d

Browse files
authored
Merge pull request #5 from ecstatic-morse/windows
[WIP] Add a Docker image for Windows builds
2 parents 09b38b4 + 067aae3 commit 85c036d

File tree

3 files changed

+75
-0
lines changed

3 files changed

+75
-0
lines changed

windows/Dockerfile

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# escape=`
2+
3+
FROM mcr.microsoft.com/windows/servercore:1803
4+
5+
# Install the Visual C++ Build tools
6+
#
7+
# Error code 3010 indicates a restart is required to complete installation, but
8+
# the command was otherwise successful.
9+
SHELL ["cmd", "/S", "/C"]
10+
ADD https://aka.ms/vs/15/release/vs_buildtools.exe C:\TEMP\vs_buildtools.exe
11+
RUN C:\TEMP\vs_buildtools.exe --quiet --wait --norestart --nocache `
12+
--add "Microsoft.VisualStudio.Workload.VCTools" `
13+
--includeRecommended `
14+
|| IF "%ERRORLEVEL%"=="3010" EXIT 0
15+
16+
SHELL ["powershell", "-Command"]
17+
18+
# Install vcpkg
19+
ADD https://github.com/Microsoft/vcpkg/archive/master.zip C:\TEMP\vcpkg-master.zip
20+
RUN $ErrorActionPreference = 'Stop'; `
21+
Expand-Archive -Path C:\TEMP\vcpkg-master.zip -DestinationPath .; `
22+
cd .\vcpkg-master; `
23+
.\bootstrap-vcpkg.bat; `
24+
.\vcpkg integrate install
25+
26+
# Install packages
27+
COPY vc-packages.txt C:\
28+
RUN .\vcpkg-master\vcpkg install @(Get-Content C:\vc-packages.txt)
29+
30+
CMD ["powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass"]

windows/README.md

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Windows build environment for rust crates
2+
3+
This repository contains the source of a Docker container the Rust project uses
4+
to build third-party crates on Windows. It is based on **Windows Server Core,
5+
version 1803**, and contains all the native dependencies used by the Rust
6+
crates we know of.
7+
8+
## Dependencies
9+
10+
All dependencies listed in `vc-packages.txt` will be installed into the
11+
image with `vcpkg`.
12+
13+
## Using the docker image
14+
15+
This image must be run on a Windows host with both containerization and Hyper-V
16+
enabled (Windows 10 Pro or Windows Server >=2016). If you wish to run `crater`
17+
on an Azure VM, this requires a virtual machine image tagged with "v3".
18+
19+
20+
Hyper-V can be enabled in [the GUI][hyperv] or in `Powershell` with:
21+
22+
```powershell
23+
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All
24+
```
25+
26+
A reboot is required for this to take effect.
27+
28+
[hyperv]: https://docs.microsoft.com/en-us/virtualization/hyper-v-on-windows/quick-start/enable-hyper-v#enable-the-hyper-v-role-through-settings
29+
30+
31+
The Docker host must have a [build number][build] equal to that of the image
32+
you wish to run (presently `mcr.microsoft.com/windows/servercore:1803`).
33+
34+
[Docker Desktop][] is required to run native Windows containers; this image
35+
will not work with Docker Toolbox. Once installed, ensure that Docker Desktop
36+
is configured to run Windows containers by right-clicking the icon in the
37+
dock, or by running the following in `Powershell`:
38+
39+
```powershell
40+
$Env:ProgramFiles\Docker\Docker\DockerCli.exe -SwitchDaemon .
41+
```
42+
43+
[Docker Desktop]: https://hub.docker.com/editions/community/docker-ce-desktop-windows
44+
[build]: https://docs.microsoft.com/en-us/virtualization/windowscontainers/deploy-containers/version-compatibility

windows/vc-packages.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
zlib

0 commit comments

Comments
 (0)