Windows 容器开发环境
一个基于 Windows 操作系统的 Docker 容器开发环境, 可用于编译 C 方面代码
# escape=`
FROM mcr.microsoft.com/windows/servercore:ltsc2022
SHELL ["cmd", "/S", "/C"]
RUN curl -SL --output vs_buildtools.exe https://aka.ms/vs/17/release/vs_buildtools.exe
RUN start /w vs_buildtools.exe `
--quiet --wait --norestart --nocache `
--installPath "%ProgramFiles(x86)%\Microsoft Visual Studio\2022\BuildTools" `
--add Microsoft.VisualStudio.Workload.VCTools `
--add Microsoft.Component.MSBuild `
--add Microsoft.VisualStudio.Component.Roslyn.Compiler `
--add Microsoft.VisualStudio.Component.TextTemplating `
--add Microsoft.VisualStudio.Component.VC.CoreBuildTools `
--add Microsoft.VisualStudio.Component.VC.CoreIde `
--add Microsoft.VisualStudio.Component.VC.Redist.14.Latest `
--add Microsoft.VisualStudio.Component.Windows10SDK `
--add Microsoft.VisualStudio.ComponentGroup.NativeDesktop.Core `
--add Microsoft.VisualStudio.Component.TestTools.BuildTools `
--add Microsoft.VisualStudio.Component.VC.ASAN `
--add Microsoft.VisualStudio.Component.VC.CMake.Project `
--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 `
--add Microsoft.VisualStudio.Component.Windows11SDK.22000 `
--add Microsoft.Component.VC.Runtime.UCRTSDK `
|| IF "%ERRORLEVEL%"=="3010" EXIT 0
RUN del /q vs_buildtools.exe
ENTRYPOINT ["C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\Common7\\Tools\\VsDevCmd.bat", "&&", "powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass"]
编译
docker run -it --rm cpp_buildtools
运行
docker build -t cpp_buildtools:latest -m 2GB .