services:
  web:
    build: .
    container_name: 124_webapp
    ports:
      - "80:8000"
    working_dir: /cost-assistant
    volumes:
      - .:/cost-assistant
      - ./data/uploads:/cost-assistant/data/uploads
    env_file:
      - .env
    command: python -m uvicorn main:app --host 0.0.0.0 --port 8000 --reload

  docmost:
    image: docmost/docmost:latest
    container_name: docmost
    depends_on:
      - db
      - redis
    environment:
      APP_URL: "http://einszwovier.local:3000"
      APP_SECRET: "Ltr/i5KY8S8xQQZbaRHVS07gaAqwxPfrMxW6ZetNRqk="
      DATABASE_URL: "postgresql://docmost:einszwo4@db:5432/docmost?schema=public"
      REDIS_URL: "redis://redis:6379"
      MAIL_DRIVER: "smtp"
      SMTP_HOST: "smtp.migadu.com"
      SMTP_PORT: 465
      SMTP_SECURE: "true"
      SMTP_USERNAME: "aron@petau.net"
      SMTP_PASSWORD: "Reprintedservices2766"
      MAIL_FROM_ADDRESS: "aron@petau.net"
      MAIL_FROM_NAME: "einszwovier - docs"
    ports:
      - "3000:3000"
    restart: unless-stopped
    volumes:
      - ./docmost/storage:/app/data/storage

  db:
    image: postgres:16-alpine
    container_name: docmost_postgres
    environment:
      POSTGRES_DB: docmost
      POSTGRES_USER: docmost
      POSTGRES_PASSWORD: einszwo4
    restart: unless-stopped
    volumes:
      - ./docmost/db:/var/lib/postgresql/data

  redis:
    image: redis:7.2-alpine
    container_name: docmost_redis
    restart: unless-stopped
    volumes:
      - ./docmost/redis:/data

  synapse:
    image: matrixdotorg/synapse:latest
    container_name: matrix_server
    restart: always
    ports:
      - "8008:8008"  
    volumes:
      - ./matrix/data:/data
    environment:
      - SYNAPSE_SERVER_NAME=einszwovier.local
      - SYNAPSE_REPORT_STATS=no

  ollama:
    image: ollama/ollama:latest
    container_name: ollama
    ports:
      - 11434:11434
    volumes:
      - ./ollama:/root/.ollama
    tty: true
    restart: unless-stopped

  open-webui:
    image: ghcr.io/open-webui/open-webui:main
    container_name: open-webui
    depends_on:
      - ollama
    ports:
      - 8080:8080
    volumes:
      - ./open-webui:/app/backend/data
    environment:
      - 'OLLAMA_BASE_URL=http://ollama:11434'
      - 'WEBUI_SECRET_KEY=a8cbc11647c471e5a30d9b182a7147a0777e41a6b0cb036fd6a8d967585502c7'
      - 'ENABLE_API=true'
      - 'WEBUI_API_KEY=a8cbc11647c471e5a30d9b182a7147a0777e41a6b0cb036fd6a8d967585502c7'
    extra_hosts:
      - host.docker.internal:host-gateway
    restart: unless-stopped

  watchtower:
    image: containrrr/watchtower:latest
    container_name: watchtower
    restart: unless-stopped
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    command: >
      --cleanup
      --interval 86400

  portainer:
    image: portainer/portainer-ce:latest
    container_name: portainer
    restart: unless-stopped
    ports:
      - "9000:9000"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - portainer_data:/data

volumes:
  portainer_data:
