Currently the docker-compose file does not define any dependencies between containers. So containers come up in random order. This can lead to situations where frontend is ready but backend (Django + db) are not.
The compose file should be updated to establish container dependencies to ensure a working stack on start up:
Currently the
docker-compose
file does not define any dependencies between containers. So containers come up in random order. This can lead to situations where frontend is ready but backend (Django + db) are not.The compose file should be updated to establish container dependencies to ensure a working stack on start up:
Example docker-compose file with health checks
```dockerfile services: api: image: fast-ffmpeg restart: unless-stopped working_dir: /app ports: - ${FAST_API_PORT:-8000}:8000 depends_on: - worker environment: TZ: ${GLOBAL_TIMEZONE} SOURCE_MEDIA_FOLDER: /media OUTPUT_FOLDER: /output CELERY_RESULT_BACKEND: ${CELERY_RESULT_BACKEND:-redis://redis:6379/0} CELERY_BROKER_URL: ${CELERY_BROKER_URL:-amqp://guest@broker//} PROFILE_CFG: /app/profiles.cfg volumes: - ./app:/app - ./profiles.cfg:/app/profiles.cfg - ${SOURCE_ROOT}:${SOURCE_ROOT} logging: driver: json-file options: max-size: 500m max-file: 2 entrypoint: [ "fastapi", "${FAST_API_DEPLOYMENT_MODE:-dev}", "--host", "0.0.0.0", "main.py" ] redis: image: redis:alpine restart: unless-stopped environment: TZ: ${GLOBAL_TIMEZONE} logging: driver: json-file options: max-size: 500m max-file: 2 healthcheck: test: [ "CMD-SHELL", "redis-cli ping | grep PONG" ] retries: 5 interval: 2s broker: image: rabbitmq:alpine hostname: fast-ffmpeg-broker environment: TZ: ${GLOBAL_TIMEZONE} restart: unless-stopped logging: driver: json-file options: max-size: 500m max-file: 2 healthcheck: test: [ "CMD-SHELL", "rabbitmq-diagnostics check_port_connectivity" ] retries: 5 interval: 5s worker: image: fast-ffmpeg restart: unless-stopped working_dir: /app depends_on: broker: condition: service_healthy redis: condition: service_healthy volumes: - ./app:/app - ${SOURCE_ROOT}:${SOURCE_ROOT} - ${FFMPEG_BINARIES}:/opt/ffmpeg environment: TZ: ${GLOBAL_TIMEZONE} CAPTURE_SUBPROCESS_OUTPUT: ${CAPTURE_SUBPROCESS_OUTPUT:-False} CELERY_BROKER_URL: ${CELERY_BROKER_URL:-amqp://guest@broker//} CELERY_RESULT_BACKEND: ${CELERY_RESULT_BACKEND:-redis://redis:6379/0} CELERY_AUTOSCALE_MAX: ${CELERY_AUTOSCALE_MAX:-4} CELERY_AUTOSCALE_MIN: ${CELERY_AUTOSCALE_MIN:-2} logging: driver: json-file options: max-size: 500m max-file: 2 ```