diff --git a/docker/Dockerfile.alpine b/docker/Dockerfile.alpine index 167fabe..6b3b1fb 100644 --- a/docker/Dockerfile.alpine +++ b/docker/Dockerfile.alpine @@ -1,4 +1,4 @@ -FROM python:3.7.9-alpine +FROM python:3.10-alpine LABEL maintainer="foo@bar.com" ARG TZ='Asia/Shanghai' @@ -22,9 +22,7 @@ RUN apk add --no-cache \ && cd ${BUILD_PREFIX} \ && cp config-template.json ${BUILD_PREFIX}/config.json \ && /usr/local/bin/python -m pip install --no-cache --upgrade pip \ - && pip install --no-cache \ - itchat-uos==1.5.0.dev0 \ - openai \ + && pip install --no-cache -r requirements.txt \ && apk del curl wget WORKDIR ${BUILD_PREFIX} diff --git a/docker/Dockerfile.debian b/docker/Dockerfile.debian index a659433..0a17ae5 100644 --- a/docker/Dockerfile.debian +++ b/docker/Dockerfile.debian @@ -1,4 +1,4 @@ -FROM python:3.7.9 +FROM python:3.10 LABEL maintainer="foo@bar.com" ARG TZ='Asia/Shanghai' @@ -23,9 +23,7 @@ RUN apt-get update \ && cd ${BUILD_PREFIX} \ && cp config-template.json ${BUILD_PREFIX}/config.json \ && /usr/local/bin/python -m pip install --no-cache --upgrade pip \ - && pip install --no-cache \ - itchat-uos==1.5.0.dev0 \ - openai + && pip install --no-cache -r requirements.txt WORKDIR ${BUILD_PREFIX} diff --git a/docker/Dockerfile.latest b/docker/Dockerfile.latest index 061fa99..53bb41b 100644 --- a/docker/Dockerfile.latest +++ b/docker/Dockerfile.latest @@ -1,4 +1,4 @@ -FROM python:3.7.9-alpine +FROM python:3.10-alpine LABEL maintainer="foo@bar.com" ARG TZ='Asia/Shanghai' @@ -7,22 +7,17 @@ ARG CHATGPT_ON_WECHAT_VER ENV BUILD_PREFIX=/app -COPY chatgpt-on-wechat.tar.gz ./chatgpt-on-wechat.tar.gz +ADD . ${BUILD_PREFIX} -RUN apk add --no-cache \ - bash \ - && tar -xf chatgpt-on-wechat.tar.gz \ - && mv chatgpt-on-wechat ${BUILD_PREFIX} \ +RUN apk add --no-cache bash ffmpeg espeak \ && cd ${BUILD_PREFIX} \ - && cp config-template.json ${BUILD_PREFIX}/config.json \ + && cp config-template.json config.json \ && /usr/local/bin/python -m pip install --no-cache --upgrade pip \ - && pip install --no-cache \ - itchat-uos==1.5.0.dev0 \ - openai + && pip install --no-cache -r requirements.txt WORKDIR ${BUILD_PREFIX} -ADD ./entrypoint.sh /entrypoint.sh +ADD docker/entrypoint.sh /entrypoint.sh RUN chmod +x /entrypoint.sh \ && adduser -D -h /home/noroot -u 1000 -s /bin/bash noroot \ @@ -30,4 +25,4 @@ RUN chmod +x /entrypoint.sh \ USER noroot -ENTRYPOINT ["/entrypoint.sh"] \ No newline at end of file +ENTRYPOINT ["docker/entrypoint.sh"] \ No newline at end of file diff --git a/docker/build.latest.sh b/docker/build.latest.sh index 3d41a4c..186ab92 100644 --- a/docker/build.latest.sh +++ b/docker/build.latest.sh @@ -1,8 +1,4 @@ #!/bin/bash -# move chatgpt-on-wechat -tar -zcf chatgpt-on-wechat.tar.gz --exclude=../../chatgpt-on-wechat/docker ../../chatgpt-on-wechat - -# build image -docker build -f Dockerfile.latest \ +cd .. && docker build -f Dockerfile \ -t zhayujie/chatgpt-on-wechat . \ No newline at end of file diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 5f798a6..7720e90 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -10,17 +10,17 @@ CHATGPT_ON_WECHAT_EXEC=${CHATGPT_ON_WECHAT_EXEC:-""} # use environment variables to pass parameters # if you have not defined environment variables, set them below -export OPEN_AI_API_KEY=${OPEN_AI_API_KEY:-'YOUR API KEY'} -export OPEN_AI_PROXY=${OPEN_AI_PROXY:-""} -export SINGLE_CHAT_PREFIX=${SINGLE_CHAT_PREFIX:-'["bot", "@bot"]'} -export SINGLE_CHAT_REPLY_PREFIX=${SINGLE_CHAT_REPLY_PREFIX:-'"[bot] "'} -export GROUP_CHAT_PREFIX=${GROUP_CHAT_PREFIX:-'["@bot"]'} -export GROUP_NAME_WHITE_LIST=${GROUP_NAME_WHITE_LIST:-'["ChatGPT测试群", "ChatGPT测试群2"]'} -export IMAGE_CREATE_PREFIX=${IMAGE_CREATE_PREFIX:-'["画", "看", "找"]'} -export CONVERSATION_MAX_TOKENS=${CONVERSATION_MAX_TOKENS:-"1000"} -export SPEECH_RECOGNITION=${SPEECH_RECOGNITION:-"False"} -export CHARACTER_DESC=${CHARACTER_DESC:-"你是ChatGPT, 一个由OpenAI训练的大型语言模型, 你旨在回答并解决人们的任何问题,并且可以使用多种语言与人交流。"} -export EXPIRES_IN_SECONDS=${EXPIRES_IN_SECONDS:-"3600"} +# export OPEN_AI_API_KEY=${OPEN_AI_API_KEY:-'YOUR API KEY'} +# export OPEN_AI_PROXY=${OPEN_AI_PROXY:-""} +# export SINGLE_CHAT_PREFIX=${SINGLE_CHAT_PREFIX:-'["bot", "@bot"]'} +# export SINGLE_CHAT_REPLY_PREFIX=${SINGLE_CHAT_REPLY_PREFIX:-'"[bot] "'} +# export GROUP_CHAT_PREFIX=${GROUP_CHAT_PREFIX:-'["@bot"]'} +# export GROUP_NAME_WHITE_LIST=${GROUP_NAME_WHITE_LIST:-'["ChatGPT测试群", "ChatGPT测试群2"]'} +# export IMAGE_CREATE_PREFIX=${IMAGE_CREATE_PREFIX:-'["画", "看", "找"]'} +# export CONVERSATION_MAX_TOKENS=${CONVERSATION_MAX_TOKENS:-"1000"} +# export SPEECH_RECOGNITION=${SPEECH_RECOGNITION:-"False"} +# export CHARACTER_DESC=${CHARACTER_DESC:-"你是ChatGPT, 一个由OpenAI训练的大型语言模型, 你旨在回答并解决人们的任何问题,并且可以使用多种语言与人交流。"} +# export EXPIRES_IN_SECONDS=${EXPIRES_IN_SECONDS:-"3600"} # CHATGPT_ON_WECHAT_PREFIX is empty, use /app if [ "$CHATGPT_ON_WECHAT_PREFIX" == "" ] ; then @@ -38,7 +38,7 @@ if [ "$CHATGPT_ON_WECHAT_EXEC" == "" ] ; then fi # modify content in config.json -if [ "$OPEN_AI_API_KEY" == "YOUR API KEY" ] ; then +if [ "$OPEN_AI_API_KEY" == "YOUR API KEY" ] || [ "$OPEN_AI_API_KEY" == "" ]; then echo -e "\033[31m[Warning] You need to set OPEN_AI_API_KEY before running!\033[0m" fi