Zenika / alpine-chrome

Chrome Headless docker images built upon alpine official image
https://hub.docker.com/r/zenika/alpine-chrome
Apache License 2.0
1.78k stars 239 forks source link

When using zenika/alpine-chrome:with-chromedriver docker image then in GitLab CI ChromeDriver was started successfully. is display but it get stuck and do nothing #245

Open manishbupadhyay opened 5 months ago

manishbupadhyay commented 5 months ago

Describe the bug When using zenika/alpine-chrome:with-chromedriver docker image then in GitLab CI ChromeDriver was started successfully. is display but it get stuck and do nothing

To Reproduce Steps to reproduce the behavior:

  1. Use zenika/alpine-chrome:with-chromedriver docker image in your docker and GitLab CI files

What is the expected behavior? ChromeDriver was started successfully. and it should execute the test cases as well

What is the actual behavior?

Starting ChromeDriver 121.0.6167.184 (057a8ae7deb3374d0f1b04b36304d236f0136188-refs/branch-heads/6167@{#1818}) on port 9515

ChromeDriver was started successfully. is display but it get stuck and do nothing image

manishbupadhyay commented 5 months ago

Can someone please look into this and help me to resolve this issue?

As per my understanding I think zenika/alpine-chrome:with-chromedriver docker image starting chrome driver 121 but chrome has now new update 122 might be the chrome version issue.

manishbupadhyay commented 5 months ago

@zigarn zigarn Can you please take a look at this?

zigarn commented 5 months ago

@manishbupadhyay can you provide a minimal reproducible .gitlab-ci.yml file? Ideally even a public gitlab repository with it and the CI pipeline?

zigarn commented 5 months ago

I'm only working on the packaging and don't know much of the JS frameworks packaged. But from what I understand, it's the expected behavior of the with-chromedriver image: it launch a chromedriver server and then wait for connections. Ping @jlandure

manishbupadhyay commented 5 months ago

Hey @zigarn thanks for your response, please find below minimal gitlab ci and docker files .gitlab-ci.yml

image: internal/java-builder:17
variables:
  MAVEN_CLI_OPTS: "-s .m2/settings.xml --batch-mode"
  MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository"
  CONTEXT: ""
  ENVIRONMENT: ""
  APPLICATION_VERSION: ""
  CUCUMBER_TAGS:
    value: ""
    description: "The cucumber tag variable will pick tags from scheduled job, please pick ONE from this list: @SmokeTest,@GapMapsUI,@RegressionTest"

cache:
  paths:
    - .m2/repository/

stages:
  - build
  - SmokeTest
  - deploy

build:
  stage: build
  when: always
  script:
    - mvn compile
    - echo "Thanks for running $CI_JOB_NAME"

SmokeTest:
  stage: SmokeTest
  image: zenika/alpine-chrome:with-chromedriver
  artifacts:
    when: always
    paths:
      - target/
      - tests*
    #extends: .bootstrap-job-deb
    reports:
      junit:
        - target/surefire-reports/TEST-*.xml
        - target/failsafe-reports/TEST-*.xml
  rules:
    - if: '$CUCUMBER_TAGS == "@SmokeTest"'
      when: always
    - when: never

  script:
      - echo $MAVEN_CLI_OPTS
      - echo $MAVEN_OPTS
      - echo $CI_PROJECT_DIR
      - echo $CI_PROJECT_PATH
      - echo $CUCUMBER_TAGS
      - echo $CONTEXT
      - echo $ENVIRONMENT
      - echo $APPLICATION_VERSION
      - echo $CI_PIPELINE_SOURCE
      - echo $GITLAB_USER_LOGIN
      - mvn clean compile verify -Dcontext=$CONTEXT -Denvironment=$ENVIRONMENT -Dversion=$APPLICATION_VERSION -Djira.username=$GITLAB_USER_LOGIN -Dcucumber.filter.tags=$CUCUMBER_TAGS -Dit.test=SmokeTestRunner -Dwebdriver.remote.driver=chrome -Dwebdriver.remote.url=http://gitlabrunnerip:4444/wd/hub

deploy:
  stage: deploy
  environment: test
  when: on_success
  script:
    - echo "Thanks for deploying $CI_JOB_NAME"

docker file

FROM zenika/alpine-chrome:with-chromedriver
ADD ./target/myproject.jar app.jar
ARG test
ENV envValue=$test
ENTRYPOINT ["java","-jar","/app.jar"]
zigarn commented 4 months ago

Please read https://docs.gitlab.com/ee/ci/docker/using_docker_images.html#override-the-entrypoint-of-an-image The image's entrypoint is used and as pointed in earlier comment, the entrypoint is to launch the chromedriver server. So just reset the entrypoint in the gitlab-ci config:

#...
SmokeTest:
  stage: SmokeTest
  image:
    name: zenika/alpine-chrome:with-chromedriver
    entrypoint: [""]
#...
manishbupadhyay commented 4 months ago

@zigarn when I use the entrypoint above as you mentioned then the mvn is not found message is displayed

...

SmokeTest: stage: SmokeTest image: name: zenika/alpine-chrome:with-chromedriver entrypoint: [""]

...

zigarn commented 4 months ago

This is quite logic as neither java nor maven are provided in the image zenika/alpine-chrome:with-chromedriver. You need to install them in your CI script or to extend the image first to add them in a new one containing chromedriver, java and maven.

manishbupadhyay commented 4 months ago

@zigarn can you please give me an example with my above gitlab ci file?