0

I'm building site via gulp inside a windows container:

mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-1909

The container have nodejs and gulp-cli installed in it as following (in Dockerfile):

#Install NodeJs
RUN (New-Object Net.WebClient).DownloadFile('https://nodejs.org/dist/v12.16.3/node-v12.16.3-win-x64.zip', 'node.zip'); \
    Expand-Archive -LiteralPath 'node.zip' -DestinationPath '.' ; \
    Start-Process -FilePath '.\node-v12.16.3-win-x64\npm' -NoNewWindow -Wait -ArgumentList 'install -g gulp-cli' ; \
    $env:PATH = 'c:\tools\node-v12.16.3-win-x64;' + $env:PATH; \
    [Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine);

As you can see I'm installing node in the container under c:\tools\node-v12.16.3-win-x64.

In my cake script i try to execute gulp file as following:

StartProcess("cmd", new ProcessSettings {
            Arguments = "/c gulp",
            WorkingDirectory = projectDir)
        });

But seems that Start-Process cannot find the file... I'm getting this output from cake Start-Process:

Executing: "cmd" /c gulp
'gulp' is not recognized as an internal or external command

Running the container interactive I can see the file it is in that place and if I run gulp from projectDir all works.

I've also try it to run it like all of the following forms without success:

StartProcess("powershell", new ProcessSettings {
            Arguments = "gulp",
            WorkingDirectory = projectDir)
        });

StartProcess("gulp");

StartProcess("gulp.cmd");

This is the output from within the container regarding npn, gulp versions (requested from comments):

enter image description here

Diego
  • 666
  • 1
  • 8
  • 27
  • Could you provide output to when you interactively run ```gulp --version``` on this container? And I am also curious if this works: ```where gulp``` and ```where npm``` I think gulp requires npm to be able to run well, so that's check npm too :) – estherwn May 19 '20 at 10:19
  • Hi @estherwn thanks for your reply... I've added the output you mention to the question – Diego May 19 '20 at 11:35

1 Answers1

1

EDIT:

That 'Local version: Unknown' seems off. Is C:\code your project directory?

When I look at the 'official' gulp configuration steps, the installation results in having both a CLI and local version. (see: https://gulpjs.com/docs/en/getting-started/quick-start/ )

You could consider using Cake.Gulp which can help run gulp with cake either from a local or global installation:

Perhaps making sure that npm installed gulp locally might do the trick because cake is expecting a local variant. I am unfortunately inexperienced with cake, so this is my best guess after doing some basic research. (one of my sources: Why do we need to install gulp globally and locally? )


Original answer

You could try using an absolute path to the gulp application.

For example:

StartProcess("cmd", new ProcessSettings {
            Arguments = "/c c:\tools\node-v12.16.3-win-x64\gulp",
            WorkingDirectory = projectDir)
        });

It could be that your environment is not set properly, I found this that could be of use: Appending to PATH in a Windows Docker container

estherwn
  • 156
  • 6
  • Hi, I've tried tht way also with same results. Good point with the environment variable, but seems it is sett properly since if i run the container iteratively and check environment variables it is there. – Diego May 19 '20 at 09:57