Set up NodeBB via environment variables

  • Admin

    For v0.7.0, NodeBB now accepts configuration via environment variables. Thanks to @ahwayakchih for his work that prompted this change 🙂

    Since v0.6.0, We've also significantly relaxed the amount of data you need to set up NodeBB, with sensible defaults assumed if not provided:

    • If no url is defined, NodeBB will default to http://localhost:4567
    • All database defaults are assumed, only the actual database value is required (redis or mongo)
    • If no admin username is specified, admin is used
    • If no admin password is specified, a password is automatically generated (NodeBB will tell you the password at the end)
    • User creation doesn't require an email, so admin creation during installation won't require one either.

    Prior to this change, automated setup was achieved via passing an escaped JSON string in the setup argument. I personally found this cumbersome and hard to work with, so it will be deprecated prior to v1.0.0 (this is open to discussion).


    # Minimum setup options
    $ database=redis node app --setup`
    # Setup NodeBB on Redis database 4
    $ database=redis redis__database=4 node app --setup`
    # MongoDB setup with username and password
    $ database=mongo mongo__username=foobar mongo__password=mypassword node app --setup
    # Admin user defined
    $ database=redis admin__password=foobar node app --setup

  • Plugin & Theme Dev

    @julian Is it for developers or users?

    If for developers, It would be more helpful to have predefined configuration file, for fast and easy setup. I have found myself in situation when from time to time I should reinstall NodeBB from the scratch (rm -rf NodeBB, git clone, npm install, ./nodebb setup, ./nodebb dev)

    So it would be great to have configuration file with answers for setup wizard, seems it should look like:

    ./nodebb setup /usr/local/some/path/config.default.json

  • Global Moderator

    @Nicolas I think you can copy your default.json file into the directory after git cloneing as config.json, and it will use those settings.

  • Plugin & Theme Dev

    Nope, you still need go through Wizard, but it will be a bit faster 😉

  • Global Moderator

    @Nicolas If everything is the same, you shouldn't even have to run ./nodebb setup, you should be able to just start it.

  • Plugin & Theme Dev

    Still no 😉 because you will not have necessary node packages - for example mongo_db 😉
    Also from scratch, there is probability that you don't have populated database, as a result you need dummy data from setup script - like categories, admin user, etc.

  • Global Moderator

    @Nicolas Seems like we need a better CLI. Maybe a Node-based one possibly called NBBVM?

    adds to long list of plugins/utilities to build

  • @Nicolas You could just npm install? That's what I did while development multiple times, git clone, cp ~/config.json ./, npm install.

  • Admin

    Thanks for the comments guys 🙂

    The automated setup via environment variables is to aid with setup on cloud services and our SaaS platform. The interactive prompt will still continue to be in use, but we're looking to change the default installation steps to utilise the web installation interface Andrew has implemented.

    From there, we can reduce the steps to:

    1. Install dependencies
    2. Clone the repository
    3. npm install --production
    4. Start the web install (via npm start possibly)

    A cloud hosting provider can automate all four steps, so nobody has to mess with a shell again 🙂

  • @julian said:

    A cloud hosting provider

    read: The NodeBB Saas platform 😜

  • Admin

    😉 maybe?

  • @julian Objection! When setting settings through env variables, they are always strings. Currently NodeBB doesn't seem to take this into account. i.e. running ./nodebb start (or npm start) with the env variables daemon and silent both set to false, NodeBB still starts both daemonized and silent.
    (false does not equal "false" 😛 )

    Also, slightly unrelated, but when doing the setup thingy with a redis password provided, i.e. like

     $ database=redis redis__password=CorrectHorseBatteryStaple node app --setup`

    the password provided is used during the install but not actually saved to config.json.

  • Admin


| |