version: "3.8" services: prefect-server: image: prefecthq/prefect:${PREFECT_VERSION:-3-latest} container_name: prefect-server restart: unless-stopped ports: - "${PREFECT_PORT:-4200}:4200" volumes: - prefect_data:/root/.prefect - prefect_flows:/flows environment: - PREFECT_SERVER_API_HOST=0.0.0.0 - PREFECT_SERVER_API_PORT=4200 - PREFECT_API_DATABASE_CONNECTION_URL=postgresql+asyncpg://${PG_USER:-prefect}:${PG_PASSWORD:-prefect}@prefect-db:5432/${PG_DB:-prefect} - PREFECT_SERVER_ANALYTICS_ENABLED=${ANALYTICS:-false} command: prefect server start depends_on: prefect-db: condition: service_healthy prefect-worker: image: prefecthq/prefect:${PREFECT_VERSION:-3-latest} container_name: prefect-worker restart: unless-stopped volumes: - prefect_flows:/flows - /var/run/docker.sock:/var/run/docker.sock environment: - PREFECT_API_URL=http://prefect-server:4200/api command: prefect worker start --pool default-agent-pool --type docker depends_on: - prefect-server prefect-db: image: postgres:16-alpine container_name: prefect-db restart: unless-stopped environment: - POSTGRES_USER=${PG_USER:-prefect} - POSTGRES_PASSWORD=${PG_PASSWORD:-prefect} - POSTGRES_DB=${PG_DB:-prefect} volumes: - prefect_pg_data:/var/lib/postgresql/data healthcheck: test: ["CMD-SHELL", "pg_isready -U ${PG_USER:-prefect}"] interval: 10s timeout: 5s retries: 5 volumes: prefect_data: prefect_flows: prefect_pg_data: