From c8e095d074b80aad4141584665df5d45727b29f3 Mon Sep 17 00:00:00 2001 From: Guillaume Barry Date: Thu, 26 Oct 2023 22:06:55 +0200 Subject: [PATCH 01/10] #2422 Add support of arm64 for image karatelabs/karate-chrome --- build-docker.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/build-docker.sh b/build-docker.sh index 9b52511e1..49b82632a 100755 --- a/build-docker.sh +++ b/build-docker.sh @@ -23,7 +23,10 @@ cp karate-core/target/karate-${KARATE_VERSION}.jar karate-docker/karate-chrome/t # export DOCKER_DEFAULT_PLATFORM=linux/amd64 # build karate-chrome docker image that includes karate fatjar + maven jars for convenience -docker build -t karate-chrome karate-docker/karate-chrome +#docker build -t karate-chrome karate-docker/karate-chrome +docker buildx create --name multiplatform-builder +docker buildx use multiplatform-builder +docker buildx build --platform linux/amd64,linux/arm64 -t karate-chrome karate-docker/karate-chrome # just in case a previous run had hung (likely only in local dev) docker stop karate || true From d3b7e9773a52144d48f8e494402afd05157a955f Mon Sep 17 00:00:00 2001 From: Guillaume Barry Date: Thu, 26 Oct 2023 23:54:32 +0200 Subject: [PATCH 02/10] switch to chromium instead of chrome-stable --- karate-docker/karate-chrome/Dockerfile | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/karate-docker/karate-chrome/Dockerfile b/karate-docker/karate-chrome/Dockerfile index c613ab3ac..bd4bf7cba 100644 --- a/karate-docker/karate-chrome/Dockerfile +++ b/karate-docker/karate-chrome/Dockerfile @@ -7,10 +7,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ wget \ gnupg2 -RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \ - && echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list \ - && apt-get update && apt-get install -y --no-install-recommends \ - google-chrome-stable +RUN apt-get update && apt-get install -y --no-install-recommends \ + chromium-browser RUN useradd chrome --shell /bin/bash --create-home \ && usermod -a -G sudo chrome \ From 6782ae6d989ccf507d3db0c82fe78e45e95f0506 Mon Sep 17 00:00:00 2001 From: Guillaume Barry Date: Thu, 26 Oct 2023 23:57:08 +0200 Subject: [PATCH 03/10] switch to chromium --- karate-docker/karate-chrome/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/karate-docker/karate-chrome/Dockerfile b/karate-docker/karate-chrome/Dockerfile index bd4bf7cba..ee4d92678 100644 --- a/karate-docker/karate-chrome/Dockerfile +++ b/karate-docker/karate-chrome/Dockerfile @@ -8,7 +8,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ gnupg2 RUN apt-get update && apt-get install -y --no-install-recommends \ - chromium-browser + chromium RUN useradd chrome --shell /bin/bash --create-home \ && usermod -a -G sudo chrome \ From 3ac1e2346c0238e38b2c3724e4a56e4a89f9c372 Mon Sep 17 00:00:00 2001 From: Guillaume Barry Date: Fri, 27 Oct 2023 00:14:42 +0200 Subject: [PATCH 04/10] siwtch to chromium --- karate-docker/karate-chrome/supervisord.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/karate-docker/karate-chrome/supervisord.conf b/karate-docker/karate-chrome/supervisord.conf index 52c145a5c..bb700fd05 100644 --- a/karate-docker/karate-chrome/supervisord.conf +++ b/karate-docker/karate-chrome/supervisord.conf @@ -34,7 +34,7 @@ priority=300 [program:chrome] user=chrome environment=HOME="/home/chrome",USER="chrome",DISPLAY=":1",DBUS_SESSION_BUS_ADDRESS="unix:path=/dev/null" -command=/usr/bin/google-chrome +command=/usr/bin/chromium --user-data-dir=/home/chrome --no-first-run --disable-translate From aa5f76426a9ab21f7bec5492eff1b664980b5c1a Mon Sep 17 00:00:00 2001 From: Guillaume Barry Date: Fri, 27 Oct 2023 00:21:00 +0200 Subject: [PATCH 05/10] make multi platform build with first testing current one --- build-docker.sh | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/build-docker.sh b/build-docker.sh index 49b82632a..1bbe104a2 100755 --- a/build-docker.sh +++ b/build-docker.sh @@ -19,14 +19,13 @@ cp -r ~/.m2/repository/io/karatelabs ${KARATE_REPO} mvn package -B -ntp -P fatjar -DskipTests -f karate-core/pom.xml cp karate-core/target/karate-${KARATE_VERSION}.jar karate-docker/karate-chrome/target/karate.jar -# hack for apple silicon -# export DOCKER_DEFAULT_PLATFORM=linux/amd64 - -# build karate-chrome docker image that includes karate fatjar + maven jars for convenience -#docker build -t karate-chrome karate-docker/karate-chrome +# setup multiplatform build docker buildx create --name multiplatform-builder docker buildx use multiplatform-builder -docker buildx build --platform linux/amd64,linux/arm64 -t karate-chrome karate-docker/karate-chrome + +# build karate-chrome docker image that includes karate fatjar + maven jars for convenience +# build for current platform and push for local test +docker buildx build --load -t karate-chrome karate-docker/karate-chrome # just in case a previous run had hung (likely only in local dev) docker stop karate || true @@ -46,3 +45,7 @@ docker exec -w /karate karate mvn test -B -ntp -f karate-e2e-tests/pom.xml -Dtes docker stop karate wait + +# finish multiplatform build adding missing platform as test is working +docker buildx build --platform linux/amd64,linux/arm64 -t karate-chrome karate-docker/karate-chrome +# -> still to check how to push to final repo From 64042c69681d3cd12d6c73103fc85c3d0d1e2777 Mon Sep 17 00:00:00 2001 From: Guillaume Barry Date: Wed, 1 Nov 2023 12:51:47 +0100 Subject: [PATCH 06/10] #2422 revert to chrome --- karate-docker/karate-chrome/Dockerfile | 2 +- karate-docker/karate-chrome/supervisord.conf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/karate-docker/karate-chrome/Dockerfile b/karate-docker/karate-chrome/Dockerfile index ee4d92678..2840b3377 100644 --- a/karate-docker/karate-chrome/Dockerfile +++ b/karate-docker/karate-chrome/Dockerfile @@ -18,7 +18,7 @@ RUN useradd chrome --shell /bin/bash --create-home \ RUN apt-get install -y --no-install-recommends \ xvfb \ x11vnc \ - xterm \ + xterm \ fluxbox \ wmctrl \ supervisor \ diff --git a/karate-docker/karate-chrome/supervisord.conf b/karate-docker/karate-chrome/supervisord.conf index bb700fd05..52c145a5c 100644 --- a/karate-docker/karate-chrome/supervisord.conf +++ b/karate-docker/karate-chrome/supervisord.conf @@ -34,7 +34,7 @@ priority=300 [program:chrome] user=chrome environment=HOME="/home/chrome",USER="chrome",DISPLAY=":1",DBUS_SESSION_BUS_ADDRESS="unix:path=/dev/null" -command=/usr/bin/chromium +command=/usr/bin/google-chrome --user-data-dir=/home/chrome --no-first-run --disable-translate From e96a7ada3a0bd6e55a5c53f2ea3534ffcb6b0563 Mon Sep 17 00:00:00 2001 From: Guillaume Barry Date: Wed, 1 Nov 2023 12:52:12 +0100 Subject: [PATCH 07/10] #2422 add new image for chromium --- karate-docker/karate-chromium/Dockerfile | 49 ++++++++++++ karate-docker/karate-chromium/entrypoint.sh | 21 +++++ .../karate-chromium/supervisord.conf | 77 +++++++++++++++++++ 3 files changed, 147 insertions(+) create mode 100644 karate-docker/karate-chromium/Dockerfile create mode 100644 karate-docker/karate-chromium/entrypoint.sh create mode 100644 karate-docker/karate-chromium/supervisord.conf diff --git a/karate-docker/karate-chromium/Dockerfile b/karate-docker/karate-chromium/Dockerfile new file mode 100644 index 000000000..0c1188078 --- /dev/null +++ b/karate-docker/karate-chromium/Dockerfile @@ -0,0 +1,49 @@ +FROM maven:3-amazoncorretto-17-debian + +LABEL maintainer="Peter Thomas" +LABEL url="https://github.com/karatelabs/karate/tree/master/karate-docker/karate-chromium" + +RUN apt-get update && apt-get install -y --no-install-recommends \ + wget \ + gnupg2 + +RUN apt-get update && apt-get install -y --no-install-recommends \ + chromium + +RUN useradd chrome --shell /bin/bash --create-home \ + && usermod -a -G sudo chrome \ + && echo 'ALL ALL = (ALL) NOPASSWD: ALL' >> /etc/sudoers \ + && echo 'chrome:karate' | chpasswd + +RUN apt-get install -y --no-install-recommends \ + xvfb \ + x11vnc \ + xterm \ + fluxbox \ + wmctrl \ + supervisor \ + socat \ + ffmpeg \ + locales \ + locales-all + +ENV LANG en_US.UTF-8 + +RUN apt-get clean \ + && rm -rf /var/cache/* /var/log/apt/* /var/lib/apt/lists/* /tmp/* \ + && mkdir ~/.vnc \ + && x11vnc -storepasswd karate ~/.vnc/passwd \ + && locale-gen ${LANG} \ + && dpkg-reconfigure --frontend noninteractive locales \ + && update-locale LANG=${LANG} + +COPY supervisord.conf /etc +COPY entrypoint.sh / +RUN chmod +x /entrypoint.sh + +EXPOSE 5900 9222 + +ADD target/karate.jar / +ADD target/repository /usr/share/maven/ref/repository + +CMD ["/bin/bash", "/entrypoint.sh"] diff --git a/karate-docker/karate-chromium/entrypoint.sh b/karate-docker/karate-chromium/entrypoint.sh new file mode 100644 index 000000000..3df51f8cd --- /dev/null +++ b/karate-docker/karate-chromium/entrypoint.sh @@ -0,0 +1,21 @@ +#!/bin/bash +set -x -e +if [ -z "$KARATE_JOBURL" ] + then + export KARATE_OPTIONS="-h" + export KARATE_START="false" + else + export KARATE_START="true" + export KARATE_OPTIONS="-j $KARATE_JOBURL" +fi +if [ -z "$KARATE_SOCAT_START" ] + then + export KARATE_SOCAT_START="false" + export KARATE_CHROME_PORT="9222" + else + export KARATE_SOCAT_START="true" + export KARATE_CHROME_PORT="9223" +fi +[ -z "$KARATE_WIDTH" ] && export KARATE_WIDTH="1280" +[ -z "$KARATE_HEIGHT" ] && export KARATE_HEIGHT="720" +exec /usr/bin/supervisord -c /etc/supervisord.conf diff --git a/karate-docker/karate-chromium/supervisord.conf b/karate-docker/karate-chromium/supervisord.conf new file mode 100644 index 000000000..bb700fd05 --- /dev/null +++ b/karate-docker/karate-chromium/supervisord.conf @@ -0,0 +1,77 @@ +[supervisord] +user=root +nodaemon=true + +[unix_http_server] +file=/tmp/supervisor.sock +username=dummy +password=dummy + +[rpcinterface:supervisor] +supervisor.rpcinterface_factory=supervisor.rpcinterface:make_main_rpcinterface + +[supervisorctl] +serverurl=unix:///tmp/supervisor.sock +username=dummy +password=dummy + +[program:xvfb] +command=/usr/bin/Xvfb :1 -screen 0 %(ENV_KARATE_WIDTH)sx%(ENV_KARATE_HEIGHT)sx24 +extension RANDR +autorestart=true +priority=100 + +[program:fluxbox] +environment=DISPLAY=":1" +command=/usr/bin/fluxbox -display :1 +autorestart=true +priority=200 + +[program:x11vnc] +command=/usr/bin/x11vnc -display :1 -usepw -shared -forever -xrandr +autorestart=true +priority=300 + +[program:chrome] +user=chrome +environment=HOME="/home/chrome",USER="chrome",DISPLAY=":1",DBUS_SESSION_BUS_ADDRESS="unix:path=/dev/null" +command=/usr/bin/chromium + --user-data-dir=/home/chrome + --no-first-run + --disable-translate + --disable-notifications + --disable-popup-blocking + --disable-infobars + --disable-gpu + --mute-audio + --dbus-stub + --disable-dev-shm-usage + --enable-logging=stderr + --log-level=0 + --window-position=0,0 + --window-size=%(ENV_KARATE_WIDTH)s,%(ENV_KARATE_HEIGHT)s + --force-device-scale-factor=1 + --remote-allow-origins=* + --remote-debugging-port=%(ENV_KARATE_CHROME_PORT)s +autorestart=true +priority=400 + +[program:socat] +command=/usr/bin/socat tcp-listen:9222,fork tcp:localhost:9223 +autorestart=true +autostart=%(ENV_KARATE_SOCAT_START)s +priority=500 + +[program:ffmpeg] +command=/usr/bin/ffmpeg -y -f x11grab -r 16 -s %(ENV_KARATE_WIDTH)sx%(ENV_KARATE_HEIGHT)s -i :1 -vcodec libx264 -pix_fmt yuv420p -preset fast /tmp/karate.mp4 +autostart=%(ENV_KARATE_SOCAT_START)s +priority=600 + +[program:karate] +command=/usr/bin/java -jar karate.jar %(ENV_KARATE_OPTIONS)s +autorestart=false +autostart=%(ENV_KARATE_START)s +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 +priority=700 From 31251e84cbcd8b3a5af658a7ee7b94243e83e435 Mon Sep 17 00:00:00 2001 From: Guillaume Barry Date: Wed, 1 Nov 2023 12:53:03 +0100 Subject: [PATCH 08/10] #2422 rework docker build to create chromium --- .github/workflows/maven-release.yml | 8 +++----- build-docker.sh | 23 +++++++++++++++++------ 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/.github/workflows/maven-release.yml b/.github/workflows/maven-release.yml index 9ffab8b19..f2edfd747 100644 --- a/.github/workflows/maven-release.yml +++ b/.github/workflows/maven-release.yml @@ -38,11 +38,9 @@ jobs: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - name: docker push - run: | - docker tag karate-chrome karatelabs/karate-chrome:${{ github.event.inputs.version }} - docker tag karate-chrome karatelabs/karate-chrome:latest - docker push karatelabs/karate-chrome:${{ github.event.inputs.version }} - docker push karatelabs/karate-chrome:latest + run: | + docker buildx build --push --platform linux/amd64 --cache-from=type=local,src=./target/docker -t karate-chrome -t karatelabs/karate-chrome:latest -t karatelabs/karate-chrome:${{ github.event.inputs.version }} karate-docker/karate-chrome + docker buildx build --push --platform linux/amd64,linux/arm64 --cache-from=type=local,src=./target/docker -t karate-chromium -t karatelabs/karate-chromium:latest -t karatelabs/karate-chromium:${{ github.event.inputs.version }} karate-docker/karate-chromium - name: maven deploy to central env: MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} diff --git a/build-docker.sh b/build-docker.sh index 1bbe104a2..e9749193c 100755 --- a/build-docker.sh +++ b/build-docker.sh @@ -20,18 +20,32 @@ mvn package -B -ntp -P fatjar -DskipTests -f karate-core/pom.xml cp karate-core/target/karate-${KARATE_VERSION}.jar karate-docker/karate-chrome/target/karate.jar # setup multiplatform build +docker buildx rm multiplatform-builder docker buildx create --name multiplatform-builder docker buildx use multiplatform-builder # build karate-chrome docker image that includes karate fatjar + maven jars for convenience -# build for current platform and push for local test -docker buildx build --load -t karate-chrome karate-docker/karate-chrome +# Only possible for linux/amd64 as chrome not available on linux/arm64 +docker buildx build --platform linux/amd64 --cache-from=type=local,src=./target/docker --cache-to=type=local,dest=./target/docker -t karate-chrome -t karate-chrome:latest karate-docker/karate-chrome +# build karate-chromium docker image that includes karate fatjar + maven jars for convenience +# Both platform +docker buildx build --platform linux/amd64,linux/arm64 --cache-from=type=local,src=./target/docker --cache-to=type=local,dest=./target/docker -t karate-chromium karate-docker/karate-chromium + +# Select image for test depending current OS +if [[ "$OSTYPE" == "darwin"* ]]; then + # chromium only solution on Mac darwin + IMAGE=karate-chromium +else + IMAGE=karate-chrome +fi +# Load image image for local +docker buildx build --load --cache-from=type=local,src=./target/docker -t karate-$IMAGE karate-docker/karate-$IMAGE # just in case a previous run had hung (likely only in local dev) docker stop karate || true # note that this command is run as a background process -docker run --name karate --rm --cap-add=SYS_ADMIN -v "$PWD":/karate -v "$HOME"/.m2:/root/.m2 karate-chrome & +docker run --name karate --rm --cap-add=SYS_ADMIN -v "$PWD":/karate -v "$HOME"/.m2:/root/.m2 karate-chromium & # just ensure that the docker container named "karate" exists after the above command # it does not have to have completed startup, the command / karate test below will wait @@ -46,6 +60,3 @@ docker exec -w /karate karate mvn test -B -ntp -f karate-e2e-tests/pom.xml -Dtes docker stop karate wait -# finish multiplatform build adding missing platform as test is working -docker buildx build --platform linux/amd64,linux/arm64 -t karate-chrome karate-docker/karate-chrome -# -> still to check how to push to final repo From 10ccee02f97778f74ad24afbf52c895d21510614 Mon Sep 17 00:00:00 2001 From: Guillaume Barry Date: Wed, 1 Nov 2023 13:14:55 +0100 Subject: [PATCH 09/10] #2422 rework docker build to create chromium --- build-docker.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build-docker.sh b/build-docker.sh index e9749193c..09ef25c1d 100755 --- a/build-docker.sh +++ b/build-docker.sh @@ -1,5 +1,5 @@ #!/bin/bash -set -x -e +#set -x -e # assume that karate jars are installed in maven local repo # mvn clean install -DskipTests -P pre-release @@ -34,9 +34,9 @@ docker buildx build --platform linux/amd64,linux/arm64 --cache-from=type=local,s # Select image for test depending current OS if [[ "$OSTYPE" == "darwin"* ]]; then # chromium only solution on Mac darwin - IMAGE=karate-chromium + IMAGE=chromium else - IMAGE=karate-chrome + IMAGE=chrome fi # Load image image for local docker buildx build --load --cache-from=type=local,src=./target/docker -t karate-$IMAGE karate-docker/karate-$IMAGE @@ -45,7 +45,7 @@ docker buildx build --load --cache-from=type=local,src=./target/docker -t karate docker stop karate || true # note that this command is run as a background process -docker run --name karate --rm --cap-add=SYS_ADMIN -v "$PWD":/karate -v "$HOME"/.m2:/root/.m2 karate-chromium & +docker run --name karate --rm --cap-add=SYS_ADMIN -v "$PWD":/karate -v "$HOME"/.m2:/root/.m2 karate-$IMAGE & # just ensure that the docker container named "karate" exists after the above command # it does not have to have completed startup, the command / karate test below will wait From 26b87c94e2f6e96ca748de4c00e87f68c7945f1b Mon Sep 17 00:00:00 2001 From: Guillaume Barry Date: Thu, 6 Jun 2024 12:58:11 +0200 Subject: [PATCH 10/10] #2422 rfinish revert to chrome missing elements --- karate-docker/karate-chrome/Dockerfile | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/karate-docker/karate-chrome/Dockerfile b/karate-docker/karate-chrome/Dockerfile index 2840b3377..c613ab3ac 100644 --- a/karate-docker/karate-chrome/Dockerfile +++ b/karate-docker/karate-chrome/Dockerfile @@ -7,8 +7,10 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ wget \ gnupg2 -RUN apt-get update && apt-get install -y --no-install-recommends \ - chromium +RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \ + && echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list \ + && apt-get update && apt-get install -y --no-install-recommends \ + google-chrome-stable RUN useradd chrome --shell /bin/bash --create-home \ && usermod -a -G sudo chrome \ @@ -18,7 +20,7 @@ RUN useradd chrome --shell /bin/bash --create-home \ RUN apt-get install -y --no-install-recommends \ xvfb \ x11vnc \ - xterm \ + xterm \ fluxbox \ wmctrl \ supervisor \