There are several tricks that can help when you are setting up a staging server.
A staging server is essentially a clone of a production site. It also resides on a server, and functions identically. It runs inside a Docker container, just as a normal Discourse site does.
It exists to give you a place to try risky things out, or to trial things that you cannot easily hide from your users. It is very useful for trialling adverts using the Official Advertising / Ad Plugin for Discourse, or if you want to do something funky like a forum import or merge.
This is in contrast to a development server, which typically runs in an easily accessible (and sandboxed) place so that a developer can tinker with the code safely.
Everything that you need for a standard self-hosted install
If you have S3 backups setup, your life will be a whole lot easier
- otherwise you’ll need a way to move large files into and out of a server via SSH
Set up your server as you wish
Install Discourse as per discourse/INSTALL-cloud.md at main · discourse/discourse · GitHub You can use junk mail credentials.
- confirm that your install is working:
- Set yourself up an admin account from the command line if needed to skip any authentication needs.
./launcher enter app rake admin:create
Edit app.yml and make these tweaks:
first you might like to make a copy of the original app.yml (I call mine
app.vanilla.yml) which you can revert to if you stuff things up
at the bottom of the
envsection add these lines:
## Staging server specific settings DISCOURSE_AUTOMATIC_BACKUPS_ENABLED: false DISCOURSE_LOGIN_REQUIRED: true DISCOURSE_DISABLE_EMAILS: 'yes' DISCOURSE_S3_DISABLE_CLEANUP: true DISCOURSE_ALLOW_RESTORE: true
- if you have S3 (or similar) backups configured then add these too (with your settings from the main site)
## S3 Configuration DISCOURSE_S3_ACCESS_KEY_ID: 'your_key' DISCOURSE_S3_SECRET_ACCESS_KEY: 'your_secret' DISCOURSE_BACKUP_LOCATION: 's3' DISCOURSE_S3_BACKUP_BUCKET: 'your_backups_location' DISCOURSE_S3_REGION: 'your_s3_region' DISCOURSE_S3_DISABLE_CLEANUP: true
and if you also are doing S3 uploads:
DISCOURSE_ENABLE_S3_UPLOADS: true DISCOURSE_S3_UPLOAD_BUCKET: 'your_uploads_location'
You might like to add the same plugins that you have on your production site while you are there.
Do a rebuild
./launcher rebuild app
You’ve now got a staging server that is connected to your S3 backups (but won’t overwrite them), is easy to restore to, and that is unable to email anyone under any circumstances. Perfect!
You can restore a fresh backup to the staging server and go to town. If you don’t like what you have, you simply restore it again.
If you leave your staging server ‘on’ for prolonged periods, you do risk it being indexed by Google, and having your users accidentally login to it instead. As their credentials are a clone of your production site, this is very possible.
A simple way to mitigate these two things is to simply turn Discourse off:
./launcher stop app
And to turn it back on so you can use it:
./launcher restart app
You’ll have to make sure that you update/rebuild both it and your production site at the same time if you want to ensure that things remain aligned from the plugin and code point of view. Same goes for app.yml changes.
If you don’t use S3, you’ll have to manually move backups between servers. And they are big!
If you want a staging server, then you should populate it with your actual data from your actual forum. Somtimes it is your particular data that is causing the issue, and testing your forum with some other set of data can give you a sense of false hope.
If what you want is a test server to see what Discourse is like, though, you might want to check things out with some fake data, and if you do, you can do this:
cd /var/discourse ./launcher enter app cd /var/www/discourse ALLOW_DEV_POPULATE=1 bundle install ALLOW_DEV_POPULATE=1 rake dev:populate exit exit
This will seed your forum with some fake data so that you can see what things look like with whatever themes and plugins you want. If you haven’t started your forum yet, this will give you some idea what things are lkely to look like.