# Local dev services for petdex contributors. Engine-agnostic, works
# with both `docker compose` and `podman compose`. Brings up the
# minimum stack the app needs: Postgres + Redis. Everything else
# (Clerk, R2, Resend) is either a shared OSS dev instance or a no-op
# fallback in development.
#
# Usage:
#   bun run dev:docker
#
# That script probes for the available container engine, boots this
# compose file, runs drizzle-kit push, seeds, and starts next dev.

name: petdex-dev

services:
  postgres:
    image: postgres:16-alpine
    container_name: petdex-postgres
    restart: unless-stopped
    environment:
      POSTGRES_USER: petdex
      POSTGRES_PASSWORD: petdex
      POSTGRES_DB: petdex
      # The pgvector extension is only used by the optional similarity
      # path (admin queue + vibe search). The image ships without it,
      # so the schema migrations skip the index in dev and the dev
      # build short-circuits when no embeddings are present.
    ports:
      - "127.0.0.1:54320:5432"
    volumes:
      - petdex-postgres-data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U petdex -d petdex"]
      interval: 2s
      timeout: 3s
      retries: 30

  redis:
    image: redis:7-alpine
    container_name: petdex-redis
    restart: unless-stopped
    command: ["redis-server", "--save", "", "--appendonly", "no"]
    ports:
      - "127.0.0.1:63790:6379"
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 2s
      timeout: 3s
      retries: 30

  # Upstash provides @upstash/redis as a REST client. Local Redis is a
  # plain TCP server. srh (serverless-redis-http) exposes a Redis
  # backend over the same REST protocol Upstash speaks, so the app's
  # Redis.fromEnv() works unchanged in dev.
  redis-rest:
    image: hiett/serverless-redis-http:latest
    container_name: petdex-redis-rest
    restart: unless-stopped
    environment:
      SRH_MODE: env
      SRH_TOKEN: petdex-dev-token
      SRH_CONNECTION_STRING: redis://redis:6379
    depends_on:
      redis:
        condition: service_healthy
    ports:
      - "127.0.0.1:8079:80"

volumes:
  petdex-postgres-data:
