Skip to content

Commit 3ba850f

Browse files
committed
Fix Chrome beta support for NodeChrome
The Dockerfile says Chrome beta is supported: > can specify versions by CHROME_VERSION; > e.g. google-chrome-stable=53.0.2785.101-1 > google-chrome-beta=53.0.2785.92-1 But when actually building an image with e.g. `--build-arg CHROME_VERSION=google-chrome-beta=62.0.3202.29-1`, then a couple of problems appear. Firstly, the version field in `/opt/selenium/config.json` will not be populated, because `/opt/google/chrome/chrome` does not exist. Secondly and even more importantly, the node simply won't work. I assume it's because `chrome_launcher.sh` tries to execute the nonexistent `/opt/google/chrome/chrome`, but I haven't confirmed for sure. This change fixes both of those issues by actually wrapping the existing executable, instead of replacing it. I have locally tested it by with latest versions (not specifying any build arguments) and with the latest Chrome beta version. Both work. As can be seen from current [Chromium source][1], the wrapping code that was used in chrome_launcher.sh has changed considerably. This change avoids duplicating that code here and so makes it impossible for this to get out of date. In addition, this will work with different Chrome versions which might have different code in the wrapper. [1]: https://cs.chromium.org/chromium/src/chrome/installer/linux/common/wrapper
1 parent 3fb76ba commit 3ba850f

File tree

4 files changed

+20
-93
lines changed

4 files changed

+20
-93
lines changed

NodeChrome/Dockerfile.txt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key
1919
&& rm /etc/apt/sources.list.d/google-chrome.list \
2020
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/*
2121

22+
#=================================
23+
# Chrome Launch Script Wrapper
24+
#=================================
25+
COPY wrap_chrome_binary /opt/bin/wrap_chrome_binary
26+
RUN /opt/bin/wrap_chrome_binary
27+
2228
USER seluser
2329

2430
#============================================
@@ -40,10 +46,5 @@ RUN CD_VERSION=$(if [ ${CHROME_DRIVER_VERSION:-latest} = "latest" ]; then echo $
4046

4147
COPY generate_config /opt/bin/generate_config
4248

43-
#=================================
44-
# Chrome Launch Script Modification
45-
#=================================
46-
COPY chrome_launcher.sh /opt/google/chrome/google-chrome
47-
4849
# Generating a default config during build time
4950
RUN /opt/bin/generate_config > /opt/selenium/config.json

NodeChrome/chrome_launcher.sh

Lines changed: 0 additions & 87 deletions
This file was deleted.

NodeChrome/generate_config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
CHROME_VERSION=$(/opt/google/chrome/chrome -version | awk '{ print $3 }')
3+
CHROME_VERSION=$(/usr/bin/google-chrome -version | awk '{ print $3 }')
44

55
cat <<_EOF
66
{

NodeChrome/wrap_chrome_binary

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
WRAPPER_PATH=$(readlink -f /usr/bin/google-chrome)
4+
BASE_PATH="$WRAPPER_PATH-base"
5+
mv "$WRAPPER_PATH" "$BASE_PATH"
6+
7+
cat > "$WRAPPER_PATH" <<_EOF
8+
#!/bin/bash
9+
10+
# Note: exec -a below is a bashism.
11+
exec -a "\$0" "$BASE_PATH" --no-sandbox "\$@"
12+
_EOF
13+
chmod +x "$WRAPPER_PATH"

0 commit comments

Comments
 (0)