I've noticed in the Dockerfile contains this stanza:
CMD node app --setup && npm start which seems to me like it would run setup by default no matter what. Is that the expected behavior? It seems to me that Docker users would want to create a container that could be restarted any time without requiring any other interaction other than
docker start <container>.
Quick explanation (prolly more behind it, very very tired right now though so I can't really remember):
By default the Docker image requires all environment variables to be specified because having to deal with data that isn't in the image itself can be a pain, so this keeps the image stateless.
node app --setup is always run before starting the image because any files this creates is deterministically based on the data passed to the
-e arguments, so it can just be thrown away and you don't need to deal with moving it around between different machines in HA scenarios.
You could also address all this by simply putting the environment variables in the Dockerfile when building it, but you can't really use the public Docker Hub for this as it'd post your DB info - and also the session secret, which you should specify if loadbalancing across multiple containers.
I've tried adding connect-redis to the package.json file, but this seems to have no effect.
Is there a way around this?
npm install runs when you build the image (thus version-locking all dependencies without something like
npm shrinkwrap), anything you do afterwards just behaves normally - i.e. adding things to the package.json using a text editor (or sed, etc. you get the idea) doesn't automagically install them.
Would pre-configuring NodeBB before building the docker container be a better and is this even an option?
It's definitely possible! You could base your image on our image and specify all the configuration stuffs using
ENV, use a
RUN directive to run
node app --setup at build-time and optionally add a
CMD directive that's just
npm start. (the
CMD is the default command ran if you start the container without supplying any, also your CMD would override ours )
Good luck, hope this helps a bit and sorry if you knew more than I cautiously assumed you might when writing this post - well, at least that'd make it also useful to any stray Googlers out there looking for help...