services:
  postgres:
    image: postgres:16-alpine
    container_name: mdv-dev-postgres
    restart: unless-stopped
    environment:
      # Dev-only credentials. Public by design, never reuse them outside local dev.
      POSTGRES_USER: mdv
      POSTGRES_PASSWORD: mdv_dev_only
      POSTGRES_DB: mercadodevida
    ports:
      - '5432:5432'
    volumes:
      - mdv_pg_data:/var/lib/postgresql/data
    healthcheck:
      test: ['CMD-SHELL', 'pg_isready -U mdv -d mercadodevida']
      interval: 2s
      timeout: 3s
      retries: 30

  redis:
    image: redis:7-alpine
    container_name: mdv-dev-redis
    restart: unless-stopped
    command:
      ['redis-server', '--appendonly', 'yes', '--appendfsync', 'everysec', '--save', '60', '1']
    ports:
      - '6379:6379'
    volumes:
      - mdv_redis_data:/data
    healthcheck:
      test: ['CMD', 'redis-cli', 'ping']
      interval: 2s
      timeout: 3s
      retries: 30

volumes:
  mdv_pg_data:
    # Keep the existing Docker volume explicit so Compose project-name changes
    # cannot silently create an empty PostgreSQL volume.
    name: project_mdv_pg_data
  mdv_redis_data:
    # Keep the existing Docker volume explicit and persist Redis AOF/RDB files.
    name: project_mdv_redis_data
