# Configuration for libretranslate setup

# Name of the big-bear-libretranslate application
name: big-bear-libretranslate
# Service definitions for the big-bear-libretranslate application
services:
  # Service name: big-bear-libretranslate
  # The `big-bear-libretranslate` service definition
  big-bear-libretranslate:
    # Name of the container
    container_name: big-bear-libretranslate
    # Image to be used for the container
    image: libretranslate/libretranslate:v1.9.6
    # Container restart policy
    restart: unless-stopped
    environment:
      - LT_API_KEYS=true # Enables API key authentication for the LibreTranslate service.
      - LT_API_KEYS_DB_PATH=/app/db/api_keys.db # Specifies the path within the container where API keys are stored.
      - LT_UPDATE_MODELS=true # Allows the LibreTranslate service to update its translation models on startup.
      - LT_LOAD_ONLY=en,fr,es,de,it,pt,ru,ja,zh # Restricts the languages loaded by LibreTranslate to these language codes.
    volumes:
      - /DATA/AppData/$AppID/db:/app/db # Mounts a volume at /app/db within the container for persistent API key storage.
      - /DATA/AppData/$AppID/.local:/home/libretranslate/.local # Mounts a volume for storing and updating translation models.
    # Ports mapping between host and container
    ports:
      # Mapping port 5000 of the host to port 5000 of the container
      - "5000:5000"
    tty: true # Allocates a pseudo-TTY, which can be useful for interactive applications and logging.
    healthcheck: # Defines a health check for the container to ensure it's running correctly.
      # This command is run within the container to check its health.
      # If the command exits with a 0 status, the service is considered healthy. Any other exit status indicates an unhealthy service.
      test: ["CMD-SHELL", "./venv/bin/python scripts/healthcheck.py"]
    x-casaos:
      envs:
        - container: LT_API_KEYS
          description:
            en_us: 'Container Variable: LT_API_KEYS'
        - container: LT_API_KEYS_DB_PATH
          description:
            en_us: 'Container Variable: LT_API_KEYS_DB_PATH'
        - container: LT_UPDATE_MODELS
          description:
            en_us: 'Container Variable: LT_UPDATE_MODELS'
        - container: LT_LOAD_ONLY
          description:
            en_us: 'Container Variable: LT_LOAD_ONLY'
      volumes:
        - container: /app/db
          description:
            en_us: 'Container Path: /app/db'
        - container: /home/libretranslate/.local
          description:
            en_us: 'Container Path: /home/libretranslate/.local'
      ports:
        - container: "5000"
          description:
            en_us: 'Container Port: 5000'
x-casaos:
  # Supported CPU architectures for this application
  architectures:
    - amd64
    - arm64
  # Main service for this application
  main: big-bear-libretranslate
  # Detailed description for the application
  description:
    en_us: Free and Open Source Machine Translation API, entirely self-hosted. Unlike other APIs, it doesn't rely on proprietary providers such as Google or Azure to perform translations. Instead, its translation engine is powered by the open source Argos Translate library.
  # Brief tagline for the application
  tagline:
    en_us: Free and Open Source Machine Translation API. 100% self-hosted, offline capable and easy to setup.
  # Developer's information
  developer: LibreTranslate
  # Author of this particular configuration
  author: BigBearTechWorld
  # Icon URL for the application
  icon: https://cdn.jsdelivr.net/gh/bigbeartechworld/big-bear-universal-apps/apps/libretranslate/logo.png
  # Thumbnail image for the application (if any)
  thumbnail: ""
  # Title for the application
  title:
    en_us: LibreTranslate
  # Category under which the application falls
  category: BigBearCasaOS
  # Default port mapping for the application
  port_map: "5000"
