Dockerfile 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. FROM python:3.10-slim
  2. WORKDIR /app
  3. # https://github.com/aptible/supercronic
  4. ARG TARGETARCH
  5. ENV SUPERCRONIC_VERSION=v0.2.34
  6. RUN set -ex && \
  7. apt-get update && \
  8. apt-get install -y --no-install-recommends curl && \
  9. case ${TARGETARCH} in \
  10. amd64) \
  11. export SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/${SUPERCRONIC_VERSION}/supercronic-linux-amd64; \
  12. export SUPERCRONIC_SHA1SUM=e8631edc1775000d119b70fd40339a7238eece14; \
  13. export SUPERCRONIC=supercronic-linux-amd64; \
  14. ;; \
  15. arm64) \
  16. export SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/${SUPERCRONIC_VERSION}/supercronic-linux-arm64; \
  17. export SUPERCRONIC_SHA1SUM=4ab6343b52bf9da592e8b4bb7ae6eb5a8e21b71e; \
  18. export SUPERCRONIC=supercronic-linux-arm64; \
  19. ;; \
  20. arm) \
  21. export SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/${SUPERCRONIC_VERSION}/supercronic-linux-arm; \
  22. export SUPERCRONIC_SHA1SUM=4ba4cd0da62082056b6def085fa9377d965fbe01; \
  23. export SUPERCRONIC=supercronic-linux-arm; \
  24. ;; \
  25. 386) \
  26. export SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/${SUPERCRONIC_VERSION}/supercronic-linux-386; \
  27. export SUPERCRONIC_SHA1SUM=80b4fff03a8d7bf2f24a1771f37640337855e949; \
  28. export SUPERCRONIC=supercronic-linux-386; \
  29. ;; \
  30. *) \
  31. echo "Unsupported architecture: ${TARGETARCH}"; \
  32. exit 1; \
  33. ;; \
  34. esac && \
  35. curl -fsSLO "$SUPERCRONIC_URL" && \
  36. echo "${SUPERCRONIC_SHA1SUM} ${SUPERCRONIC}" | sha1sum -c - && \
  37. chmod +x "$SUPERCRONIC" && \
  38. mv "$SUPERCRONIC" "/usr/local/bin/${SUPERCRONIC}" && \
  39. ln -s "/usr/local/bin/${SUPERCRONIC}" /usr/local/bin/supercronic && \
  40. apt-get remove -y curl && \
  41. apt-get clean && \
  42. rm -rf /var/lib/apt/lists/*
  43. COPY requirements.txt .
  44. RUN pip install --no-cache-dir -r requirements.txt
  45. COPY main.py .
  46. COPY docker/manage.py .
  47. # 复制 entrypoint.sh 并强制转换为 LF 格式
  48. COPY docker/entrypoint.sh /entrypoint.sh.tmp
  49. RUN sed -i 's/\r$//' /entrypoint.sh.tmp && \
  50. mv /entrypoint.sh.tmp /entrypoint.sh && \
  51. chmod +x /entrypoint.sh && \
  52. chmod +x manage.py && \
  53. mkdir -p /app/config /app/output
  54. ENV PYTHONUNBUFFERED=1 \
  55. CONFIG_PATH=/app/config/config.yaml \
  56. FREQUENCY_WORDS_PATH=/app/config/frequency_words.txt
  57. ENTRYPOINT ["/entrypoint.sh"]