services:
  app:
    build:
      context: .
      dockerfile: Dockerfile
    restart: always
    environment:
      - MONGODB_URI=${MONGODB_URI}
      - ADMIN_PASSWORD=${ADMIN_PASSWORD}
      - JWT_SECRET=${JWT_SECRET}
      - NODE_ENV=production
    networks:
      - lifeos-network
    depends_on:
      - db

  db:
    image: mongo:latest
    restart: always
    environment:
      - MONGO_INITDB_ROOT_USERNAME=${MONGO_USER:?MONGO_USER is required}
      - MONGO_INITDB_ROOT_PASSWORD=${MONGO_PASSWORD:?MONGO_PASSWORD is required}
    volumes:
      - mongo-data:/data/db
    networks:
      - lifeos-network

  caddy:
    image: caddy:latest
    restart: always
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile
      - caddy-data:/data
      - caddy-config:/config
    networks:
      - lifeos-network
    depends_on:
      - app

networks:
  lifeos-network:
    driver: bridge

volumes:
  mongo-data:
  caddy-data:
  caddy-config:
