diff --git a/docker-compose.yml b/docker-compose.yml index 78044c03b8..d16ec6ed20 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -20,10 +20,18 @@ services: STORE_MODEL_IN_DB: "True" # allows adding models to proxy via UI env_file: - .env # Load local .env file + depends_on: + - db # Indicates that this service depends on the 'db' service, ensuring 'db' starts first + healthcheck: # Defines the health check configuration for the container + test: [ "CMD", "curl", "-f", "http://localhost:4000/health/liveliness || exit 1" ] # Command to execute for health check + interval: 30s # Perform health check every 30 seconds + timeout: 10s # Health check command times out after 10 seconds + retries: 3 # Retry up to 3 times if health check fails + start_period: 40s # Wait 40 seconds after container start before beginning health checks db: - image: postgres + image: postgres:16 restart: always environment: POSTGRES_DB: litellm @@ -31,6 +39,8 @@ services: POSTGRES_PASSWORD: dbpassword9090 ports: - "5432:5432" + volumes: + - postgres_data:/var/lib/postgresql/data # Persists Postgres data across container restarts healthcheck: test: ["CMD-SHELL", "pg_isready -d litellm -U llmproxy"] interval: 1s @@ -53,6 +63,8 @@ services: volumes: prometheus_data: driver: local + postgres_data: + name: litellm_postgres_data # Named volume for Postgres data persistence # ...rest of your docker-compose config if any