# Python prefect single-instance stack — apples-to-apples counterpart to # compose.yml (the zig single shape). # # Mirrors the zig single shape: one webserver + one services container backed # by shared postgres + shared redis. Same configuration knobs as the HA # stack (compose.ha-python.yml) since python's official self-hosted setup # uses the prefect_redis bridge whenever postgres+redis are present, but with # a single webapp instead of two. # # Host port allocation (offset by +100 vs compose.yml so both stacks can # run concurrently for bench-compare): # postgres : 5434 → 5432 (zig single uses 5432; HA uses 5432 too; we go +2) # redis : 6381 → 6379 # webapp : 4300 → 4200 # # Usage: # docker compose -f compose.single-python.yml up --build -d # curl http://localhost:4300/api/health # # Tear down (drops postgres volume): # docker compose -f compose.single-python.yml down -v name: prefect-py-single services: postgres: image: postgres:16-alpine environment: POSTGRES_USER: prefect POSTGRES_PASSWORD: prefect POSTGRES_DB: prefect ports: - "127.0.0.1:5434:5432" volumes: - prefect-pgdata-single-python:/var/lib/postgresql/data healthcheck: test: ["CMD-SHELL", "pg_isready -U prefect -d prefect"] interval: 2s timeout: 2s retries: 10 redis: image: redis:7-alpine command: ["redis-server", "--appendonly", "no"] ports: - "127.0.0.1:6381:6379" healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 1s timeout: 1s retries: 10 webapp: build: context: .. dockerfile: docker/Dockerfile.python-ha command: ["prefect", "server", "start", "--host", "0.0.0.0", "--port", "4200"] environment: &server-env PREFECT_SERVER_LOGGING_LEVEL: WARNING PREFECT_LOGGING_LEVEL: WARNING PREFECT_SERVER_DATABASE_CONNECTION_URL: "postgresql+asyncpg://prefect:prefect@postgres:5432/prefect" PREFECT_MESSAGING_BROKER: "prefect_redis.messaging" PREFECT_MESSAGING_CACHE: "prefect_redis.messaging" PREFECT_SERVER_EVENTS_CAUSAL_ORDERING: "prefect_redis.ordering" PREFECT_SERVER_CONCURRENCY_LEASE_STORAGE: "prefect_redis.lease_storage" PREFECT_SERVER_DOCKET_URL: "redis://redis:6379/1" PREFECT_REDIS_MESSAGING_HOST: "redis" PREFECT_REDIS_MESSAGING_PORT: "6379" PREFECT_REDIS_MESSAGING_DB: "0" ports: - "127.0.0.1:4300:4200" depends_on: postgres: condition: service_healthy redis: condition: service_healthy healthcheck: test: ["CMD-SHELL", "python -c 'import urllib.request, sys; sys.exit(0 if urllib.request.urlopen(\"http://localhost:4200/api/health\", timeout=2).status==200 else 1)'"] interval: 5s timeout: 4s retries: 12 start_period: 30s services: build: context: .. dockerfile: docker/Dockerfile.python-ha command: ["prefect", "server", "services", "start"] environment: <<: *server-env depends_on: postgres: condition: service_healthy redis: condition: service_healthy webapp: condition: service_healthy volumes: prefect-pgdata-single-python: