Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows Container Image #261

Open
pcj opened this issue Feb 25, 2020 · 5 comments
Open

Windows Container Image #261

pcj opened this issue Feb 25, 2020 · 5 comments

Comments

@pcj
Copy link

pcj commented Feb 25, 2020

In a perfect world we would not have to consider windows testing, but of course we do. While the linux container support here has been great, the windows container story is lacking.

Given cypress now has cross-platform (browser) testing, wouldn't it be great to claim cross-platform (container os) support as well?

Also see #51

@pcj
Copy link
Author

pcj commented Feb 25, 2020

Here's my progress using a windows container image on cirrus-ci:

# https://gist.github.com/fkorotkov/ea5baf3dc29a58fa20f977f39f635d21
windows_integration_task:
  # depends_on:
  #   - build
  windows_container:
    image: cirrusci/windowsservercore:2019
    os_version: 2019
  env:
    CYPRESS_CACHE_FOLDER: C:\Users\ContainerAdministrator\AppData\Local
    DEBUG: cypress*
  node_modules_cache:
    folder: node_modules
    fingerprint_script: type package-lock.json
  env_list_script:
    - ps: gci env:* | sort-object name
  nodejs_install_script:
    - choco install -y nodejs
  chrome_install_script:
    - choco install -y googlechrome
  npm_install_script:
    - refreshenv
    - npm install
  cypress_run_script:
    - refreshenv
    - ps: gci env:* | sort-object name
    - ps: New-Item -ItemType file "$env:CYPRESS_CACHE_FOLDER\example.txt"
    - npm run "cy:bzl:ci-windows"
#< CLIXML
Name                           Value                                           
----                           -----                                           
ALLUSERSPROFILE                C:\ProgramData                                  
APPDATA                        C:\Users\ContainerAdministrator\AppData\Roaming 
BRANCH                         prep_063                                        
ChocolateyInstall              C:\ProgramData\chocolatey                       
ChocolateyLastPathUpdate       132022097771569953                              
CI                             true                                            
CI_NODE_INDEX                  3                                               
CI_NODE_TOTAL                  4                                               
CIRRUS_BASE_BRANCH             master                                          
CIRRUS_BASE_SHA                584654397ede37d94032d6f9c91665258ebf3d2a        
CIRRUS_BRANCH                  prep_063                                        
CIRRUS_BUILD_ID                5667610595426304                                
CIRRUS_CHANGE_IN_REPO          0c8832b15c8cf466710abfb5d9550e976cd03c2b        
CIRRUS_CHANGE_MESSAGE          Update cypress to 4.0.2                         
CIRRUS_CI                      true                                            
CIRRUS_COMMIT_MESSAGE          Update cypress to 4.0.2                         
CIRRUS_DEFAULT_BRANCH          master                                          
CIRRUS_HTTP_CACHE_HOST         127.0.0.1:12321                                 
CIRRUS_LAST_GREEN_BUILD_ID     5408077868433408                                
CIRRUS_LAST_GREEN_CHANGE       cbd393ec682ee766e08b2293f30789fb6b9599c1        
CIRRUS_OS                      windows                                         
CIRRUS_PR                      137                                             
CIRRUS_REPO_CLONE_HOST         github.com                                      
CIRRUS_TASK_ID                 4793635753426944                                
CIRRUS_TASK_NAME               windows_integration                             
CIRRUS_USER_COLLABORATOR       true                                            
CIRRUS_USER_PERMISSION         admin                                           
CIRRUS_WORKING_DIR             C:/Users/ContainerAdministrator/AppData/Local...
CommonProgramFiles             C:\Program Files\Common Files                   
CommonProgramFiles(x86)        C:\Program Files (x86)\Common Files             
CommonProgramW6432             C:\Program Files\Common Files                   
COMPUTERNAME                   A0E8E3EBC1F8                                    
ComSpec                        C:\Windows\system32\cmd.exe                     
CONTINUOUS_INTEGRATION         true                                            
CYPRESS_CACHE_FOLDER           C:\Users\ContainerAdministrator\AppData\Local   
DEBUG                          cypress*                                        
DriverData                     C:\Windows\System32\Drivers\DriverData          
GITHUB_CHECK_SUITE_ID          481652802                                       
LANG                           en_US.UTF-8                                     
LOCALAPPDATA                   C:\Users\ContainerAdministrator\AppData\Local   
NUMBER_OF_PROCESSORS           2                                               
OriginalArchitecture           AMD64                                           
OriginalUserName               ContainerAdministrator                          
OS                             Windows_NT                                      
Path                           C:\Windows\system32;C:\Windows;C:\Windows\Sys...
Path_HKCU                      C:\Users\ContainerAdministrator\AppData\Local...
Path_HKLM                      C:\Windows\system32;C:\Windows;C:\Windows\Sys...
PATHEXT                        .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;....
PROCESSOR_ARCHITECTURE         AMD64                                           
PROCESSOR_IDENTIFIER           Intel64 Family 6 Model 63 Stepping 0, Genuine...
PROCESSOR_LEVEL                6                                               
PROCESSOR_REVISION             3f00                                            
ProgramData                    C:\ProgramData                                  
ProgramFiles                   C:\Program Files                                
ProgramFiles(x86)              C:\Program Files (x86)                          
ProgramW6432                   C:\Program Files                                
PROMPT                         $P$G                                            
PSModulePath                   C:\Users\ContainerAdministrator\Documents\Win...
PUBLIC                         C:\Users\Public                                 
SystemDrive                    C:                                              
SystemRoot                     C:\Windows                                      
TEMP                           C:\Users\ContainerAdministrator\AppData\Local...
TERM                           xterm-256color                                  
TMP                            C:\Users\ContainerAdministrator\AppData\Local...
USERDOMAIN                     User Manager                                    
USERNAME                       ContainerAdministrator                          
USERPROFILE                    C:\Users\ContainerAdministrator                 
windir                         C:\Windows                                      
<Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><Obj S="progress" RefId="0"><TN RefId="0"><T>System.Management.Automation.PSCustomObject</T><T>System.Object</T></TN><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj><Obj S="progress" RefId="1"><TNRef RefId="0" /><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj></Objs>#< CLIXML
    Directory: C:\Users\ContainerAdministrator\AppData\Local
Mode                LastWriteTime         Length Name                          
----                -------------         ------ ----                          
-a----        2/25/2020  10:24 PM              0 example.txt                   
<Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><Obj S="progress" RefId="0"><TN RefId="0"><T>System.Management.Automation.PSCustomObject</T><T>System.Object</T></TN><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj></Objs>
> [email protected] cy:bzl:ci-windows C:\Users\ContainerAdministrator\AppData\Local\Temp\cirrus-ci-build
> start-server-and-test bzl-serve-windows http://localhost:8080 cy:bzl:run
starting server using command "npm run bzl-serve-windows"
and when url "[ 'http://localhost:8080' ]" is responding
running tests using command "npm run cy:bzl:run"
> [email protected] bzl-serve-windows C:\Users\ContainerAdministrator\AppData\Local\Temp\cirrus-ci-build
> bzl.exe serve
time="2020-02-25T22:24:35Z" level=info msg="Ready at http://127.0.0.1:8080"
> [email protected] cy:bzl:run C:\Users\ContainerAdministrator\AppData\Local\Temp\cirrus-ci-build
> cypress run --spec 'cypress/integration/bzl/*.spec.js' --config baseUrl=http://localhost:8080 --reporter junit --reporter-options 'mochaFile=cypress/results/[hash].xml,toConsole=true'
2020-02-25T22:24:38.501Z cypress:cli:cli cli starts with arguments ["C:\\Program Files\\nodejs\\node.exe","C:\\Users\\ContainerAdministrator\\AppData\\Local\\Temp\\cirrus-ci-build\\node_modules\\cypress\\bin\\cypress","run","--spec","'cypress/integration/bzl/*.spec.js'","--config","baseUrl=http://localhost:8080","--reporter","junit","--reporter-options","'mochaFile=cypress/results/[hash].xml,toConsole=true'"]
2020-02-25T22:24:38.503Z cypress:cli NODE_OPTIONS is not set
2020-02-25T22:24:38.503Z cypress:cli:cli program parsing arguments
2020-02-25T22:24:38.509Z cypress:cli:cli running Cypress with args [ Command { commands: [], options: [ [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option] ], _execs: Set(0) {}, _allowUnknownOption: false, _args: [], _name: 'run', _optionValues: {}, _storeOptionsAsProperties: true, _passCommandToAction: true, _actionResults: [], _helpFlags: '-h, --help', _helpDescription: 'output usage information', _helpShortFlag: '-h', _helpLongFlag: '--help', _noHelp: false, _exitCallback: undefined, _executableFile: undefined, parent: Command { commands: [Array], options: [Array], _execs: Set(0) {}, _allowUnknownOption: false, _args: [], _name: 'cypress', _optionValues: {}, _storeOptionsAsProperties: true, _passCommandToAction: true, _actionResults: [], _helpFlags: '-h, --help', _helpDescription: 'output usage information', _helpShortFlag: '-h', _helpLongFlag: '--help', _usage: '<command> [options]', _events: [Object: null prototype], _eventsCount: 8, rawArgs: [Array], args: [] }, _usage: '[options]', _description: 'Runs Cypress tests from the CLI without the GUI', _argsDescription: undefined, _events: [Object: null prototype] { 'option:browser': [Function (anonymous)], 'option:ci-build-id': [Function (anonymous)], 'option:config': [Function (anonymous)], 'option:config-file': [Function (anonymous)], 'option:env': [Function (anonymous)], 'option:group': [Function (anonymous)], 'option:key': [Function (anonymous)], 'option:headed': [Function (anonymous)], 'option:headless': [Function (anonymous)], 'option:no-exit': [Function (anonymous)], 'option:parallel': [Function (anonymous)], 'option:port': [Function (anonymous)], 'option:project': [Function (anonymous)], 'option:record': [Function (anonymous)], 'option:reporter': [Function (anonymous)], 'option:reporter-options': [Function (anonymous)], 'option:spec': [Function (anonymous)], 'option:tag': [Function (anonymous)], 'option:dev': [Function (anonymous)] }, _eventsCount: 19, exit: true, spec: "'cypress/integration/bzl/*.spec.js'", config: 'baseUrl=http://localhost:8080', reporter: 'junit', reporterOptions: "'mochaFile=cypress/results/[hash].xml,toConsole=true'" } ]
2020-02-25T22:24:38.939Z cypress:cli:cli variable-length opts parsed { args: [ 'C:\\Program Files\\nodejs\\node.exe', 'C:\\Users\\ContainerAdministrator\\AppData\\Local\\Temp\\cirrus-ci-build\\node_modules\\cypress\\bin\\cypress', 'run', '--spec', "'cypress/integration/bzl/*.spec.js'", '--config', 'baseUrl=http://localhost:8080', '--reporter', 'junit', '--reporter-options', "'mochaFile=cypress/results/[hash].xml,toConsole=true'" ], opts: Command { commands: [], options: [ [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option] ], _execs: Set(0) {}, _allowUnknownOption: false, _args: [], _name: 'run', _optionValues: {}, _storeOptionsAsProperties: true, _passCommandToAction: true, _actionResults: [], _helpFlags: '-h, --help', _helpDescription: 'output usage information', _helpShortFlag: '-h', _helpLongFlag: '--help', _noHelp: false, _exitCallback: undefined, _executableFile: undefined, parent: Command { commands: [Array], options: [Array], _execs: Set(0) {}, _allowUnknownOption: false, _args: [], _name: 'cypress', _optionValues: {}, _storeOptionsAsProperties: true, _passCommandToAction: true, _actionResults: [], _helpFlags: '-h, --help', _helpDescription: 'output usage information', _helpShortFlag: '-h', _helpLongFlag: '--help', _usage: '<command> [options]', _events: [Object: null prototype], _eventsCount: 8, rawArgs: [Array], args: [] }, _usage: '[options]', _description: 'Runs Cypress tests from the CLI without the GUI', _argsDescription: undefined, _events: [Object: null prototype] { 'option:browser': [Function (anonymous)], 'option:ci-build-id': [Function (anonymous)], 'option:config': [Function (anonymous)], 'option:config-file': [Function (anonymous)], 'option:env': [Function (anonymous)], 'option:group': [Function (anonymous)], 'option:key': [Function (anonymous)], 'option:headed': [Function (anonymous)], 'option:headless': [Function (anonymous)], 'option:no-exit': [Function (anonymous)], 'option:parallel': [Function (anonymous)], 'option:port': [Function (anonymous)], 'option:project': [Function (anonymous)], 'option:record': [Function (anonymous)], 'option:reporter': [Function (anonymous)], 'option:reporter-options': [Function (anonymous)], 'option:spec': [Function (anonymous)], 'option:tag': [Function (anonymous)], 'option:dev': [Function (anonymous)] }, _eventsCount: 19, exit: true, spec: "'cypress/integration/bzl/*.spec.js'", config: 'baseUrl=http://localhost:8080', reporter: 'junit', reporterOptions: "'mochaFile=cypress/results/[hash].xml,toConsole=true'" } }
2020-02-25T22:24:38.942Z cypress:cli parsed cli options { config: 'baseUrl=http://localhost:8080', reporter: 'junit', reporterOptions: "'mochaFile=cypress/results/[hash].xml,toConsole=true'", spec: "'cypress/integration/bzl/*.spec.js'" }
2020-02-25T22:24:38.943Z cypress:cli verifying Cypress app
2020-02-25T22:24:38.944Z cypress:cli Using CYPRESS_CACHE_FOLDER from environment variable
2020-02-25T22:24:38.945Z cypress:cli Using CYPRESS_CACHE_FOLDER from environment variable
2020-02-25T22:24:38.945Z cypress:cli using environment variable CYPRESS_CACHE_FOLDER C:\Users\ContainerAdministrator\AppData\Local
2020-02-25T22:24:38.945Z cypress:cli checking environment variables
2020-02-25T22:24:38.950Z cypress:cli checking if executable exists C:\Users\ContainerAdministrator\AppData\Local\4.0.2\Cypress\Cypress.exe
2020-02-25T22:24:38.953Z cypress:cli Binary is executable? : true
2020-02-25T22:24:38.954Z cypress:cli binaryDir is  C:\Users\ContainerAdministrator\AppData\Local\4.0.2\Cypress
2020-02-25T22:24:38.954Z cypress:cli Reading binary package.json from: C:\Users\ContainerAdministrator\AppData\Local\4.0.2\Cypress\resources\app\package.json
2020-02-25T22:24:38.977Z cypress:cli Found binary version 4.0.2 installed in: C:\Users\ContainerAdministrator\AppData\Local\4.0.2\Cypress
2020-02-25T22:24:38.979Z cypress:cli could not read binary_state.json file at "C:\Users\ContainerAdministrator\AppData\Local\4.0.2\binary_state.json"
2020-02-25T22:24:38.980Z cypress:cli {}
2020-02-25T22:24:38.980Z cypress:cli is Verified ? undefined
2020-02-25T22:24:38.981Z cypress:cli running binary verification check 4.0.2
It looks like this is your first time using Cypress: 4.0.2
[22:24:38]  Verifying Cypress can run C:\Users\ContainerAdministrator\AppData\Local\4.0.2\Cypress [started]
2020-02-25T22:24:38.993Z cypress:cli clearing out the verified version
2020-02-25T22:24:39.004Z cypress:cli needs Xvfb? false
2020-02-25T22:24:39.004Z cypress:cli spawning, should retry on display problem? false
2020-02-25T22:24:39.005Z cypress:cli running smoke test
2020-02-25T22:24:39.005Z cypress:cli using Cypress executable C:\Users\ContainerAdministrator\AppData\Local\4.0.2\Cypress\Cypress.exe
2020-02-25T22:24:39.005Z cypress:cli smoke test command: C:\Users\ContainerAdministrator\AppData\Local\4.0.2\Cypress\Cypress.exe --smoke-test --ping=68
2020-02-25T22:24:39.006Z cypress:cli smoke test timeout 30000 ms
2020-02-25T22:24:39.891Z cypress:cli Smoke test failed: Error: Command failed with exit code 3221225781: C:\Users\ContainerAdministrator\AppData\Local\4.0.2\Cypress\Cypress.exe --smoke-test --ping=68
    at makeError (C:\Users\ContainerAdministrator\AppData\Local\Temp\cirrus-ci-build\node_modules\execa\lib\error.js:56:11)
    at handlePromise (C:\Users\ContainerAdministrator\AppData\Local\Temp\cirrus-ci-build\node_modules\execa\index.js:114:26)
    at processTicksAndRejections (internal/process/task_queues.js:97:5) {
  command: 'C:\\Users\\ContainerAdministrator\\AppData\\Local\\4.0.2\\Cypress\\Cypress.exe --smoke-test --ping=68',
  exitCode: 3221225781,
  signal: undefined,
  signalDescription: undefined,
  stdout: '',
  stderr: '',
  failed: true,
  timedOut: false,
  isCanceled: false,
  killed: false
}
2020-02-25T22:24:39.892Z cypress:cli error message: Command failed with exit code 3221225781: C:\Users\ContainerAdministrator\AppData\Local\4.0.2\Cypress\Cypress.exe --smoke-test --ping=68
[22:24:39]  Verifying Cypress can run C:\Users\ContainerAdministrator\AppData\Local\4.0.2\Cypress [failed]
Cypress failed to start.
This is usually caused by a missing library or dependency.
The error below should indicate which dependency is missing.
https://on.cypress.io/required-dependencies
If you are using Docker, we provide containers with all required dependencies installed.
----------
Command failed with exit code 3221225781: C:\Users\ContainerAdministrator\AppData\Local\4.0.2\Cypress\Cypress.exe --smoke-test --ping=68
----------
Platform: win32 (10.0.17763)
Cypress Version: 4.0.2
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] cy:bzl:run: `cypress run --spec 'cypress/integration/bzl/*.spec.js' --config baseUrl=http://localhost:8080 --reporter junit --reporter-options 'mochaFile=cypress/results/[hash].xml,toConsole=true'`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] cy:bzl:run script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\ContainerAdministrator\AppData\Roaming\npm-cache\_logs\2020-02-25T22_24_39_929Z-debug.log
Error: Command failed with ENOENT: npm run cy:bzl:run
spawn npm run cy:bzl:run ENOENT
    at notFoundError (C:\Users\ContainerAdministrator\AppData\Local\Temp\cirrus-ci-build\node_modules\cross-spawn\lib\enoent.js:6:26)
    at verifyENOENT (C:\Users\ContainerAdministrator\AppData\Local\Temp\cirrus-ci-build\node_modules\cross-spawn\lib\enoent.js:40:16)
    at ChildProcess.cp.emit (C:\Users\ContainerAdministrator\AppData\Local\Temp\cirrus-ci-build\node_modules\cross-spawn\lib\enoent.js:27:25)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12) {
  code: 'ENOENT',
  errno: 'ENOENT',
  syscall: 'spawn npm run cy:bzl:run',
  path: 'npm run cy:bzl:run',
  spawnargs: [],
  originalMessage: 'spawn npm run cy:bzl:run ENOENT',
  shortMessage: 'Command failed with ENOENT: npm run cy:bzl:run\n' +
    'spawn npm run cy:bzl:run ENOENT',
  command: 'npm run cy:bzl:run',
  exitCode: undefined,
  signal: undefined,
  signalDescription: undefined,
  stdout: undefined,
  stderr: undefined,
  failed: true,
  timedOut: false,
  isCanceled: false,
  killed: false
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] cy:bzl:ci-windows: `start-server-and-test bzl-serve-windows http://localhost:8080 cy:bzl:run`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] cy:bzl:ci-windows script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\ContainerAdministrator\AppData\Roaming\npm-cache\_logs\2020-02-25T22_24_43_370Z-debug.log

