From beb7bda243206182985e087cd231be4be443fec0 Mon Sep 17 00:00:00 2001 From: lanvent Date: Thu, 27 Apr 2023 19:38:33 +0800 Subject: [PATCH] fix(docker): use debian.latest as latest image --- README.md | 6 ++---- ...ile.debian.latest => Dockerfile.alpine.latest} | 14 +++++--------- docker/Dockerfile.latest | 15 ++++++++++----- requirements-optional.txt | 2 +- 4 files changed, 18 insertions(+), 19 deletions(-) rename docker/{Dockerfile.debian.latest => Dockerfile.alpine.latest} (50%) diff --git a/README.md b/README.md index 0665f50..0a77dda 100644 --- a/README.md +++ b/README.md @@ -83,15 +83,13 @@ pip3 install -r requirements-optional.txt 参考[#415](https://github.com/zhayujie/chatgpt-on-wechat/issues/415) -使用`azure`语音功能需安装依赖(列在`requirements-optional.txt`内,但为便于`railway`部署已注释): +使用`azure`语音功能需安装依赖,并参考[文档](https://learn.microsoft.com/en-us/azure/cognitive-services/speech-service/quickstarts/setup-platform?pivots=programming-language-python&tabs=linux%2Cubuntu%2Cdotnet%2Cjre%2Cmaven%2Cnodejs%2Cmac%2Cpypi)的环境要求。 +: ```bash pip3 install azure-cognitiveservices-speech ``` -> 目前默认发布的镜像和`railway`部署,都基于`apline`,无法安装`azure`的依赖。若有需求请自行基于[`debian`](https://github.com/zhayujie/chatgpt-on-wechat/blob/master/docker/Dockerfile.debian.latest)打包。 -参考[文档](https://learn.microsoft.com/en-us/azure/cognitive-services/speech-service/quickstarts/setup-platform?pivots=programming-language-python&tabs=linux%2Cubuntu%2Cdotnet%2Cjre%2Cmaven%2Cnodejs%2Cmac%2Cpypi) - ## 配置 配置文件的模板在根目录的`config-template.json`中,需复制该模板创建最终生效的 `config.json` 文件: diff --git a/docker/Dockerfile.debian.latest b/docker/Dockerfile.alpine.latest similarity index 50% rename from docker/Dockerfile.debian.latest rename to docker/Dockerfile.alpine.latest index ffe7af3..432075c 100644 --- a/docker/Dockerfile.debian.latest +++ b/docker/Dockerfile.alpine.latest @@ -1,4 +1,4 @@ -FROM python:3.10-slim +FROM python:3.10-alpine LABEL maintainer="foo@bar.com" ARG TZ='Asia/Shanghai' @@ -9,23 +9,19 @@ ENV BUILD_PREFIX=/app ADD . ${BUILD_PREFIX} -RUN apt-get update \ - &&apt-get install -y --no-install-recommends bash \ - ffmpeg espeak libavcodec-extra\ +RUN apk add --no-cache bash ffmpeg espeak \ && cd ${BUILD_PREFIX} \ && cp config-template.json config.json \ && /usr/local/bin/python -m pip install --no-cache --upgrade pip \ - && pip install --no-cache -r requirements.txt \ - && pip install --no-cache -r requirements-optional.txt \ - && pip install azure-cognitiveservices-speech + && pip install --no-cache -r requirements.txt --extra-index-url https://alpine-wheels.github.io/index\ + && pip install --no-cache -r requirements-optional.txt --extra-index-url https://alpine-wheels.github.io/index WORKDIR ${BUILD_PREFIX} ADD docker/entrypoint.sh /entrypoint.sh RUN chmod +x /entrypoint.sh \ - && groupadd -r noroot \ - && useradd -r -g noroot -s /bin/bash -d /home/noroot noroot \ + && adduser -D -h /home/noroot -u 1000 -s /bin/bash noroot \ && chown -R noroot:noroot ${BUILD_PREFIX} USER noroot diff --git a/docker/Dockerfile.latest b/docker/Dockerfile.latest index 0c9bfce..7ec3909 100644 --- a/docker/Dockerfile.latest +++ b/docker/Dockerfile.latest @@ -1,27 +1,32 @@ -FROM python:3.10-alpine +FROM python:3.10-slim LABEL maintainer="foo@bar.com" ARG TZ='Asia/Shanghai' ARG CHATGPT_ON_WECHAT_VER +RUN echo /etc/apt/sources.list +RUN sed -i 's/deb.debian.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list ENV BUILD_PREFIX=/app ADD . ${BUILD_PREFIX} -RUN apk add --no-cache bash ffmpeg espeak libavcodec-extra\ +RUN apt-get update \ + &&apt-get install -y --no-install-recommends bash ffmpeg espeak libavcodec-extra\ && cd ${BUILD_PREFIX} \ && cp config-template.json config.json \ && /usr/local/bin/python -m pip install --no-cache --upgrade pip \ - && pip install --no-cache -r requirements.txt --extra-index-url https://alpine-wheels.github.io/index\ - && pip install --no-cache -r requirements-optional.txt --extra-index-url https://alpine-wheels.github.io/index + && pip install --no-cache -r requirements.txt \ + && pip install --no-cache -r requirements-optional.txt \ + && pip install azure-cognitiveservices-speech WORKDIR ${BUILD_PREFIX} ADD docker/entrypoint.sh /entrypoint.sh RUN chmod +x /entrypoint.sh \ - && adduser -D -h /home/noroot -u 1000 -s /bin/bash noroot \ + && groupadd -r noroot \ + && useradd -r -g noroot -s /bin/bash -d /home/noroot noroot \ && chown -R noroot:noroot ${BUILD_PREFIX} USER noroot diff --git a/requirements-optional.txt b/requirements-optional.txt index 8e73bd0..580e850 100644 --- a/requirements-optional.txt +++ b/requirements-optional.txt @@ -6,7 +6,7 @@ SpeechRecognition # google speech to text gTTS>=2.3.1 # google text to speech pyttsx3>=2.90 # pytsx text to speech baidu_aip>=4.16.10 # baidu voice -# azure-cognitiveservices-speech # azure voice +azure-cognitiveservices-speech # azure voice numpy<=1.24.2 langid # language detect