Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions {{ cookiecutter.name }}/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -59,25 +59,30 @@ USER web
RUN python manage.py compilemessages \
&& python manage.py collectstatic --noinput

# Also to mark that when CMD is used in shell form, it is a conscious decision
SHELL ["/bin/bash", "-c"]


#
# web image
#
FROM base AS web
HEALTHCHECK --interval=15s --timeout=15s --start-period=15s --retries=3 \
CMD wget --quiet --tries=1 --spider http://localhost:8000/api/v1/healthchecks/

CMD ["sh", "-c", "python manage.py migrate && uwsgi --master --http=:8000 --venv=/code/.venv/ --wsgi=app.wsgi --workers=2 --threads=2 --harakiri=25 --max-requests=1000 --log-x-forwarded-for"]

#
# worker image
#
FROM base AS worker

ENV _CELERY_APP=app.celery
HEALTHCHECK --interval=15s --timeout=15s --start-period=5s --retries=3 \
CMD celery --app=${_CELERY_APP} inspect ping --destination=celery@$HOSTNAME

CMD ["celery", "--app=${_CELERY_APP}", "worker", "--concurrency=${CONCURENCY:-2}", "--hostname=celery@%h", "--max-tasks-per-child=${MAX_REQUESTS_PER_CHILD:-50}", "--time-limit=${TIME_LIMIT:-900}", "--soft-time-limit=${SOFT_TIME_LIMIT:-45}"]

CMD ["sh", "-c", "celery --app=${_CELERY_APP} worker --concurrency=${CONCURENCY:-2} --hostname=celery@%h --max-tasks-per-child=${MAX_REQUESTS_PER_CHILD:-50} --time-limit=${TIME_LIMIT:-900} --soft-time-limit=${SOFT_TIME_LIMIT:-45}"]

#
# scheduler image
#
FROM base AS scheduler

ENV _SCHEDULER_DB_PATH=/var/db/scheduler
Expand All @@ -88,4 +93,4 @@ VOLUME ${_SCHEDULER_DB_PATH}

ENV _CELERY_APP=app.celery
HEALTHCHECK NONE
CMD ["celery", "--app=${_CELERY_APP}", "beat", "--pidfile=/tmp/celerybeat.pid", "--schedule=${_SCHEDULER_DB_PATH}/celerybeat-schedule.db"]
CMD ["sh", "-c", "celery --app=${_CELERY_APP} beat --pidfile=/tmp/celerybeat.pid --schedule=${_SCHEDULER_DB_PATH}/celerybeat-schedule.db"]