services:
  # Runs database migrations for version upgrades with existing data. Skip for new deployments.
  migrate:
    image: nxpsmcd/eiq-ai-toolkit-api:2.1.1
    entrypoint: []
    command: >
      python3 -m pymongo_migrate.cli upgrade
      -u mongodb://root:example@mongo:27017
      -d datastore
      -m /app/db-migration/pymongo_migrations
    depends_on:
      - mongo

  api:
    image: nxpsmcd/eiq-ai-toolkit-api:2.1.1
    container_name: eiq-ai-toolkit-api
    restart: unless-stopped
    ports:
      - 8000:8000
    environment:
      - DATABASE_URL=mongodb://root:example@mongo:27017
      - REDIS_URL=redis://redis:6379
      - DOWNLOAD_SIGNING_SECRET=CHANGE_ME
    volumes:
      - app_data:/app_data

  workers:
    image: nxpsmcd/eiq-ai-toolkit-workers:2.1.1
    container_name: eiq-ai-toolkit-workers
    restart: unless-stopped
    environment:
      - DATABASE_URL=mongodb://root:example@mongo:27017
      - REDIS_URL=redis://redis:6379
    volumes:
      - app_data:/app_data

  frontend:
    image: nxpsmcd/eiq-ai-toolkit-gui:2.1.1
    container_name: eiq-ai-toolkit-gui
    restart: unless-stopped
    ports:
      - 8080:8080

  mongo:
    image: mongo
    container_name: eiq-ai-toolkit-mongo
    restart: unless-stopped
    ports:
      - 27017:27017
    environment:
      MONGO_INITDB_ROOT_USERNAME: root
      MONGO_INITDB_ROOT_PASSWORD: example
    volumes:
      - mongodata:/data/db
      - mongoconfig:/data/configdb

  redis:
    image: redis:alpine
    container_name: eiq-ai-toolkit-redis
    restart: unless-stopped
    ports:
      - 6379:6379
    command: redis-server --loglevel warning
    volumes:
      - redis_data:/data

volumes:
  app_data:
  mongodata:
  mongoconfig:
  redis_data:
