Browse Source

Crontab Support para Task Periodico

Tomás Ponce Gessi 3 năm trước cách đây
mục cha
commit
608888dbac
3 tập tin đã thay đổi với 15 bổ sung1 xóa
  1. 4 1
      Dockerfile
  2. 1 0
      app/requirements.txt
  3. 10 0
      entrypoint.sh

+ 4 - 1
Dockerfile

@@ -1,4 +1,4 @@
-FROM python:3.9-buster
+FROM python:3.9-alpine
 # don't write .pyc files on import
 ENV PYTHONDONTWRITEBYTECODE 1
 # force stdout and stderr to be unbuffered
@@ -8,4 +8,7 @@ EXPOSE 8000
 WORKDIR /app
 COPY ./app .
 RUN pip install -r /app/requirements.txt
+COPY ./entrypoint.sh /
+RUN chmod +x /entrypoint.sh
+ENTRYPOINT [ "/entrypoint.sh" ]
 CMD python manage.py runserver 0.0.0.0:8000

+ 1 - 0
app/requirements.txt

@@ -13,3 +13,4 @@ requests==2.27.1
 sqlparse==0.4.2
 urllib3==1.26.9
 zipp==3.8.0
+django-crontab==0.7.1

+ 10 - 0
entrypoint.sh

@@ -0,0 +1,10 @@
+#!/bin/sh
+
+# Add crontabs from Django:
+python manage.py crontab add
+
+# Launch the Cron daemon:
+crond -f &
+
+# Launch Docker Command:
+exec "$@"