version: "3.8"

services:
  invoiceshelf-postgres:
    image: postgres:15
    networks:
      - dokploy-network
    volumes:
      - invoiceshelf-postgres-data:/var/lib/postgresql/data
    environment:
      - POSTGRES_PASSWORD=${DB_PASSWORD}
      - POSTGRES_USER=${DB_USERNAME}
      - POSTGRES_DB=${DB_DATABASE}
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U ${DB_USERNAME}"]
      interval: 10s
      timeout: 5s
      retries: 5

  invoiceshelf-app:
    image: invoiceshelf/invoiceshelf:latest
    networks:
      - dokploy-network
    volumes:
      - invoiceshelf-app-data:/data
      - invoiceshelf-app-conf:/conf
    environment:
      - PHP_TZ=UTC
      - TIMEZONE=UTC
      - APP_NAME=InvoiceShelf
      - APP_ENV=production
      - APP_DEBUG=false
      - APP_URL=http://${INVOICESHELF_HOST}
      - DB_CONNECTION=pgsql
      - DB_HOST=invoiceshelf-postgres
      - DB_PORT=5432
      - DB_DATABASE=${DB_DATABASE}
      - DB_USERNAME=${DB_USERNAME}
      - DB_PASSWORD=${DB_PASSWORD}
      - CACHE_STORE=file
      - SESSION_DRIVER=file
      - SESSION_LIFETIME=120
      - SESSION_ENCRYPT=true
      - SESSION_PATH=/
      - SESSION_DOMAIN=${INVOICESHELF_HOST}
      - SANCTUM_STATEFUL_DOMAINS=${INVOICESHELF_HOST}
      - STARTUP_DELAY=10
    depends_on:
      invoiceshelf-postgres:
        condition: service_healthy

networks:
  dokploy-network:
    external: true

volumes:
  invoiceshelf-postgres-data:
  invoiceshelf-app-data:
  invoiceshelf-app-conf: 