Windows docker image to build windows Theia IDE

Hi devs,

I am trying to build a Windows-based docker image, which I plan to use for automated build of windows instance of the Theia IDE. Currently the “work in progress” state image looks like the following …

FROM mcr.microsoft.com/windows/servercore:1809 as installer
USER ContainerAdministrator

SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';$ProgressPreference='silentlyContinue';"]

RUN Invoke-WebRequest "https://nodejs.org/dist/v16.15.1/node-v16.15.1-x86.msi" \
		-OutFile node-v16.15.1-x86.msi -UseBasicParsing ; \
	Start-Process -Wait -FilePath msiexec -ArgumentList /i, "node-v16.15.1-x86.msi", /qn 
ADD install.ps1 .
RUN irm get.scoop.sh -outfile 'install.ps1'
RUN .\install.ps1 -RunAsAdmi | Out-Null
RUN scoop install yarn
RUN scoop install python
RUN Invoke-WebRequest "https://aka.ms/vs/17/release/vs_buildtools.exe" \
		-OutFile vs_buildtools.exe -UseBasicParsing ; \
	Start-Process -FilePath 'vs_buildtools.exe' -ArgumentList '/quiet', '/NoRestart' -Wait ; 

When I run the yarn install from this image, it always ends with the following error …

yarn install v1.22.19
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
warning "workspace-aggregator-d785db11-0baf-48c0-a489-1e210903683c > browser-app > @theia/messages > react-perfect-scrollbar@1.5.8" has unmet peer dependency "react@>=16.3.3".
warning "workspace-aggregator-d785db11-0baf-48c0-a489-1e210903683c > browser-app > @theia/messages > react-perfect-scrollbar@1.5.8" has unmet peer dependency "react-dom@>=16.3.3".
warning "workspace-aggregator-d785db11-0baf-48c0-a489-1e210903683c > browser-app > @theia/process > node-pty@0.11.0-beta17" has unmet peer dependency "node-gyp@^8.3.0".
[4/4] Building fresh packages... #####################################################################################################################################] 2832/2832 [1/10] ⡀ drivelist
[2/10] ⡀ keytar
[3/10] ⡀ nsfw
[4/10] ⢀ oniguruma
error C:\node_modules\nsfw: Command failed.
Exit code: 1
Command: node-gyp rebuild
Arguments:
Directory: C:\node_modules\nsfw
Output:
gyp info it worked if it ends with ok
gyp info using node-gyp@7.1.2
gyp info using node@16.15.1 | win32 | ia32
gyp ERR! find VS
gyp ERR! find VS msvs_version not set from command line or npm config
gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer, try re-running with '--loglevel silly' for more details
gyp ERR! find VS looking for Visual Studio 2015
gyp ERR! find VS - not found
gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8
gyp ERR! find VS
gyp ERR! find VS **************************************************************
gyp ERR! find VS You need to install the latest version of Visual Studio
gyp ERR! find VS including the "Desktop development with C++" workload.
gyp ERR! find VS For more information consult the documentation at:
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
gyp ERR! find VS **************************************************************
gyp ERR! find VS
gyp ERR! configure error
gyp ERR! stack Error: Could not find any Visual Studio installation to use
gyp ERR! stack     at VisualStudioFinder.fail (C:\node_modules\@npmcli\run-script\node_modules\node-gyp\lib\find-visualstudio.js:121:47)
gyp ERR! stack     at C:\node_modules\@npmcli\run-script\node_modules\node-gyp\lib\find-visualstudio.js:74:16
gyp ERR! stack     at VisualStudioFinder.findVisualStudio2013 (C:\node_modules\@npmcli\run-script\node_modules\node-gyp\lib\find-visualstudio.js:351:14)
gyp ERR! stack     at C:\node_modules\@npmcli\run-script\node_modules\node-gyp\lib\find-visualstudio.js:70:14
gyp ERR! stack     at C:\node_modules\@npmcli\run-script\node_modules\node-gyp\lib\find-visualstudio.js:372:16
gyp ERR! stack     at C:\node_modules\@npmcli\run-script\node_modules\node-gyp\lib\util.js:54:7
gyp ERR! stack     at C:\node_modules\@npmcli\run-script\node_modules\node-gyp\lib\util.js:33:16
gyp ERR! stack     at ChildProcess.exithandler (node:child_process:406:5)
gyp ERR! stack     at ChildProcess.emit (node:events:527:28)
gyp ERR! stack     at maybeClose (node:internal/child_process:1092:16)
gyp ERR! System Windows_NT 10.0.17763
gyp ERR! command "C:\\Program Files (x86)\\nodejs\\node.exe" "C:\\node_modules\\@npmcli\\run-script\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\node_modules\nsfw

I have tryied to follow this guide.
I have also went througth many (I would say almost all ) others internet discussions, but always with the same result.
Just as a note … the build from the local windows machine works well . The problem is the docker image tools installation …

Does anyone have any idea what I am doing wrong?

Thanks for any hint!

@Nowass nodejs installs the windows-build-tools automatically now (since version 14). Can you try removing the install calls for python and the vs-buildtools? It might be that installing the build tools manually messes with the existing installation.

Hi @msujew, thanks for hint … you are right … it should not be there, I just forget to mention that I add the build tools installation just during my trials … but the result is the same.
BTW, I f I do not install python, then it is missing and the build fails on gyp ERR! stack Error: Could not find any Python installation to use