banner
Geek

Geek

🧠在家居士 | 🥦素食者 | 🏃🏻马拉松爱好者 | 📡AI降临派 | 过🪜技术资深学者 | 🤖科技狂 | 📤更新狂🆅 https://www.igeekbb.com/
twitter
github

Deploy the official ChatGPT service using Docker on OpenWrt routers.

Introduction#

In my daily life and travels, the ChatGPT official website often has issues. Fortunately, both locations have OpenWrt routers, so I decided to deploy ChatGPT on the routers. The gateways in both locations are set to 192.168.2.1. I added ChatGPT on the router to my Google Chrome bookmarks so that I can access it quickly from both locations.

Project#

This time, I used Pandora, an open-source project that implements a web version of ChatGPT using an Access Token. The backend is optimized to bypass Cloudflare, resulting in faster speeds.

The Access Token is valid for 14 days and does not require a VPN during that period.

Deployment#

Installing Docker#

Open the OpenWrt firmware I'm using, which can be found at https://supes.top/. Go to "System" and then "Software" and click on "Update lists".

After the update, install the following packages:

  • luci-lib-jsonc
  • luci-lib-docker
  • luci-app-dockerman

Once the installation is complete, Docker can be found in the left column.

It is recommended to complete the following steps using SSH, as Docker on OpenWrt is difficult to use.

Connect to the OpenWrt gateway at 192.168.2.1 using an SSH tool. The username and password are the same as the ones used for OpenWrt. I recommend using the electerm tool.

Pulling the Image#

docker pull pengzhile/pandora

Running the Image#

docker run -e PANDORA_CLOUD=cloud -e PANDORA_SERVER=0.0.0.0:8899 -p 8899:8899 -d pengzhile/pandora

For more Docker environment variables, please refer to pandora environment variables.

Obtaining the Access Token#

  • Log in to the official website and then access this link to obtain the Access Token, which is valid for 14 days.

  • Alternatively, you can directly log in with your OpenAI account. Open http://gateway:8899/ and use the Access Token.

With the cloud mode, it is the same as the ChatGPT official website. The chat history is synchronized and the performance is stable and efficient.

Setting Up Auto Start (Optional)#

  • Use the /etc/rc.local file to execute custom startup scripts.

  • Find the /etc/rc.local file.

  • Add the following content to the end of the file:

#!/bin/sh
/etc/init.d/dockerd restart # Restart Docker service
sleep 10 # Wait for 10 seconds to ensure Docker service has started
docker start my_container # Start Docker container

Replace my_container with the container ID in the OpenWrt Docker, for example, 3c3ab7807401.

  • Save and close the file.

Grant execution permission to the /etc/rc.local file:

chmod +x /etc/rc.local
Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.