godotengine / build-containers

Godot engine build containers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Proposal: Use a Windows docker image for MSVC build?

dsnopek opened this issue · comments

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 :-)

As far as I know, official builds don't use GitHub Actions. For reference, it takes around 26 hours on my crappy laptop to build everything (except UWP), and it takes only 4 hours on AMD Ryzen™ Threadripper™, so GitHub Actions are probably not suited for this.

I believe the limitation/requirement is that everything must be run on a single Linux host. Unless official build system moves to distributed approach I guess.

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?

GitHub Actions has Windows, macOS and Linux instances available.

That said, we intend to keep official builds on MinGW for various reasons, so having this in the official containers repository would only be useful for UWP (which is currently broken).

As far as I know, official builds don't use GitHub Actions.

Ah, ok, for some reason I thought the official builds were done via GitHub Actions.

I believe the limitation/requirement is that everything must be run on a single Linux host. Unless official build system moves to distributed approach I guess.

Ok, I guess that probably means this proposal won't work. But if the builds could be done via GitLab CI or Jenkins or something, it's definitely possible to have the build run on Windows, even without having a physical Windows machine available.

That said, we intend to keep official builds on MinGW for various reasons, so having this in the official containers repository would only be useful for UWP (which is currently broken).

Understood! This proposal was meant as a replacement for the godot-msvc image, which is only used officially for the UWP build. However, it could be also useful for other folks who want to use a godot-msvc image for their own purposes (like I do for my project :-)).

I am also looking forward to automating the construction of this module, perhaps offering the option of manually uploading or building zip packages from auxiliary containers.