# Configuration for nocodb setup

# Name of the big-bear-nocodb application
name: big-bear-nocodb
# Service definitions for the big-bear-nocodb application
services:
  # Service name: big-bear-nocodb
  # This section configures the NocoDB application itself
  big-bear-nocodb:
    image: nocodb/nocodb:0.301.5 # Specifies the Docker image to use for NocoDB
    container_name: big-bear-nocodb # Sets a custom name for the container
    restart: unless-stopped # Container restart policy to ensure availability
    environment: # Environment variables for configuring NocoDB
      - DATABASE_URL=postgres://nocodb:nocodb@big-bear-nocodb-db:5432/nocodb # Connection string for the PostgreSQL database
      - NC_AUTH_JWT_SECRET=899499fc-36a0-4131-b077-7bb9f051ac9b # JWT secret for authentication
      - NC_REDIS_URL=redis://default:casaos@big-bear-nocodb-redis:6379 # Connection string for Redis
    ports:
      - "8080:8080" # Maps port 8080 from the container to the host
    volumes:
      - /DATA/AppData/$AppID/data:/usr/src/app/data # Maps persistent data storage for NocoDB
    networks:
      - big-bear-nocodb-network # Connects to the custom network
    x-casaos:
      envs:
        - container: DATABASE_URL
          description:
            en_us: 'Container Variable: DATABASE_URL'
        - container: NC_AUTH_JWT_SECRET
          description:
            en_us: 'Container Variable: NC_AUTH_JWT_SECRET'
        - container: NC_REDIS_URL
          description:
            en_us: 'Container Variable: NC_REDIS_URL'
      volumes:
        - container: /usr/src/app/data
          description:
            en_us: 'Container Path: /usr/src/app/data'
      ports:
        - container: "8080"
          description:
            en_us: 'Container Port: 8080'
  # Database service configuration
  big-bear-nocodb-db:
    container_name: big-bear-nocodb-db
    image: postgres:13 # Specifies the PostgreSQL Docker image to use
    restart: always # Ensures the database container is always running
    environment: # Database credentials and configurations
      POSTGRES_DB: nocodb # Database name
      POSTGRES_USER: nocodb # Database user
      POSTGRES_PASSWORD: nocodb # Database password
    volumes:
      - /DATA/AppData/$AppID/pgdata:/var/lib/postgresql/data # Persistent storage for the database
    networks:
      - big-bear-nocodb-network # Connects to the custom 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'
  # Redis service configuration
  big-bear-nocodb-redis:
    image: redis:8.2.2-alpine@sha256:1c78f5e7512cc8b22b0edc95c20e7abd9e1fd832e5dfd5c3c6b59ce82fb238d0 # Specifies the Redis Docker image to use
    container_name: big-bear-nocodb-redis
    restart: unless-stopped # Ensures Redis container is available unless manually stopped
    command: ["redis-server", "--requirepass", "casaos"] # Starts Redis with a password
    volumes:
      - /DATA/AppData/$AppID/redis:/data # Persistent storage for Redis data
    healthcheck:
      test: ["CMD", "redis-cli", "ping"] # Health check command for Redis
      interval: 1s # Interval between health checks
      timeout: 3s # Timeout for each health check
      retries: 30 # Number of retries before considering the service unhealthy
    networks:
      - big-bear-nocodb-network # Connects to the custom network
    x-casaos:
      volumes:
        - container: /data
          description:
            en_us: 'Container Path: /data'
# Network configuration
networks:
  big-bear-nocodb-network:
    driver: bridge # Uses a bridge network for inter-container communication
x-casaos:
  # Supported CPU architectures for this application
  architectures:
    - amd64
    - arm64
  # Main service for this application
  main: big-bear-nocodb
  # Detailed description for the application
  description:
    en_us: NocoDB allows building no-code database solutions with ease of spreadsheets. Bring your own database or choose ours! Millions of rows? Not a problem. Your Data. Your rules. You are in control.
  # Brief tagline for the application
  tagline:
    en_us: "\U0001F525 \U0001F525 \U0001F525 Open Source Airtable Alternative"
  # Developer's information
  developer: nocodb
  # Author of this particular configuration
  author: BigBearTechWorld
  # Icon URL for the application
  icon: https://cdn.jsdelivr.net/gh/selfhst/icons/png/nocodb.png
  # Thumbnail image for the application (if any)
  thumbnail: https://user-images.githubusercontent.com/86527202/277104231-e2fad786-f211-4dcb-9bd3-aaece83a6783.gif
  # Title for the application
  title:
    en_us: NocoDB
  # Category under which the application falls
  category: BigBearCasaOS
  # Default port mapping for the application
  port_map: "8080"
