banner
Geek

Geek

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

Deploying the ChatGPT official service to OpenWrt routers using Docker

Introduction#

In the hustle and bustle of life and bricklaying, the ChatGPT official website often goes offline. Fortunately, both locations have OpenWrt routers, so I deployed ChatGPT on the routers. The gateways in both locations are 192.168.2.1, and I added ChatGPT on the router to Google Chrome bookmarks, allowing quick access from both locations.

Project#

This time, I used Pandora, an open-source project that implements a web version of ChatGPT using an Access Token. It has backend optimization, bypasses Cloudflare, and has impressive speed.

The Access Token is valid for 14 days, and during this period, no VPN is required for access.

Deployment#

Install Docker#

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

CleanShot 2023-05-26 at 11.02.28@2x

After the update, install the following:

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

CleanShot 2023-05-26 at 11.03.15@2x

CleanShot 2023-05-26 at 11.03.40@2x

Once installed, Docker can be found in the left column.

CleanShot 2023-05-26 at 11.05.01@2x

The following operations are recommended to be completed via SSH, as Docker on OpenWrt is difficult to use!

Connect to the OpenWrt gateway 192.168.2.1 using an SSH tool. The username and password are the same as the ones for OpenWrt. Recommended tool: electerm

Pull the image#

docker pull pengzhile/pandora

CleanShot 2023-05-26 at 11.08.06@2x

Run the image#

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

CleanShot 2023-05-26 at 11.08.37@2x

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

Get the Access Token#

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

  • Alternatively, you can directly use your OpenAI account to log in.
    Open http://gateway:8899/
    I use the Access Token
    CleanShot 2023-05-26 at 11.09.16@2x

Done! Using the cloud mode is no different from the ChatGPT official website. Chat logs are synchronized and the experience is stable and efficient.

CleanShot 2023-05-26 at 11.11.36@2x

Set 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

CleanShot 2023-05-26 at 11.50.48@2x

Replace docker start my_container with the container ID in the OpenWrt Docker, for example, mine is 3c3ab7807401.
docker start 3c3ab7807401

Pasted image 20230529104653

  • Save and close the file.

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

chmod +x /etc/rc.local

CleanShot 2023-05-26 at 11.50.59@2x


Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.