agentic
agentic copied to clipboard
Not Able to run ChatGPT inside Docker Container
Verify latest release
- [X] I verified that the issue exists in the latest
chatgpt
release
Verify webapp is working
- [X] I verify that the ChatGPT webapp is working properly for this account.
Environment details
Nodejs - v18.12.1 OS Ubuntu - 20.04 LTS puppeteer - 19.4.1 chatgpt - 3.3.2
Describe the Bug
I created nodejs program for chatgpt using this library and running in docker container.
logs cmd - docker logs containerID
I installed google-chrome browser inside the docker also
Error:
Listening to Port 8000 Error: Failed to launch the browser process! [31:31:1223/094709.453848:ERROR:ozone_platform_x11.cc(238)] Missing X server or $DISPLAY [31:31:1223/094709.453908:ERROR:env.cc(255)] The platform failed to initialize. Exiting.
TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md
at onClose (/node_modules/puppeteer-core/src/node/BrowserRunner.ts:328:9)
at ChildProcess.<anonymous> (/node_modules/puppeteer-core/src/node/BrowserRunner.ts:317:16)
at ChildProcess.emit (node:events:525:35)
at ChildProcess.emit (node:domain:489:12)
at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
Has anyone faced this issue? Share your opinion ...
The recaptcha requires human intervention also google chrome must be installed
check out xvfb to display brother or and vnc to monitor.
Try
Xvfb -ac :99 -screen 0 1280x1024x16 & export DISPLAY=:99
monitor with x11vnc ?
Try
x11vnc -display $DISPLAY -bg -forever -nopw -quiet -listen localhost[any port you want] -xkb
https://stackoverflow.com/questions/60304251/unable-to-open-x-display-when-trying-to-run-google-chrome-on-centos-rhel-7-5
What was content of your Docker file?
This Dockerfile will work:
https://github.com/jakecoppinger/matrix-chatgpt-bot/blob/main/Dockerfile
I've found if you get captcha issues just login from a browser on the same machine, I was using an entirely different browser (Safari vs Chrome) and it was fine for me.
The recaptcha requires human intervention also google chrome must be installed
@alcarazolabs, Chrome, and chromium browser - I have installed it in docker, but it won't work.
My working example
FROM node:18.12.1
RUN wget -qO - https://dl.google.com/linux/linux_signing_key.pub | gpg --dearmor -o /usr/share/keyrings/googlechrome-linux-keyring.gpg && \
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/googlechrome-linux-keyring.gpg] http://dl.google.com/linux/chrome/deb/ stable main" | tee /etc/apt/sources.list.d/google-chrome.list && \
apt-get update && \
apt-get install -y xvfb google-chrome-stable
WORKDIR /app
COPY package.json yarn.lock ./
RUN yarn install
COPY . .
CMD xvfb-run -a --server-args="-screen 0 1280x800x24 -ac -nolisten tcp -dpi 96 +extension RANDR" yarn start
My working example
FROM node:18.12.1 RUN wget -qO - https://dl.google.com/linux/linux_signing_key.pub | gpg --dearmor -o /usr/share/keyrings/googlechrome-linux-keyring.gpg && \ echo "deb [arch=amd64 signed-by=/usr/share/keyrings/googlechrome-linux-keyring.gpg] http://dl.google.com/linux/chrome/deb/ stable main" | tee /etc/apt/sources.list.d/google-chrome.list && \ apt-get update && \ apt-get install -y xvfb google-chrome-stable WORKDIR /app COPY package.json yarn.lock ./ RUN yarn install COPY . . CMD xvfb-run -a --server-args="-screen 0 1280x800x24 -ac -nolisten tcp -dpi 96 +extension RANDR" yarn start
Does that work on ARM64 as well as AMD64?
Does that work on ARM64 as well as AMD64?
i dont think so need to check
FROM node:18
# Install latest chrome dev package and fonts to support major charsets (Chinese, Japanese, Arabic, Hebrew, Thai and a few others)
# Note: this installs the necessary libs to make the bundled version of Chromium that Puppeteer installs, work.
RUN apt-get update \
&& apt-get install -y wget gnupg \
&& wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
&& apt-get update \
&& apt-get install -y google-chrome-stable=108.0.5359.124-1 fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf libxss1 --no-install-recommends \
&& rm -rf /var/lib/apt/lists/*
# To run Headful mode, you will need to have a display, which is not present in a server.
# To avoid this, we will use Xvfb, and create a fake display, so the chrome will think there is a display and run properly.
# So we just need to install Xvfb and Puppeteer related dependencies.
RUN apt-get update && apt-get install -yq gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget x11vnc x11-xkb-utils xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic x11-apps xvfb
RUN mkdir -p /home/pptruser/Downloads
WORKDIR /home/pptruser
RUN npm install [email protected] \
# Add user so we don't need --no-sandbox.
# same layer as npm install to keep re-chowned files from using up several hundred MBs more space
&& groupadd -r pptruser && useradd -r -g pptruser -G audio,video pptruser \
&& chown -R pptruser:pptruser /home/pptruser
WORKDIR /home/pptruser/chat
copy . .
RUN npm install
CMD ["./run.sh"]
Ref from here: https://github.com/MetaviewAI/docker-puppeteer/blob/master/Dockerfile
run.sh
#!/bin/bash
xvfb-run -n1 -f /tmp/authvnc npx tsx demos/local-server.ts
After updating chatgpt lib and docker file, gets the below error
"dependencies": { "chatgpt": "^3.3.4", "dotenv": "^14.2.0", "matrix-bot-sdk": "^0.6.2", "puppeteer": "^19.4.1", "typescript": "^4.5.2" }
code : const api = new ChatGPTAPIBrowser({ email: "XXXXX", password: "YYYY", debug: true, isGoogleLogin: true, minimize: true, // executablePath: "/usr/bin/google-chrome", });
error-----------------> ChatGPTError: Failed to authenticate session
Does anyone resolve this?
Does that work on ARM64 as well as AMD64?
i dont think so need to check
If you need ARM64 you'd have to use Chromium instead of Chrome I think, that would however work on both AMD64 and ARM64.
As others have commented, this is possible by utilizing xvfb
to create a virtual display, though I don't have a working dockerfile myself to link to.
After updating chatgpt lib and docker file, gets the below error
"dependencies": { "chatgpt": "^3.3.4", "dotenv": "^14.2.0", "matrix-bot-sdk": "^0.6.2", "puppeteer": "^19.4.1", "typescript": "^4.5.2" }
code : const api = new ChatGPTAPIBrowser({ email: "XXXXX", password: "YYYY", debug: true, isGoogleLogin: true, minimize: true, // executablePath: "/usr/bin/google-chrome", });
error-----------------> ChatGPTError: Failed to authenticate session
Does anyone resolve this?
After debugging, I found that because google has another login step
I printed the url of the page at the final step of getting cookies, it was https://accounts.google.com/signin/v2/challenge/selection...
Thanks. @tqnghia1998
But, where need to be changed the account? can you please briefly explain? Not able to understand the link!!!
Thanks. @tqnghia1998
But, where need to be changed the account? can you please briefly explain? Not able to understand the link!!!
It means seems there is another verification step for google login in docker container. I am still finding the solution, have no clue to fix yet
Ok, Thanks @tqnghia1998.
I am also finding the solution. Please let me know if find any
Hi @tqnghia1998 and @transitive-bullshit ,
error-----------------> ChatGPTError: Failed to authenticate session
I think it is a Gmail region access issue, not able to access one region to another region in chatgpt browser, within verification the session got expired. so we got this error.
Need to be looked into this issue.
let me know if anyone resolves this.
This is my solution. https://github.com/fuergaosi233/wechat-chatgpt/blob/main/Dockerfile
Hey,@fuergaosi233
is it solve the below error?
error-----------------> ChatGPTError: Failed to authenticate session
I think it is a Gmail region access issue, not able to access one region to another region in chatgpt browser, within verification the session got expired. so we got this error.
Please let me know...
Hey,@fuergaosi233
is it solve the below error?
error-----------------> ChatGPTError: Failed to authenticate session
I think it is a Gmail region access issue, not able to access one region to another region in chatgpt browser, within verification the session got expired. so we got this error.
Please let me know...
I don't think it has anything to do with Docker, I have occasionally encountered this error and reslove it after retry.
Please use @fuergaosi233 https://github.com/fuergaosi233/wechat-chatgpt/blob/main/Dockerfile as a general Docker template for now.
If you're still running into problems, then it likely has nothing to do with Docker but rather a problem with your setup, environment, or how you're using the package. Feel free to open a separate issue in this case.
Thanks!