Skip to content

Instantly share code, notes, and snippets.

@dangtrinhnt
Created April 5, 2021 15:14
Show Gist options
  • Save dangtrinhnt/d1fd0d0b9dd4f22280061c6c33dbb839 to your computer and use it in GitHub Desktop.
Save dangtrinhnt/d1fd0d0b9dd4f22280061c6c33dbb839 to your computer and use it in GitHub Desktop.
Running Selenium with Chromedriver inside Windows container
FROM mcr.microsoft.com/windows/servercore:ltsc2019
# install needed fonts for googlechrome to run properly
ADD files/fonts.tar /Fonts/
WORKDIR /Fonts/
RUN @powershell -NoProfile -ExecutionPolicy Bypass -Command ".\Add-Font.ps1 Fonts"
WORKDIR "C:/ProgramData"
# enable Web-WebSockets
RUN @powershell -NoProfile -ExecutionPolicy Bypass -Command "Add-WindowsFeature Web-WebSockets"
# install chocolately
RUN @powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin" -Y
# install openjdk8
RUN choco install openjdk8 -Y
# update environment variables
RUN refreshenv
# install googlechrome
RUN choco install googlechrome -Y
# copy your application to the WORKDIR
ADD files/myapplication.war "C:/ProgramData"
# copy chromedriver.exe to the same level of your application
# assumming your application
ADD files/drivers/chromedriver.exe "C:/ProgramData/drivers"
EXPOSE 8080
# run your application
CMD ["java", "-jar", "C:/ProgramData/myapplication.war"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment