-
Notifications
You must be signed in to change notification settings - Fork 380
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
Comments
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"
Possibly related issue: cypress-io/cypress-example-recipes#327 |
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. |
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. |
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"] |
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
The text was updated successfully, but these errors were encountered: