diff --git a/docker-compose.yml b/docker-compose.yml index ab03b07f..00766f83 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -28,13 +28,13 @@ services: web: <<: *app - command: sh start-web.sh ports: - "8000:8000" celery: <<: *app - command: celery -A dynamicweb worker -l info + environment: + ROLE: celery volumes: pgdata: diff --git a/entrypoint.sh b/entrypoint.sh index 7d024a79..7829b27f 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -47,4 +47,15 @@ for _ in range(60): sys.exit("postgres at %s:%s not reachable" % (host, port)) PYEOF -exec "$@" +# Explicit arguments win (docker compose run web python manage.py shell); +# otherwise ROLE decides what this container does: web (default), celery, or +# migrate (run the migrations and exit). +if [ "$#" -gt 0 ]; then + exec "$@" +fi +case "${ROLE:-web}" in + web) exec sh start-web.sh ;; + celery) exec celery -A dynamicweb worker -l "${CELERY_LOGLEVEL:-info}" ;; + migrate) MIGRATE_ONLY=True exec sh start-web.sh ;; + *) echo "unknown ROLE '$ROLE' (web, celery, migrate)" >&2; exit 1 ;; +esac