Skip to content

Commit aba6bf7

Browse files
committed
Update Rust version to 1.75.0 and enhance Docker build scripts for Windows and update the README file
Signed-off-by: bashir <[email protected]>
1 parent d413394 commit aba6bf7

File tree

3 files changed

+69
-8
lines changed

3 files changed

+69
-8
lines changed

Diff for: Dockerfile.windows.x86_64

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ ARG RUST_TOOLCHAIN
77
FROM mcr.microsoft.com/windows/servercore:$WIN_VER
88

99
ENV chocolateyUseWindowsCompression "true"
10-
ENV RUST_TOOLCHAIN="1.46.0"
10+
# Update Rust version to one that supports cargo resolver
11+
ENV RUST_TOOLCHAIN="1.75.0"
1112
# Set Chocolatey version to 1.4.0 to avoid .NET Framework 4.8 dependency
1213
ENV chocolateyVersion="1.4.0"
1314

Diff for: README.md

+38-1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ Example of running cargo build on the kvm crate:
4242
Finished `release` profile [optimized] target(s) in 6.34s
4343
```
4444

45+
For Windows users (ensure Docker Desktop is in Linux containers mode):
46+
```powershell
47+
> git clone https://github.com/rust-vmm/kvm.git
48+
> cd kvm
49+
> docker run --volume "${PWD}:/kvm" `
50+
rustvmm/dev:latest `
51+
/bin/bash -c "cd /kvm && cargo build --release"
52+
```
4553
## Testing Changes locally with the Container Image
4654

4755
When we modify the container to install new dependencies, we may need to
@@ -74,6 +82,28 @@ Since you've mounted the host's current directory ($(pwd)) to `/workdir` in
7482
the container, any files in the current working directory on the host will be
7583
accessible in the `/workdir` directory inside the container.
7684

85+
For Windows (ensure Docker Desktop is in Linux containers mode):
86+
```powershell
87+
> cd rust-vmm-container
88+
> .\docker.ps1 build
89+
90+
# Example output: Build completed for rustvmm/dev:gb607c2b_x86_64
91+
92+
# Test the container using the tag from the build output
93+
> docker run -it --rm `
94+
--volume "${PWD}:/path/to/workdir" `
95+
--workdir /path/to/workdir `
96+
rustvmm/dev:gb607c2b_x86_64
97+
```
98+
99+
Note: Unlike Linux, Windows doesn't have direct access to KVM, so the `--device=/dev/kvm` and `--privileged` flags are not needed.
100+
101+
Note: If you want to build a Windows container instead, you can switch Docker Desktop to "Windows containers" mode and run:
102+
```powershell
103+
> cd rust-vmm-container
104+
> .\docker.ps1 build # This will automatically use Dockerfile.windows.x86_64
105+
```
106+
77107
## Publishing a New Version
78108

79109
A new container version is published for each PR merged to main that adds
@@ -107,6 +137,13 @@ On an `aarch64` platform:
107137
> ./docker.sh publish
108138
```
109139

140+
On Windows (ensure Docker Desktop is in Linux containers mode):
141+
```powershell
142+
> cd rust-vmm-container
143+
> .\docker.ps1 build
144+
> .\docker.ps1 publish
145+
```
146+
110147
You will need to redo all steps on an `x86_64` platform so the containers are
111148
kept in sync (same package versions on both `x86_64` and `aarch64`).
112149

@@ -123,4 +160,4 @@ If it is the first time you are creating a docker manifest, most likely it will
123160
fail with: ```docker manifest is only supported when experimental cli features
124161
are enabled```. Checkout
125162
[this article](https://medium.com/@mauridb/docker-multi-architecture-images-365a44c26be6)
126-
to understand why and how to fix it.
163+
to understand why and how to fix it.

Diff for: docker.ps1

+29-6
Original file line numberDiff line numberDiff line change
@@ -18,33 +18,43 @@ function Next-Version {
1818
}
1919

2020
function Get-FullVersion {
21-
return "$IMAGE_NAME:g$(Next-Version)"
21+
$version = Next-Version
22+
return "${IMAGE_NAME}:g${version}"
2223
}
2324

2425
function Print-NextVersion {
25-
return "$IMAGE_NAME:g$(Next-Version)"
26+
Write-Output (Get-FullVersion)
2627
}
2728

2829
function Print-Registry {
29-
return $REGISTRY
30+
Write-Output $REGISTRY
3031
}
3132

3233
function Print-ImageName {
33-
return $IMAGE_NAME
34+
Write-Output $IMAGE_NAME
3435
}
3536

3637
function Build-Tag {
3738
return "$(Get-FullVersion)_$ARCH"
3839
}
3940

4041
function Build-Container {
42+
# Check if running in Linux or Windows container mode
43+
$containerInfo = docker version --format '{{.Server.Os}}'
44+
$dockerfile = if ($containerInfo -eq "linux") {
45+
"Dockerfile"
46+
} else {
47+
"Dockerfile.windows.x86_64"
48+
}
49+
4150
# Build the container and check for failures
42-
# Docker build returns 0 on success, non-zero on failure
4351
$tag = Build-Tag
52+
Write-Host "Building using $dockerfile in $containerInfo container mode..."
53+
4454
docker build -t $tag `
4555
--build-arg GIT_BRANCH=$GIT_BRANCH `
4656
--build-arg GIT_COMMIT=$GIT_COMMIT `
47-
-f Dockerfile.windows.x86_64 .
57+
-f $dockerfile .
4858
if ($LASTEXITCODE -ne 0) {
4959
Write-Error "Build failed with exit code $LASTEXITCODE"
5060
exit $LASTEXITCODE
@@ -55,7 +65,20 @@ function Build-Container {
5565
function Publish-Container {
5666
$tag = Build-Tag
5767
Write-Host "Publishing $tag to dockerhub"
68+
69+
# Check if image exists locally
70+
$imageExists = docker image inspect $tag 2>$null
71+
if ($LASTEXITCODE -ne 0) {
72+
Write-Error "Image $tag not found locally. Please run 'build' first."
73+
exit 1
74+
}
75+
76+
# Attempt to push
5877
docker push $tag
78+
if ($LASTEXITCODE -ne 0) {
79+
Write-Error "Failed to publish $tag"
80+
exit $LASTEXITCODE
81+
}
5982
Write-Host "Successfully published $tag"
6083
}
6184

0 commit comments

Comments
 (0)