services:
  db:
    image: postgres:15
    container_name: odoo_db
    environment:
      POSTGRES_DB: postgres
      POSTGRES_USER: odoo
      POSTGRES_PASSWORD: odoo
      PGDATA: /var/lib/postgresql/data/pgdata
    volumes:
      - ./data/postgres:/var/lib/postgresql/data/pgdata
    ports:
      - "5432:5432"
    restart: unless-stopped
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U odoo"]
      interval: 10s
      timeout: 5s
      retries: 5

  odoo:
    image: odoo:17.0
    container_name: odoo_app
    depends_on:
      db:
        condition: service_healthy
    ports:
      - "8069:8069"
      - "8071:8071"
      - "8072:8072"
    volumes:
      - ./addons:/mnt/extra-addons
      - ./config/odoo.conf:/etc/odoo/odoo.conf
      - ./data/odoo:/var/lib/odoo
    environment:
      HOST: db
      PORT: 5432
      USER: odoo
      PASSWORD: odoo
    restart: unless-stopped

volumes:
  odoo_data:
  postgres_data:
