services:
  db:
    image: postgres:15
    environment:
      POSTGRES_DB: postgres
      POSTGRES_USER: odoo
      POSTGRES_PASSWORD: ${SODOO_DB_PASSWORD}
      PGDATA: /var/lib/postgresql/data/pgdata
    volumes:
      - postgres_data:/var/lib/postgresql/data/pgdata
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U odoo"]
      interval: 10s
      timeout: 5s
      retries: 5
    restart: unless-stopped

  odoo:
    image: odoo:17.0
    depends_on:
      db:
        condition: service_healthy
    volumes:
      - ./addons:/mnt/extra-addons
      - ./work_scripts:/mnt/work_scripts
      - ./config/odoo.prod.conf:/etc/odoo/odoo.conf:ro
      - ./scripts/odoo-start.sh:/odoo-start.sh:ro
      - odoo_data:/var/lib/odoo
    environment:
      HOST: db
      PORT: 5432
      USER: odoo
      PASSWORD: ${SODOO_DB_PASSWORD}
      SODOO_DB_PASSWORD: ${SODOO_DB_PASSWORD}
      SODOO_ADMIN_PASSWORD: ${SODOO_ADMIN_PASSWORD}
      SODOO_WEB_BASE_URL: https://sodoo.appnotify.co.za
    command: ["/bin/sh", "/odoo-start.sh"]
    restart: unless-stopped

volumes:
  postgres_data:
  odoo_data:
