version: "3.8"
services:
  postgres:
    image: postgres:17-alpine
    restart: unless-stopped
    environment:
      - POSTGRES_USER=senddock
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
      - POSTGRES_DB=senddock
    volumes:
      - pgdata:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U senddock"]
      interval: 10s
      timeout: 5s
      retries: 6

  redis:
    image: redis:7-alpine
    restart: unless-stopped
    volumes:
      - redisdata:/data
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 10s
      timeout: 3s
      retries: 5

  senddock:
    image: ghcr.io/arkhe-systems/senddock:0.6.5.1
    restart: unless-stopped
    depends_on:
      postgres:
        condition: service_healthy
      redis:
        condition: service_healthy
    environment:
      - DATABASE_URL=postgres://senddock:${POSTGRES_PASSWORD}@postgres:5432/senddock?sslmode=disable
      - REDIS_URL=redis://redis:6379
      - JWT_SECRET=${JWT_SECRET}
      - PUBLIC_URL=${PUBLIC_URL}
      - FRONTEND_URL=${PUBLIC_URL}
      - DEPLOYMENT_MODE=self-hosted
      - SENDDOCK_LICENSE_KEY=${SENDDOCK_LICENSE_KEY}
      - PORT=8080
    expose:
      - 8080
    healthcheck:
      test: ["CMD", "wget", "-qO-", "http://127.0.0.1:8080/health"]
      interval: 30s
      timeout: 5s
      retries: 3
      start_period: 15s

volumes:
  pgdata:
  redisdata:
