Samrat Sahoo
Samrat Sahoo

Reputation: 575

Geckodriver + Node.js in Docker on GIthub Actions

I have this Dockerfile that runs a node script (which all works well locally), but in Github Actions, get the following error:

/app/node_modules/selenium-webdriver/lib/error.js:521
    let err = new ctor(data.message)
              ^

WebDriverError: Process unexpectedly closed with status 1
    at Object.throwDecodedError (/app/node_modules/selenium-webdriver/lib/error.js:521:15)
    at parseHttpResponse (/app/node_modules/selenium-webdriver/lib/http.js:514:13)
    at Executor.execute (/app/node_modules/selenium-webdriver/lib/http.js:446:28)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  remoteStacktrace: ''
}

My Dockerfile is as follows:

# Use the official Node.js image as base
FROM node:latest

# Set working directory
WORKDIR /app

# Copy package.json and package-lock.json to the working directory
COPY ./package*.json ./

# Install dependencies
RUN npm install

# Copy the Selenium script files to the working directory
COPY ./probe.js ./

RUN apt-get update -y \
&& apt-get install --no-install-recommends --no-install-suggests -y tzdata ca-certificates bzip2 curl wget libc-dev libxt6 \
&& apt-get install --no-install-recommends --no-install-suggests -y `apt-cache depends firefox-esr | awk '/Depends:/{print$2}'` \
&& update-ca-certificates \
# Cleanup unnecessary stuff
&& apt-get purge -y --auto-remove \
              -o APT::AutoRemove::RecommendsImportant=false \
&& rm -rf /var/lib/apt/lists/* /tmp/*

# install geckodriver

RUN wget https://github.com/mozilla/geckodriver/releases/download/v0.31.0/geckodriver-v0.31.0-linux64.tar.gz && \
    tar -zxf geckodriver-v0.31.0-linux64.tar.gz -C /usr/local/bin && \
    chmod +x /usr/local/bin/geckodriver && \
    rm geckodriver-v0.31.0-linux64.tar.gz

# install firefox

RUN FIREFOX_SETUP=firefox-setup.tar.bz2 && \
    wget -O $FIREFOX_SETUP "https://download.mozilla.org/?product=firefox-95.0.1&os=linux64" && \
    tar xjf $FIREFOX_SETUP -C /opt/ && \
    ln -s /opt/firefox/firefox /usr/bin/firefox && \
    rm $FIREFOX_SETUP
    
# Run the Node.js script
CMD ["node", "/app/probe.js"]

I am fairly certain that my node script isn't the issue because I've run it locally with and without docker and it works as intended. Any ideas on how to go about fixing this?

Upvotes: 0

Views: 41

Answers (0)

Related Questions