# yaml-language-server: $schema=https://schema.zeabur.app/template.json
apiVersion: zeabur.com/v1
kind: Template
metadata:
    name: NodeBB
spec:
    description: A next-generation forum software that's free and easy to use.
    coverImage: https://github.com/NodeBB/NodeBB/raw/master/public/images/sm-card.png
    icon: https://avatars.githubusercontent.com/u/4449608?s=200&v=4
    tags:
        - Forum
        - CMS
        - Community
    readme: |-
        NodeBB is a next-generation discussion platform that utilizes web sockets for instant interactions and real-time notifications. NodeBB forums have many modern features out of the box such as social network integration and streaming discussions.

        This template includes:
        - NodeBB forum software
        - MongoDB database for data storage
        - Redis for session storage and caching

        ## Environment Variables

        After deployment, you can access the following environment variables in your NodeBB service:

        - `MONGO_CONNECTION_STRING`: The connection string to connect to your MongoDB database.
        - `MONGO_HOST`: The hostname of your MongoDB database.
        - `MONGO_PORT`: The port of your MongoDB database.
        - `MONGO_USERNAME`: The username for your MongoDB database.
        - `MONGO_PASSWORD`: The password for your MongoDB database.
        - `REDIS_CONNECTION_STRING`: The connection string to connect to your Redis cache.
        - `REDIS_HOST`: The hostname of your Redis cache.
        - `REDIS_PORT`: The port of your Redis cache.

        ## Getting Started

        1. After deployment, NodeBB will be available on port 4567
        2. Visit your NodeBB instance to complete the initial setup
        3. Configure your forum settings through the admin panel
        4. Customize themes, plugins, and other settings as needed

        ## Features

        - Real-time notifications and messaging
        - Social network integration
        - Mobile-responsive design
        - Plugin architecture for extensibility
        - Multi-language support
        - SEO-friendly URLs
        - Advanced user management and permissions

        ## Documentation

        For more information about NodeBB, visit the [official documentation](https://docs.nodebb.org/).
    services:
        - name: nodebb
          icon: https://avatars.githubusercontent.com/u/4449608?s=200&v=4
          template: PREBUILT
          spec:
            source:
                image: ghcr.io/nodebb/nodebb:latest
            ports:
                - id: web
                  port: 4567
                  type: HTTP
            volumes:
                - id: build
                  dir: /usr/src/app/build
                - id: uploads
                  dir: /usr/src/app/public/uploads
                - id: config
                  dir: /opt/config
            instructions:
                - title: NodeBB Admin URL
                  content: https://${ZEABUR_WEB_DOMAIN}
                - title: NodeBB Database Connection
                  content: mongodb://${MONGO_USERNAME}:${MONGO_PASSWORD}@${MONGO_HOST}:${MONGO_PORT}/nodebb
            env:
                MONGO_CONNECTION_STRING:
                    default: mongodb://${MONGO_USERNAME}:${MONGO_PASSWORD}@${MONGO_HOST}:${MONGO_PORT}/nodebb
                NODE_ENV:
                    default: production
                PORT:
                    default: "4567"
                REDIS_CONNECTION_STRING:
                    default: redis://:${REDIS_PASSWORD}@${REDIS_HOST}:${REDIS_PORT}
        - name: mongodb
          icon: https://cdn.zeabur.com/marketplace/mongodb.svg
          template: PREBUILT
          spec:
            source:
                image: mongo:7.0
                command:
                    - sh
                args:
                    - -c
                    - sed -i '10,23d' /usr/local/bin/docker-entrypoint.sh && exec docker-entrypoint.sh mongod
            ports:
                - id: database
                  port: 27017
                  type: TCP
            volumes:
                - id: data
                  dir: /data/db
            instructions:
                - title: Command to connect to your MongoDB
                  content: mongosh "mongodb://${MONGO_USERNAME}:${MONGO_PASSWORD}@${PORT_FORWARDED_HOSTNAME}:${DATABASE_PORT_FORWARDED_PORT}"
                - title: MongoDB connection string
                  content: mongodb://${MONGO_USERNAME}:${MONGO_PASSWORD}@${PORT_FORWARDED_HOSTNAME}:${DATABASE_PORT_FORWARDED_PORT}
                - title: MongoDB username
                  content: ${MONGO_USERNAME}
                - title: MongoDB password
                  content: ${MONGO_PASSWORD}
                - title: MongoDB host
                  content: ${PORT_FORWARDED_HOSTNAME}
                - title: MongoDB port
                  content: ${DATABASE_PORT_FORWARDED_PORT}
            env:
                MONGO_CONNECTION_STRING:
                    default: mongodb://${MONGO_USERNAME}:${MONGO_PASSWORD}@${MONGO_HOST}:${MONGO_PORT}
                    expose: true
                MONGO_HOST:
                    default: ${CONTAINER_HOSTNAME}
                    expose: true
                MONGO_INITDB_ROOT_PASSWORD:
                    default: ${PASSWORD}
                MONGO_INITDB_ROOT_USERNAME:
                    default: mongo
                MONGO_PASSWORD:
                    default: ${MONGO_INITDB_ROOT_PASSWORD}
                    expose: true
                MONGO_PORT:
                    default: ${DATABASE_PORT}
                    expose: true
                MONGO_URI:
                    default: ${MONGO_CONNECTION_STRING}
                    expose: true
                MONGO_USERNAME:
                    default: ${MONGO_INITDB_ROOT_USERNAME}
                    expose: true
        - name: redis
          icon: https://raw.githubusercontent.com/zeabur/service-icons/main/marketplace/redis.svg
          template: PREBUILT
          spec:
            source:
                image: redis/redis-stack-server:latest
            ports:
                - id: database
                  port: 6379
                  type: TCP
            volumes:
                - id: data
                  dir: /data
            instructions:
                - title: Command to connect to your Redis
                  content: redis-cli -h ${PORT_FORWARDED_HOSTNAME} -p ${DATABASE_PORT_FORWARDED_PORT} -a ${REDIS_PASSWORD}
                - title: Redis Connection String
                  content: redis://:${REDIS_PASSWORD}@${PORT_FORWARDED_HOSTNAME}:${DATABASE_PORT_FORWARDED_PORT}
                - title: Redis password
                  content: ${REDIS_PASSWORD}
                - title: Redis host
                  content: ${PORT_FORWARDED_HOSTNAME}
                - title: Redis port
                  content: ${DATABASE_PORT_FORWARDED_PORT}
            env:
                CONFFILE:
                    default: /etc/redis-stack.conf
                REDIS_ARGS:
                    default: --requirepass ${REDIS_PASSWORD}
                REDIS_CONNECTION_STRING:
                    default: redis://:${REDIS_PASSWORD}@${REDIS_HOST}:${REDIS_PORT}
                    expose: true
                REDIS_HOST:
                    default: ${CONTAINER_HOSTNAME}
                    expose: true
                REDIS_PASSWORD:
                    default: ${PASSWORD}
                    expose: true
                REDIS_PORT:
                    default: ${DATABASE_PORT}
                    expose: true
                REDIS_URI:
                    default: ${REDIS_CONNECTION_STRING}
                    expose: true
            configs:
                - path: /etc/redis-stack.conf
                  template: |
                    port 6379
                    daemonize no
                  permission: null
                  envsubst: null