Possibly related issue: cypress-io/cypress-example-recipes#327

@vyadh
Copy link

vyadh commented Mar 11, 2020

I managed to get cypress working in a Windows Container image, but it wasn't trivial. Cypress was crashing similar to cypress-io/cypress#4625 with the same error number.

Some debugging using procmon.exe indicated it was because the Windows Server Core Docker image I was using was missing the DirectX libraries. It's not clear how to install those, so I tried the full "windows" container image (1903 here) that contains these DLLs and this worked.

I haven't tried to copy the required libs to the servercore (or even nanoserver) image, which would be far more preferable given the huge size of the windows image.

@david-martyn-ford
Copy link

I managed to get cypress working in a Windows Container image, but it wasn't trivial. Cypress was crashing similar to cypress-io/cypress#4625 with the same error number.

Some debugging using procmon.exe indicated it was because the Windows Server Core Docker image I was using was missing the DirectX libraries. It's not clear how to install those, so I tried the full "windows" container image (1903 here) that contains these DLLs and this worked.

I haven't tried to copy the required libs to the servercore (or even nanoserver) image, which would be far more preferable given the huge size of the windows image.

Could you share your dockerfile that works? This is a last resort before I switch to linux containers.

@vyadh
Copy link

vyadh commented Mar 19, 2020

