Skip to content

Proposal: Use a Windows docker image for MSVC build? #91

@dsnopek

Description

@dsnopek

While I followed the instructions (and extra clues in GitHub), I couldn't actually get the godot-msvc image to successfully compile anything.

However, Docker is capable of running Windows images (ie. images with Windows in them, rather than Linux), and so I created one that is capable of compiling Godot in my testing. Here's the Dockerfile (needs to run on a Windows host, where the Docker daemon is in Windows container mode):

# escape=`

# Use the latest Windows Server Core image with .NET Framework 4.8.
FROM mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2019

# Restore the default Windows shell for correct batch processing.
SHELL ["cmd", "/S", "/C"]

RUN `
    # Download the Build Tools bootstrapper.
    curl -SL --output vs_buildtools.exe https://aka.ms/vs/16/release/vs_buildtools.exe `
    `
    # Install Build Tools with the Microsoft.VisualStudio.Workload.AzureBuildTools workload, excluding workloads and components with known issues.
    && (start /w vs_buildtools.exe --quiet --wait --norestart --nocache modify `
        --installPath "%ProgramFiles(x86)%\Microsoft Visual Studio\2019\BuildTools" `
        --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended`
        || IF "%ERRORLEVEL%"=="3010" EXIT 0) `
    `
    # Cleanup
    && del /q vs_buildtools.exe

RUN `
    curl -SL --output c:\python-installer.exe https://www.python.org/ftp/python/3.9.6/python-3.9.6.exe `
    `
    && (start c:\python-installer.exe /quiet InstallAllUsers=1 PrependPath=1) `
    && del /q c:\python-installer.exe

RUN python -m pip install scons

# Define the entry point for the docker container.
# This entry point starts the developer command prompt and launches the PowerShell shell.
ENTRYPOINT ["C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\Common7\\Tools\\VsDevCmd.bat", "&&", "powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass"]

It installs MSVC 2019, Python and scons. I was able to push this image to a private Docker repository (after adding an "allow-nondistributable-artifacts" setting in the Windows Docker daemon, so it wouldn't refuse to push Windows-licensed layers) and then use it via GitLab CI to successfully build Godot for my project.

Windows containers can only run on Windows hosts, and I don't know much about GitHub Actions (because I use GitLab CI), but assume there must be some way to have jobs run on Windows hosts with GitHub Actions too?

I haven't actually tried building the UWP export with this approach, because I don't need it -- I need to build via MSVC for the GodotSteam module -- but I assume if it works for normal Windows builds, then it should work for UWP as well.

Anyway, just a proposal I thought I'd throw out there in case it may be useful in light of other issues like #78 :-)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions