# Configuration for libredesk setup

# Name of the big-bear-libredesk application
name: big-bear-libredesk
# Service definitions for the big-bear-libredesk application
services:
  # Service name: big-bear-libredesk
  # The `big-bear-libredesk` service definition
  big-bear-libredesk:
    # Name of the container
    container_name: big-bear-libredesk
    # Image to be used for the container
    image: libredesk/libredesk:v0.7.4-alpha
    # Container restart policy
    restart: unless-stopped
    # Environment variables
    environment:
      - LIBREDESK_SYSTEM_USER_PASSWORD="c6b51a4e-ab9d-4f4f-933e-e96ed3570c1A"
    # Volumes to be mounted to the container
    volumes:
      # Mounting the local libredesk/uploads directory to /libredesk/uploads inside the container
      - /DATA/AppData/$AppID/uploads:/libredesk/uploads
      # Mounting the local libredesk/config.toml directory to /libredesk/config.toml inside the container
      - /DATA/AppData/$AppID/config:/libredesk/config
    # Ports mapping between host and container
    ports:
      # Mapping port 9000 of the host to port 9000 of the container
      - "9000:9000"
    command: [sh, -c, "./libredesk --install --idempotent-install --yes --config /libredesk/config/config.toml && ./libredesk --upgrade --yes --config /libredesk/config/config.toml && ./libredesk --config /libredesk/config/config.toml"]
    # Dependencies
    depends_on:
      - big-bear-libredesk-db
      - big-bear-libredesk-redis
    # Networks
    networks:
      - big-bear-libredesk-network
    x-casaos:
      envs:
        - container: LIBREDESK_SYSTEM_USER_PASSWORD
          description:
            en_us: 'Container Variable: LIBREDESK_SYSTEM_USER_PASSWORD'
      volumes:
        - container: /libredesk/uploads
          description:
            en_us: 'Container Path: /libredesk/uploads'
        - container: /libredesk/config
          description:
            en_us: 'Container Path: /libredesk/config'
      ports:
        - container: "9000"
          description:
            en_us: 'Container Port: 9000'
  # PostgreSQL database
  big-bear-libredesk-db:
    image: postgres:17-alpine
    container_name: big-bear-libredesk-db
    restart: unless-stopped
    networks:
      - big-bear-libredesk-network
    ports:
      - "5432:5432"
    environment:
      # Set these environment variables to configure the database, defaults to libredesk.
      POSTGRES_USER: libredesk
      POSTGRES_PASSWORD: libredesk
      POSTGRES_DB: big_bear_libredesk
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U libredesk"]
      interval: 10s
      timeout: 5s
      retries: 6
    volumes:
      - /DATA/AppData/$AppID/data/postgres:/var/lib/postgresql/data
    x-casaos:
      envs:
        - container: POSTGRES_USER
          description:
            en_us: 'Container Variable: POSTGRES_USER'
        - container: POSTGRES_PASSWORD
          description:
            en_us: 'Container Variable: POSTGRES_PASSWORD'
        - container: POSTGRES_DB
          description:
            en_us: 'Container Variable: POSTGRES_DB'
      volumes:
        - container: /var/lib/postgresql/data
          description:
            en_us: 'Container Path: /var/lib/postgresql/data'
      ports:
        - container: "5432"
          description:
            en_us: 'Container Port: 5432'
  # Redis
  big-bear-libredesk-redis:
    image: redis:7.4.6-alpine@sha256:7a7c6b5c49a6896d0a58ee0c6dc0dcabe14f30f0a2f7d2d1362d276fa2d43166
    container_name: big-bear-libredesk-redis
    restart: unless-stopped
    ports:
      - "6379:6379"
    networks:
      - big-bear-libredesk-network
    volumes:
      - /DATA/AppData/$AppID/data/redis:/data
    x-casaos:
      volumes:
        - container: /data
          description:
            en_us: 'Container Path: /data'
      ports:
        - container: "6379"
          description:
            en_us: 'Container Port: 6379'
networks:
  big-bear-libredesk-network:
    driver: bridge
x-casaos:
  # Supported CPU architectures for this application
  architectures:
    - amd64
    - arm64
  # Main service for this application
  main: big-bear-libredesk
  # Detailed description for the application
  description:
    en_us: Open source, self-hosted customer support desk. Single binary app.
  # Brief tagline for the application
  tagline:
    en_us: Open source, self-hosted customer support desk. Single binary app.
  # Developer's information
  developer: libredesk
  # Author of this particular configuration
  author: BigBearTechWorld
  # Icon URL for the application
  icon: https://cdn.jsdelivr.net/gh/bigbeartechworld/big-bear-universal-apps/apps/_example/logo.jpg
  # Thumbnail image for the application (if any)
  thumbnail: ""
  # Installation tips
  tips:
    before_install:
      en_us: |
        Read this before installing: https://community.bigbeartechworld.com/t/added-libredesk-to-bigbearcasaos/2993#p-5277-documentation-4
  # Title for the application
  title:
    en_us: Libredesk
  # Category under which the application falls
  category: BigBearCasaOS
  # Default port mapping for the application
  port_map: "9000"
