services:
  backend:
    build:
      context: .
      dockerfile: docker/Dockerfile.dev
      args:
        BUILDKIT_INLINE_CACHE: 0
    pull_policy: build
    container_name: normogen-backend-dev
    ports:
      - '6500:8000'
    volumes:
      - ./src:/app/src
      - startup-logs:/tmp
    environment:
      - RUST_LOG=debug
      - SERVER_PORT=8000
      - SERVER_HOST=0.0.0.0
      - MONGODB_URI=mongodb://mongodb:27017
      - DATABASE_NAME=normogen_dev
      - JWT_SECRET=dev-jwt-secret-key-minimum-32-chars
      - RUST_LOG_STYLE=always
    depends_on:
      mongodb:
        condition: service_healthy
    networks:
      - normogen-network
    restart: unless-stopped

  mongodb:
    image: mongo:6.0
    container_name: normogen-mongodb-dev
    ports:
      - '27017:27017'
    environment:
      - MONGO_INITDB_DATABASE=normogen_dev
    volumes:
      - mongodb_dev_data:/data/db
    networks:
      - normogen-network
    user: mongodb:mongodb
    healthcheck:
      test: |
        echo 'db.runCommand("ping").ok' | mongosh localhost:27017/test --quiet
      interval: 10s
      timeout: 5s
      retries: 5
      start_period: 60s
    restart: unless-stopped

volumes:
  mongodb_dev_data:
    driver: local
  startup-logs:
    driver: local

networks:
  normogen-network:
    driver: bridge