I was planning to raise a PR when I've simplified it - our own Dockerfile is much complicated by the fact that it requires accessing things from internal servers with secrets and multi-step builds. I started simplifying last night, and lots of things work, even video capture, but I've not run a fully successful test with it yet for reasons that aren't clear to me. I'll create a PR with what I have today and maybe refine from there.

@vyadh
Copy link

vyadh commented Mar 19, 2020

So I was going to create a PR for this I've decided against it as it's a little different from the other Dockerfiles and might not be appropriate (happy to do this if the maintainers here feel it's worth it). It's different partly because it's Windows, but partly because I wanted to avoid users having to download the cypress ZIP every time people use it in their app - it takes a while to install and but the main reason is that this will never work through our proxy. So I've installed cypress globally... Not sure how much of a problem that is!

Trigger warning - the resulting image is absolutely huge.

I tried to get it working against a couple of the Cypress examples but the tests never complete, so there may still be issues with it. Would love to know if anyone gets this working - not sure my users have tried it yet.

# Cypress Docker image.
#
# Uses full 'windows' base image due to Cypress requiring DirectX DLLs.
#
# Example build arguments with explicit versions:
#   docker build --build-arg WIN_VERSION=1809 --build-arg GIT_VERSION=2.25.1 --build-arg NODEJS_VERSION=12.16.1 --build-arg CYPRESS_VERSION=4.2.0 -t cypress .
#
# The versions of nodejs and cypress can be 'latest'.
#
# Example running the image and mapping test code from a local directory:
#   docker run --rm -v c:\dev\my-test-project:c:\cypress --env CYPRESS_BASE_URL=http://app:7071 cypress
# Where 'app' is another container running via 'docker run --name app'

ARG WIN_VERSION=1809
ARG WIN_IMAGE=mcr.microsoft.com/windows:$WIN_VERSION

FROM $WIN_IMAGE AS install

ARG GIT_VERSION=2.25.1
ARG NODEJS_VERSION=12.16.1
ARG CYPRESS_VERSION=4.2.0

ARG GIT_URL=https://github.com/git-for-windows/git/releases/download/v${GIT_VERSION}.windows.1/MinGit-${GIT_VERSION}-busybox-64-bit.zip
ARG NODEJS_URL=https://nodejs.org/dist/v${NODEJS_VERSION}/node-v${NODEJS_VERSION}-win-x64.zip

USER ContainerAdministrator
ARG SETX=/M
RUN setx %SETX% PATH "%PATH%;c:\nodejs;c:\git\cmd;c:\git\mingw64\bin;c:\git\usr\bin"
USER ContainerUser

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

# Install Git
RUN mkdir c:\download | Out-Null; \
    curl.exe --fail --location "$env:GIT_URL" -o /download/git.zip; \
    Expand-Archive /download/git.zip -DestinationPath c:\git; \
    rm /download/git.zip

# Install NodeJS
RUN curl.exe --fail "$env:NODEJS_URL" -o /download/nodejs.zip; \
    Expand-Archive 'c:\download\nodejs.zip' -DestinationPath 'c:\'; \
    mv /node-v$env:NODEJS_VERSION-win-x64 /nodejs; \
    rm /download/nodejs.zip

# Install Cypress
ENV CI=1
RUN npm install cypress@$CYPRESS_VERSION --save-dev --global

# Run Cypress to ensure working and to do first run optimisation
ENV CYPRESS_CRASH_REPORTS=0
WORKDIR /cypress
RUN Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Bypass -Force
RUN cypress verify

# Show versions of local tools
RUN echo "\"node version:    $(node -v)\"" ; \
  echo "\"npm version:     $(npm -v | Out-String)\""; \
  echo "\"cypress version: $(cypress -v | Out-String)\""; \
  echo "\"git version:     $(git version | Out-String)\""; \
  echo "\"windows version: $(cmd /s /c ver | Out-String)\""; \
  echo "\"user:            $env:USERNAME\""

CMD ["cypress.cmd", "run"]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants