Skip to content

Instantly share code, notes, and snippets.

@Meir017
Last active October 14, 2023 18:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Meir017/88460c660c04898c1e27333a94fb9d22 to your computer and use it in GitHub Desktop.
Save Meir017/88460c660c04898c1e27333a94fb9d22 to your computer and use it in GitHub Desktop.
For ID
function download-docker-image {
param(
[Parameter(Mandatory=$true)]
[string]$image,
[Parameter(Mandatory=$true)]
[string]$tag,
[Parameter(Mandatory=$true)]
[string]$output
)
$imageWithTag = "$($image):$($tag)"
$outputFile = "$($output)-$($tag).tar"
if (Test-Path $outputFile) {
Write-Host "Skipping save of " -NoNewline
Write-Host $imageWithTag -ForegroundColor Yellow -NoNewline
Write-Host " to " -NoNewline
Write-Host $outputFile -ForegroundColor Yellow -NoNewline
Write-Host "file already exists."
return
}
Write-Host "Downloading " -NoNewline
Write-Host $imageWithTag -ForegroundColor Cyan -NoNewline
Write-Host " to " -NoNewline
Write-Host $outputFile -ForegroundColor Cyan
$StartTime = Get-Date
do {
docker pull $imageWithTag
} until (
$LASTEXITCODE -eq 0
)
$EndTime = Get-Date
$TimeTaken = New-TimeSpan -Start $StartTime -End $EndTime
Write-Host "Pulled $imageWithTag in $TimeTaken" -ForegroundColor Green
$StartTime = Get-Date
if (!(Test-Path $outputFile)) {
docker save --output $outputFile $imageWithTag
$EndTime = Get-Date
$TimeTaken = New-TimeSpan -Start $StartTime -End $EndTime
Write-Host "Saved $imageWithTag to $outputFile in $TimeTaken" -ForegroundColor Green
} else {
Write-Host "Skipping save of " -NoNewline
Write-Host $imageWithTag -ForegroundColor Yellow -NoNewline
Write-Host " to " -NoNewline
Write-Host $outputFile -ForegroundColor Yellow
}
}
$DotnetVersions = @(
"v1.20.2"
"v1.20.2-focal",
"v1.21.0",
"v1.21.0-focal",
"v1.22.0",
"v1.22.0-focal",
"v1.23.0",
"v1.23.0-focal",
"v1.24.1",
"v1.24.1-focal",
"v1.25.0",
"v1.25.0-focal",
"v1.26.0",
"v1.26.0-focal",
"v1.27.2",
"v1.27.2-focal",
"v1.28.0",
"v1.28.0-focal",
"v1.29.0",
"v1.29.0-focal",
"v1.30.0",
"v1.30.0-focal",
"v1.31.1",
"v1.31.1-focal",
"v1.32.0",
"v1.32.0-jammy",
"v1.32.0-focal",
"v1.33.0",
"v1.33.0-jammy",
"v1.33.0-focal",
"v1.34.0",
"v1.34.0-jammy",
"v1.34.0-focal",
"v1.35.0",
"v1.35.0-jammy",
"v1.35.0-focal",
"v1.36.0",
"v1.36.0-jammy",
"v1.36.0-focal",
"v1.37.1",
"v1.37.1-jammy",
"v1.37.1-focal",
"v1.38.0",
"v1.38.0-jammy",
"v1.38.0-focal"
)
$NodejsVersions = @(
"v1.16.3",
"v1.16.3-bionic",
"v1.16.3-focal",
"v1.17.2",
"v1.17.2-bionic",
"v1.17.2-focal",
"v1.18.1",
"v1.18.1-bionic",
"v1.18.1-focal",
"v1.19.2",
"v1.19.2-bionic",
"v1.19.2-focal",
"v1.20.2",
"v1.20.2-bionic",
"v1.20.2-focal",
"v1.21.1",
"v1.21.1-bionic",
"v1.21.1-focal",
"v1.22.2",
"v1.22.2-bionic",
"v1.22.2-focal",
"v1.23.4",
"v1.23.4-bionic",
"v1.23.4-focal",
"v1.23.4-jammy",
"v1.24.2",
"v1.24.2-bionic",
"v1.24.2-focal",
"v1.24.2-jammy",
"v1.25.2",
"v1.25.2-bionic",
"v1.25.2-focal",
"v1.25.2-jammy",
"v1.26.1",
"v1.26.1-bionic",
"v1.26.1-focal",
"v1.26.1-jammy",
"v1.27.1",
"v1.27.1-bionic",
"v1.27.1-focal",
"v1.27.1-jammy",
"v1.28.1",
"v1.28.1-bionic",
"v1.28.1-focal",
"v1.28.1-jammy",
"v1.29.2",
"v1.29.2-focal",
"v1.29.2-jammy",
"v1.29.2-vrt",
"v1.30.0",
"v1.30.0-focal",
"v1.30.0-jammy",
"v1.30.0-vrt",
"v1.31.2",
"v1.31.2-focal",
"v1.31.2-jammy",
"v1.32.3",
"v1.32.3-focal",
"v1.32.3-jammy",
"v1.33.0",
"v1.33.0-focal",
"v1.33.0-jammy",
"v1.34.3",
"v1.34.3-focal",
"v1.34.3-jammy",
"v1.35.1",
"v1.35.1-focal",
"v1.35.1-jammy",
"v1.36.2",
"v1.36.2-focal",
"v1.36.2-jammy",
"v1.37.1",
"v1.37.1-focal",
"v1.37.1-jammy",
"v1.38.1",
"v1.38.1-focal",
"v1.38.1-jammy",
"v1.39.0",
"v1.39.0-focal",
"v1.39.0-jammy"
)
$SeleniumNodeChromeVersions = @(
'117.0',
'116.0',
'115.0',
'114.0',
'113.0',
'112.0',
'111.0',
'110.0',
'109.0',
'108.0',
'107.0',
'106.0',
'105.0',
'104.0',
'103.0',
'102.0',
'101.0',
'100.0',
'99.0',
'98.0',
'97.0'
)
$SeleniumHubVersions = @(
'4.1.2-20220131', # chrome 97.0
'4.1.2-20220217', # chrome 98.0
'4.1.3-20220327', # chrome 99.0
'4.1.3-20220405', # chrome 100.0
'4.1.4-20220427', # chrome 101.0
'4.2.2-20220609', # chrome 102.0
'4.3.0-20220726', # chrome 103.0
'4.4.0-20220812', # chrome 104.0
'4.4.0-20220831', # chrome 105.0
'4.5.3-20221024', # chrome 106.0
'4.6.0-20221104', # chrome 107.0
'4.7.2-20221219', # chrome 108.0
'4.8.0-20230202', # chrome 109.0
'4.8.1-20230306', # chrome 110.0
'4.8.3-20230404', # chrome 111.0
'4.9.0-20230421', # chrome 112.0
'4.9.1-20230508', # chrome 113.0
'4.10.0-20230614', # chrome 114.0
'4.11.0-20230801', # chrome 115.0
'4.12.1-20230912', # chrome 116.0
'4.13.0-20231004' # chrome 117.0
)
$versions = $NodejsVersions
$imageName = 'mcr.microsoft.com/playwright'
$outputName = 'playwright'
$items = @(
@{ imageName = 'mcr.microsoft.com/playwright/dotnet'; outputName = 'playwright-dotnet'; versions = $DotnetVersions },
@{ imageName = 'mcr.microsoft.com/playwright'; outputName = 'playwright'; versions = $NodejsVersions },
@{ imageName = 'selenium/node-chrome'; outputName = 'selenium-node-chrome'; versions = $SeleniumNodeChromeVersions },
@{ imageName = 'selenium/hub'; outputName = 'selenium-hub'; versions = $SeleniumHubVersions }
)
foreach ($item in $items) {
$imageName = $item.imageName
$outputName = $item.outputName
$versions = $item.versions
foreach ($version in $versions) {
download-docker-image -image $imageName -tag $version -output $outputName
}
}
Test-Path .\nuget.exe || Invoke-WebRequest -Uri https://dist.nuget.org/win-x86-commandline/latest/nuget.exe -OutFile .\nuget.exe
$versions = @(
'1.16.1',
'1.17.3',
'1.18.1',
'1.19.1',
'1.20.2',
'1.21.0',
'1.22.0',
'1.23.0',
'1.24.1',
'1.25.0',
'1.26.0',
'1.27.2',
'1.28.0',
'1.29.0',
'1.30.0',
'1.31.1',
'1.32.0',
'1.33.0',
'1.34.0',
'1.35.0',
'1.36.0',
'1.37.1',
'1.38.0'
)
Test-Path '.\nugets\' || New-Item -ItemType Directory -Path '.\nugets\
foreach ($version in $versions) {
.\nuget.exe install 'Microsoft.Playwright.MSTest' -Version $version -OutputDirectory .\nugets\ -Source 'https://api.nuget.org/v3/index.json'
}
FROM mcr.microsoft.com/dotnet/sdk:6.0-focal
ARG PLAYWRIGHT_VERSION
# === INSTALL dependencies ===
RUN apt-get update && \
# Feature-parity with node.js base images.
apt-get install -y --no-install-recommends git openssh-client curl && \
# clean apt cache
rm -rf /var/lib/apt/lists/* && \
# Create the pwuser
adduser pwuser
# === BAKE BROWSERS INTO IMAGE ===
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
# 1. Bake in browsers & deps.
# Browsers will be downloaded in `/ms-playwright`.
# Note: make sure to set 777 to the registry so that any user can access
# registry.
RUN mkdir /ms-playwright && \
mkdir /ms-playwright-agent && \
cd /ms-playwright-agent && \
dotnet new console && \
dotnet add package Microsoft.Playwright --version $PLAYWRIGHT_VERSION && \
dotnet build && \
pwsh ./bin/Debug/net6.0/playwright.ps1 install --with-deps && \
rm -rf /var/lib/apt/lists/* && \
rm -rf /tmp/* && \
rm -rf /ms-playwright-agent && \
chmod -R 777 /ms-playwright
@Meir017
Copy link
Author

Meir017 commented Oct 13, 2023

run the Playwright.Dotnet.dockerfile dockerfile using the following command:

docker build -t playwright-dotnet:1.16.1 -t playwright-dotnet:1.16.1-focal . --build-arg PLAYWRIGHT_VERSION=1.16.1

@Meir017
Copy link
Author

Meir017 commented Oct 14, 2023

node-chrome 97 tags:

  • 97.0
  • 97.0-20220131
  • 97.0-chromedriver-97.0
  • 97.0-chromedriver-97.0-20220131
  • 97.0-chromedriver-97.0-grid-4.1.2-20220131
  • 97.0.4692.99
  • 97.0.4692.99-20220131
  • 97.0.4692.99-chromedriver-97.0.4692.71
  • 97.0.4692.99-chromedriver-97.0.4692.71-20220131
  • 97.0.4692.99-chromedriver-97.0.4692.71-grid-4.1.2-20220131

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