@@ -139,6 +139,34 @@ nohup python3 app.py & tail -f nohup.out # 在后台运行程序并通 | |||
> **特殊指令:** 用户向机器人发送 **#清除记忆** 即可清空该用户的上下文记忆。 | |||
3.如果是在docker **容器运行**,可以在`根\docker`目录下: | |||
首先,修改Dockerfile.alpine文件里第9行,关于openapi key的配置 | |||
```bash | |||
BUILD_OPEN_AI_API_KEY='YOUR OPEN AI KEY HERE' | |||
``` | |||
然后,使用docker-compose启动容器运行: | |||
```bash | |||
docker-compose up | |||
``` | |||
如果您的环境里没有安装docker-compose,可以使用docker build方式构建Image,使用以下命令: | |||
```bash | |||
chmod +x build.alpine.sh #构建脚本添加执行权限 | |||
./build.alpine.sh #构建容器,基于alpine | |||
``` | |||
然后,通过已构建完成的Image启动容器,使用以下命令: | |||
```bash | |||
docker run -it --name sample-chatgpt-on-wechat zhayujie/chatgpt-on-wechat:1.0.0-alpine | |||
``` | |||
同时,我们在`根\docker\sample-chatgpt-on-wechat`下提供了Makefile脚本,方便使用 | |||
```bash | |||
cd sample-chatgpt-on-wechat #进入sample-chatgpt-on-wechat目录 | |||
make run_i #使用交互式方式启动容器 | |||
``` | |||
## 常见问题 | |||
FAQs: <https://github.com/zhayujie/chatgpt-on-wechat/wiki/FAQs> | |||
@@ -0,0 +1,38 @@ | |||
FROM python:3.7.9-alpine | |||
LABEL maintainer="foo@bar.com" | |||
ARG TZ='Asia/Shanghai' | |||
ARG CHATGPT_ON_WECHAT_VER=1.0.0 | |||
ENV BUILD_PREFIX=/app \ | |||
BUILD_OPEN_AI_API_KEY='YOUR OPEN AI KEY HERE' | |||
RUN apk add --no-cache \ | |||
curl \ | |||
wget \ | |||
openssh | |||
RUN wget -t 3 -T 30 -nv -O chatgpt-on-wechat-${CHATGPT_ON_WECHAT_VER}.tar.gz \ | |||
https://github.com/zhayujie/chatgpt-on-wechat/archive/refs/tags/${CHATGPT_ON_WECHAT_VER}.tar.gz \ | |||
&& tar -xzf chatgpt-on-wechat-${CHATGPT_ON_WECHAT_VER}.tar.gz \ | |||
&& mv chatgpt-on-wechat-${CHATGPT_ON_WECHAT_VER} ${BUILD_PREFIX} \ | |||
&& rm chatgpt-on-wechat-${CHATGPT_ON_WECHAT_VER}.tar.gz | |||
WORKDIR ${BUILD_PREFIX} | |||
RUN cd ${BUILD_PREFIX} \ | |||
&& cp config-template.json ${BUILD_PREFIX}/config.json \ | |||
&& sed -i "2s/YOUR API KEY/${BUILD_OPEN_AI_API_KEY}/" ${BUILD_PREFIX}/config.json \ | |||
&& cat ${BUILD_PREFIX}/config.json | |||
RUN /usr/local/bin/python -m pip install --upgrade pip \ | |||
&& pip install itchat-uos==1.5.0.dev0 \ | |||
&& pip install --upgrade openai | |||
RUN adduser -D -h /home/noroot -u 1000 -s /bin/bash noroot \ | |||
&& chown noroot:noroot ${BUILD_PREFIX} | |||
USER noroot | |||
CMD ["python","app.py"] |
@@ -0,0 +1,40 @@ | |||
FROM python:3.7.9 | |||
LABEL maintainer="foo@bar.com" | |||
ARG TZ='Asia/Shanghai' | |||
ARG CHATGPT_ON_WECHAT_VER=1.0.0 | |||
ENV BUILD_PREFIX=/app \ | |||
BUILD_OPEN_AI_API_KEY='YOUR OPEN AI KEY HERE' | |||
RUN apt-get update && \ | |||
apt-get install -y --no-install-recommends \ | |||
wget \ | |||
curl && \ | |||
rm -rf /var/lib/apt/lists/* | |||
RUN wget -t 3 -T 30 -nv -O chatgpt-on-wechat-${CHATGPT_ON_WECHAT_VER}.tar.gz \ | |||
https://github.com/zhayujie/chatgpt-on-wechat/archive/refs/tags/${CHATGPT_ON_WECHAT_VER}.tar.gz \ | |||
&& tar -xzf chatgpt-on-wechat-${CHATGPT_ON_WECHAT_VER}.tar.gz \ | |||
&& mv chatgpt-on-wechat-${CHATGPT_ON_WECHAT_VER} ${BUILD_PREFIX} \ | |||
&& rm chatgpt-on-wechat-${CHATGPT_ON_WECHAT_VER}.tar.gz | |||
WORKDIR ${BUILD_PREFIX} | |||
RUN cd ${BUILD_PREFIX} \ | |||
&& cp config-template.json ${BUILD_PREFIX}/config.json \ | |||
&& sed -i "2s/YOUR API KEY/${BUILD_OPEN_AI_API_KEY}/" ${BUILD_PREFIX}/config.json \ | |||
&& cat ${BUILD_PREFIX}/config.json | |||
RUN /usr/local/bin/python -m pip install --upgrade pip \ | |||
&& pip install itchat-uos==1.5.0.dev0 \ | |||
&& pip install --upgrade openai | |||
RUN groupadd -r noroot \ | |||
&& useradd -r -g noroot noroot \ | |||
&& chown -R noroot:noroot ${BUILD_PREFIX} | |||
USER noroot | |||
CMD ["python","app.py"] |
@@ -0,0 +1,3 @@ | |||
docker build -f Dockerfile.alpine \ | |||
--build-arg CHATGPT_ON_WECHAT_VER=1.0.0\ | |||
-t zhayujie/chatgpt-on-wechat:1.0.0-alpine . |
@@ -0,0 +1,3 @@ | |||
docker build -f Dockerfile.debian \ | |||
--build-arg CHATGPT_ON_WECHAT_VER=1.0.0\ | |||
-t zhayujie/chatgpt-on-wechat:1.0.0-debian . |
@@ -0,0 +1,8 @@ | |||
version: '2.0' | |||
services: | |||
chatgpt-on-wechat: | |||
build: | |||
context: ./ | |||
dockerfile: Dockerfile.alpine | |||
image: zhayujie/chatgpt-on-wechat:1.0.0-alpine | |||
container_name: sample-chatgpt-on-wechat |
@@ -0,0 +1 @@ | |||
@@ -0,0 +1,26 @@ | |||
IMG:=`cat Name` | |||
MOUNT:=-v `pwd`/config.json:/app/config.json | |||
PORT_MAP:= | |||
DOTENV:=.env | |||
CONTAINER_NAME:=sample-chatgpt-on-wechat | |||
echo: | |||
echo $(IMG) | |||
run_d: | |||
docker rm $(CONTAINER_NAME) || echo | |||
docker run -dt --name $(CONTAINER_NAME) $(PORT_MAP) \ | |||
--env-file=$(DOTENV) \ | |||
$(MOUNT) $(IMG) | |||
run_i: | |||
docker rm $(CONTAINER_NAME) || echo | |||
docker run -it --name $(CONTAINER_NAME) $(PORT_MAP) \ | |||
--env-file=$(DOTENV) \ | |||
$(MOUNT) $(IMG) | |||
stop: | |||
docker stop $(CONTAINER_NAME) | |||
rm: stop | |||
docker rm $(CONTAINER_NAME) |
@@ -0,0 +1 @@ | |||
zhayujie/chatgpt-on-wechat:1.0.0-alpine |