Dockerfile 894 B

1234567891011121314151617181920212223
  1. FROM registry.cn-hangzhou.aliyuncs.com/hexiaoshi/python:3.10
  2. RUN apt-get update && apt-get -y install tzdata cron vim && ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
  3. ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
  4. WORKDIR /app
  5. COPY . /app/
  6. RUN mv /app/crontab /etc/cron.d/crontab && chmod 0644 /etc/cron.d/crontab \
  7. && /usr/bin/crontab /etc/cron.d/crontab \
  8. && pip install --upgrade pip setuptools -i https://mirrors.aliyun.com/pypi/simple \
  9. && pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple
  10. RUN find . | grep -E "(__pycache__|Dockerfile|\.md|\.pyc|\.pyo$)" | xargs rm -rf && python3 -m compileall -b . \
  11. && find . -name "*.py" |xargs rm -rf && touch /var/log/cron.log
  12. VOLUME ["/etc/cron.d"]
  13. CMD /bin/bash -c "/usr/bin/crontab /etc/cron.d/crontab && cron && tail -f /var/log/cron.log"