I did a quick test to verify that nodebb setup will attempt to verify mongo access even if it has been provided - which I expected, but... and it does.

So it seems that the best practice here would be to pass the values in as part of the build with the assumption that the Redis or mongo instance already exists.