# Configuration for peppermint setup

# Name of the big-bear-maybe-finance application
name: big-bear-maybe-finance
# Service definitions for the big-bear-maybe-finance application
services:
  # Service name: app
  # The `app` service definition
  big-bear-maybe-finance:
    # Name of the container
    container_name: big-bear-maybe-finance
    # Image to be used for the container
    image: ghcr.io/maybe-finance/maybe:sha-347c0a790693031fdd3b32792b5b6792693d1805
    # Container restart policy
    restart: unless-stopped
    # Privilege of the container
    privileged: false
    # Uses default network mode
    networks:
      # Use the default Docker network
      - big_bear_maybe_finance_network
    # Volumes to be mounted to the container
    volumes:
      # Mounting the local maybe/pp-storage directory to /rails/storage inside the container
      - /DATA/AppData/$AppID/app-storage:/rails/storage
    # Ports mapping between host and container
    ports:
      # Mapping port 4000 of the host to port 3000 of the container
      - 4000:3000
    # Environment variables
    environment:
      # Indicates the application is self-hosted
      SELF_HOSTED: "true"
      # SSL configuration
      RAILS_FORCE_SSL: "false"
      # SSL assumption configuration
      RAILS_ASSUME_SSL: "false"
      # Sets the execution mode for GoodJob
      GOOD_JOB_EXECUTION_MODE: async
      # Secret key for Rails application
      SECRET_KEY_BASE: SECRET_KEY_BASE
      # Hostname for the PostgreSQL database service
      DB_HOST: big-bear-maybe-finance-postgres
      # Name of the PostgreSQL database
      POSTGRES_DB: maybe_production
      # PostgreSQL user
      POSTGRES_USER: maybe_user
      # Password for the PostgreSQL user
      POSTGRES_PASSWORD: casaos
      # Redis URL for caching and job queue
      REDIS_URL: redis://big-bear-maybe-finance-redis:6379/1
    # This section specifies that the `app` service depends on another service named `postgres`.
    depends_on:
      big-bear-maybe-finance-postgres:
        # Ensures that the `app` service starts only after `postgres` is healthy
        condition: service_healthy
      big-bear-maybe-finance-redis:
        # Ensures that the `app` service starts only after `redis` is healthy
        condition: service_healthy
    x-casaos:
      envs:
        - container: SELF_HOSTED
          description:
            en_us: 'Container Variable: SELF_HOSTED'
        - container: RAILS_FORCE_SSL
          description:
            en_us: 'Container Variable: RAILS_FORCE_SSL'
        - container: RAILS_ASSUME_SSL
          description:
            en_us: 'Container Variable: RAILS_ASSUME_SSL'
        - container: GOOD_JOB_EXECUTION_MODE
          description:
            en_us: 'Container Variable: GOOD_JOB_EXECUTION_MODE'
        - container: SECRET_KEY_BASE
          description:
            en_us: 'Container Variable: SECRET_KEY_BASE'
        - container: DB_HOST
          description:
            en_us: 'Container Variable: DB_HOST'
        - container: POSTGRES_DB
          description:
            en_us: 'Container Variable: POSTGRES_DB'
        - container: POSTGRES_USER
          description:
            en_us: 'Container Variable: POSTGRES_USER'
        - container: POSTGRES_PASSWORD
          description:
            en_us: 'Container Variable: POSTGRES_PASSWORD'
        - container: REDIS_URL
          description:
            en_us: 'Container Variable: REDIS_URL'
      volumes:
        - container: /rails/storage
          description:
            en_us: 'Container Path: /rails/storage'
      ports:
        - container: "3000"
          description:
            en_us: 'Container Port: 3000'
  # Service name: big-bear-maybe-finance-postgres
  # The `big-bear-maybe-finance-postgres` service definition
  big-bear-maybe-finance-postgres:
    # Name of the container
    container_name: big-bear-maybe-finance-postgres
    # Image to be used for the container
    image: postgres:16
    # Container restart policy
    restart: unless-stopped
    # Volumes to be mounted to the container
    volumes:
      # Mounting the local maybe/postgres-data directory to /var/lib/postgresql/data inside the container
      - /DATA/AppData/$AppID/postgres-data:/var/lib/postgresql/data
    # Environment variables
    environment:
      # Name of the database to create
      POSTGRES_DB: maybe_production
      # PostgreSQL user
      POSTGRES_USER: maybe_user
      # Password for the PostgreSQL user
      POSTGRES_PASSWORD: casaos
    # Health check configuration for the PostgreSQL service
    healthcheck:
      # Command to check if PostgreSQL is ready
      test: ["CMD-SHELL", "pg_isready -U maybe_user -d maybe_production"]
      # Interval between health checks
      interval: 5s
      # Timeout for the health check command
      timeout: 5s
      # Number of retries before considering the service unhealthy
      retries: 5
    # Network configuration for the PostgreSQL service
    networks:
      # Use the default Docker network
      - big_bear_maybe_finance_network
    x-casaos:
      envs:
        - container: POSTGRES_DB
          description:
            en_us: 'Container Variable: POSTGRES_DB'
        - container: POSTGRES_USER
          description:
            en_us: 'Container Variable: POSTGRES_USER'
        - container: POSTGRES_PASSWORD
          description:
            en_us: 'Container Variable: POSTGRES_PASSWORD'
      volumes:
        - container: /var/lib/postgresql/data
          description:
            en_us: 'Container Path: /var/lib/postgresql/data'
  # Service name: big-bear-maybe-finance-redis
  # The `big-bear-maybe-finance-redis` service definition
  big-bear-maybe-finance-redis:
    # Name of the container
    container_name: big-bear-maybe-finance-redis
    # Image to be used for the container
    image: redis:7.4.6-alpine@sha256:7a7c6b5c49a6896d0a58ee0c6dc0dcabe14f30f0a2f7d2d1362d276fa2d43166
    # Container restart policy
    restart: unless-stopped
    # Volumes to be mounted to the container
    volumes:
      # Mounting the local maybe/redis-data directory to /data inside the container
      - /DATA/AppData/$AppID/redis-data:/data
    # Health check configuration for the Redis service
    healthcheck:
      # Command to check if Redis is ready and responds with exactly "PONG"
      test: ["CMD", "sh", "-c", "[ \"$(redis-cli ping)\" = \"PONG\" ]"]
      # Interval between health checks
      interval: 5s
      # Timeout for the health check command
      timeout: 5s
      # Number of retries before considering the service unhealthy
      retries: 5
    # Network configuration for the Redis service
    networks:
      # Use the default Docker network
      - big_bear_maybe_finance_network
    x-casaos:
      volumes:
        - container: /data
          description:
            en_us: 'Container Path: /data'
# Definition of networks used in the services
networks:
  big_bear_maybe_finance_network:
    # Custom name for the default network
    name: big_bear_maybe_finance_network
x-casaos:
  # Supported CPU architectures for this application
  architectures:
    - amd64
    - arm64
  # Main service for this application
  main: big-bear-maybe-finance
  # Detailed description for the application
  description:
    en_us: Maybe is a fully* open-source OS for your personal finances built by a small team alongside an incredible community Discord
  # Brief tagline for the application
  tagline:
    en_us: maybe-finance
  # Developer's information
  developer: Maybe Finance
  # Author of this particular configuration
  author: BigBearCommunity
  # Icon URL for the application
  icon: https://raw.githubusercontent.com/maybe-finance/maybe/refs/heads/main/app/assets/images/logo-color.png
  # Thumbnail image for the application (if any)
  thumbnail: ""
  # Installation tips
  tips:
    before_install:
      en_us: |
        ### Additional Instructions:
        Generate the app secret key:

          1. Open a terminal and digit:

          ```bash
          head -c 64 /dev/urandom | od -An -tx1 | tr -d ' \n' && echo
          ```
          2. Copy the generated key and paste it in the `SECRET_KEY_BASE`.

          3. Save the changes and restart the application.

        For more information, refer to the [official documentation](https://maybe.co)
  # Title for the application
  title:
    en_us: Maybe Finance
  # Category under which the application falls
  category: BigBearCasaOS
  # Default port mapping for the application
  port_map: "4000"
