Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. # base image
  2. FROM python:3.12-slim-bookworm AS base
  3. WORKDIR /app/api
  4. # Install uv
  5. ENV UV_VERSION=0.7.11
  6. RUN pip install --no-cache-dir uv==${UV_VERSION}
  7. FROM base AS packages
  8. # if you located in China, you can use aliyun mirror to speed up
  9. # RUN sed -i 's@deb.debian.org@mirrors.aliyun.com@g' /etc/apt/sources.list.d/debian.sources
  10. RUN apt-get update \
  11. && apt-get install -y --no-install-recommends gcc g++ libc-dev libffi-dev libgmp-dev libmpfr-dev libmpc-dev
  12. # Install Python dependencies
  13. COPY pyproject.toml uv.lock ./
  14. RUN uv sync --locked
  15. # production stage
  16. FROM base AS production
  17. ENV FLASK_APP=app.py
  18. ENV EDITION=SELF_HOSTED
  19. ENV DEPLOY_ENV=PRODUCTION
  20. ENV CONSOLE_API_URL=http://127.0.0.1:5001
  21. ENV CONSOLE_WEB_URL=http://127.0.0.1:3000
  22. ENV SERVICE_API_URL=http://127.0.0.1:5001
  23. ENV APP_WEB_URL=http://127.0.0.1:3000
  24. EXPOSE 5001
  25. # set timezone
  26. ENV TZ=UTC
  27. WORKDIR /app/api
  28. RUN \
  29. apt-get update \
  30. # Install dependencies
  31. && apt-get install -y --no-install-recommends \
  32. # basic environment
  33. curl nodejs libgmp-dev libmpfr-dev libmpc-dev \
  34. # For Security
  35. expat libldap-2.5-0 perl libsqlite3-0 zlib1g \
  36. # install fonts to support the use of tools like pypdfium2
  37. fonts-noto-cjk \
  38. # install a package to improve the accuracy of guessing mime type and file extension
  39. media-types \
  40. # install libmagic to support the use of python-magic guess MIMETYPE
  41. libmagic1 \
  42. && apt-get autoremove -y \
  43. && rm -rf /var/lib/apt/lists/*
  44. # Copy Python environment and packages
  45. ENV VIRTUAL_ENV=/app/api/.venv
  46. COPY --from=packages ${VIRTUAL_ENV} ${VIRTUAL_ENV}
  47. ENV PATH="${VIRTUAL_ENV}/bin:${PATH}"
  48. # Download nltk data
  49. RUN python -c "import nltk; nltk.download('punkt'); nltk.download('averaged_perceptron_tagger')"
  50. ENV TIKTOKEN_CACHE_DIR=/app/api/.tiktoken_cache
  51. RUN python -c "import tiktoken; tiktoken.encoding_for_model('gpt2')"
  52. # Copy source code
  53. COPY . /app/api/
  54. # Copy entrypoint
  55. COPY docker/entrypoint.sh /entrypoint.sh
  56. RUN chmod +x /entrypoint.sh
  57. ARG COMMIT_SHA
  58. ENV COMMIT_SHA=${COMMIT_SHA}
  59. ENTRYPOINT ["/bin/bash", "/entrypoint.sh"]