upd
This commit is contained in:
@@ -1,2 +1,2 @@
|
||||
go build && ./images chrome -b 101.0.4951.64-1 -t chrome_patched:101.0
|
||||
go build && ./images chrome -b 119.0.6045.159-1 -d 119.0.6045.159 -t yessirwhatever/selenoid-image-chromedriver-patched:119.0
|
||||
|
||||
|
||||
+27
-4
@@ -1,15 +1,17 @@
|
||||
package build
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
const (
|
||||
chromeDriverBinary = "chromedriver"
|
||||
chromeDriverBinary = "chromedriver-linux64/chromedriver"
|
||||
)
|
||||
|
||||
type Chrome struct {
|
||||
@@ -25,7 +27,7 @@ func (c *Chrome) Build() error {
|
||||
|
||||
pkgTagVersion := extractVersion(pkgVersion)
|
||||
|
||||
driverVersion, err := c.parseChromeDriverVersion(pkgTagVersion)
|
||||
driverVersion := c.DriverVersion
|
||||
if err != nil {
|
||||
return fmt.Errorf("parse chromedriver version: %v", err)
|
||||
}
|
||||
@@ -120,7 +122,7 @@ func (c *Chrome) channelToBuildArgs() []string {
|
||||
func (c *Chrome) parseChromeDriverVersion(pkgVersion string) (string, error) {
|
||||
version := c.DriverVersion
|
||||
if version == LatestVersion {
|
||||
const baseUrl = "https://chromedriver.storage.googleapis.com/"
|
||||
const baseUrl = "https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json"
|
||||
v, err := c.getLatestChromeDriver(baseUrl, pkgVersion)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -131,7 +133,7 @@ func (c *Chrome) parseChromeDriverVersion(pkgVersion string) (string, error) {
|
||||
}
|
||||
|
||||
func (c *Chrome) downloadChromeDriver(dir string, version string) error {
|
||||
u := fmt.Sprintf("http://chromedriver.storage.googleapis.com/%s/chromedriver_linux64.zip", version)
|
||||
u := fmt.Sprintf("https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/%s/linux64/chromedriver-linux64.zip", version)
|
||||
_, err := downloadDriver(u, chromeDriverBinary, dir)
|
||||
if err != nil {
|
||||
return fmt.Errorf("download chromedriver: %v", err)
|
||||
@@ -139,8 +141,29 @@ func (c *Chrome) downloadChromeDriver(dir string, version string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
type ChromeDrivers struct {
|
||||
DriverVersions []struct {
|
||||
version string `json:"version"`
|
||||
} `json:"versions"`
|
||||
}
|
||||
|
||||
func (c *Chrome) getLatestChromeDriver(baseUrl string, pkgVersion string) (string, error) {
|
||||
data, err := sendGet(baseUrl)
|
||||
var chromeDrivers ChromeDrivers
|
||||
|
||||
// Parsing/Unmarshaling JSON data into person
|
||||
jsonerr := json.Unmarshal(data, &chromeDrivers)
|
||||
if jsonerr != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
// lastVersion := chromeDrivers.DriverVersions[len(chromeDrivers.DriverVersions)-1].version
|
||||
|
||||
// foundVersion := false
|
||||
// for _, driverVersion := range chromeDrivers.DriverVersions {
|
||||
// if driverVersion.version == pkgVersion {}
|
||||
// }
|
||||
fetchVersion := func(url string) (string, error) {
|
||||
|
||||
data, err := sendGet(url)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("read chromedriver version: %v", err)
|
||||
|
||||
@@ -15,7 +15,7 @@ FROM selenoid/dev_chrome:$VERSION
|
||||
|
||||
ENV DBUS_SESSION_BUS_ADDRESS=/dev/null
|
||||
COPY --from=go /devtools/devtools /usr/bin/
|
||||
COPY chromedriver /usr/bin/
|
||||
COPY chromedriver-linux64/chromedriver /usr/bin/
|
||||
COPY entrypoint.sh /
|
||||
|
||||
RUN chmod +x /usr/bin/chromedriver
|
||||
|
||||
Reference in New Issue
Block a user