Set up NodeBB via environment variables
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
urlis defined, NodeBB will default to
- All database defaults are assumed, only the actual
databasevalue is required (
- If no admin username is specified,
- 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
setupargument. 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
- If no
@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
@Nicolas I think you can copy your
default.jsonfile into the directory after
git cloneing as
config.json, and it will use those settings.
Nope, you still need go through Wizard, but it will be a bit faster
@Nicolas If everything is the same, you shouldn't even have to run
./nodebb setup, you should be able to just start it.
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.
@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
Moritz Friedrich last edited by
@Nicolas You could just
npm install? That's what I did while development multiple times,
cp ~/config.json ./,
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:
- Install dependencies
- Clone the repository
npm install --production
- Start the web install (via
A cloud hosting provider can automate all four steps, so nobody has to mess with a shell again
Moritz Friedrich last edited by
A cloud hosting provider
read: The NodeBB Saas platform
Xiph last edited by
@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
npm start) with the env variables
silentboth set to
false, NodeBB still starts both daemonized and silent.
falsedoes not equal
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.
Maybe you should add that to the docs was really hared for me to find out it was possible and it is really interesting if setting it up with docker-compose. You guys might just add it to the docker read me page. https://hub.docker.com/r/nodebb/docker/
Hi @axel12 -- add what to the readme?
@julian A docker-compose.yml file example for Docker. Basically how to setup NodeBB-Docker.