12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. FROM python:3.7.9
  2. LABEL maintainer="foo@bar.com"
  3. ARG TZ='Asia/Shanghai'
  4. ARG CHATGPT_ON_WECHAT_VER
  5. ENV BUILD_PREFIX=/app \
  6. BUILD_OPEN_AI_API_KEY='YOUR OPEN AI KEY HERE'
  7. RUN apt-get update \
  8. && apt-get install -y --no-install-recommends \
  9. wget \
  10. curl \
  11. && rm -rf /var/lib/apt/lists/* \
  12. && export BUILD_GITHUB_TAG=${CHATGPT_ON_WECHAT_VER:-`curl -sL "https://api.github.com/repos/zhayujie/chatgpt-on-wechat/releases/latest" | \
  13. grep '"tag_name":' | \
  14. sed -E 's/.*"([^"]+)".*/\1/'`} \
  15. && wget -t 3 -T 30 -nv -O chatgpt-on-wechat-${BUILD_GITHUB_TAG}.tar.gz \
  16. https://github.com/zhayujie/chatgpt-on-wechat/archive/refs/tags/${BUILD_GITHUB_TAG}.tar.gz \
  17. && tar -xzf chatgpt-on-wechat-${BUILD_GITHUB_TAG}.tar.gz \
  18. && mv chatgpt-on-wechat-${BUILD_GITHUB_TAG} ${BUILD_PREFIX} \
  19. && rm chatgpt-on-wechat-${BUILD_GITHUB_TAG}.tar.gz \
  20. && cd ${BUILD_PREFIX} \
  21. && cp config-template.json ${BUILD_PREFIX}/config.json \
  22. && sed -i "2s/YOUR API KEY/${BUILD_OPEN_AI_API_KEY}/" ${BUILD_PREFIX}/config.json \
  23. && /usr/local/bin/python -m pip install --no-cache --upgrade pip \
  24. && pip install --no-cache \
  25. itchat-uos==1.5.0.dev0 \
  26. openai
  27. WORKDIR ${BUILD_PREFIX}
  28. ADD ./entrypoint.sh /entrypoint.sh
  29. RUN chmod +x /entrypoint.sh \
  30. && groupadd -r noroot \
  31. && useradd -r -g noroot -s /bin/bash -d /home/noroot noroot \
  32. && chown -R noroot:noroot ${BUILD_PREFIX}
  33. USER noroot
  34. ENTRYPOINT ["/entrypoint.sh"]