-
Notifications
You must be signed in to change notification settings - Fork 3
Deploying Roots CMS to a server
Here's one way of deploying roots-cms and a roots project to a server in order to allow content management. We'll be using pm2 to manage our node server and deploy for deployment.
I recommend an Ubuntu server from Digital Ocean.
Here are good instructions on how to install node on a Ubuntu server.
pm2 will manage our node server processes. Install with npm install pm2@latest -g
, more documentation can be found in the repo readme.
Clone down the repo and run make install
.
Roots-CMS has an example deploy.conf.example
file inside of the repo.
cp deploy.conf.example deploy.conf
- Update
deploy.conf
with the correct config values foruser
,host
,repo
,path
, andref
deploy production setup
- Deploy will SSH to your server and build all necessary directories at the path you specify.
Add a cms.json
file to the root of your roots project with the following config and update with your values. None of the keys are required, a more detailed guide to configuring your roots project to work with roots-cms will be coming soon:
{
"content_dir": "",
"basic_auth": {
"username": "user",
"password": "password"
},
"templates": {
"content_edit": "assets/cms/templates/_content_show.jade"
},
"css": "assets/css/_blogging.styl",
"aws": {
"key": "XXXXXXXXXXXXXXXXXX",
"secret": "XXXXXXXXXXXXXXXXXXX",
"bucket": "bucket-name"
}
"uploader": "fs",
"img_upload_dir": "uploads"
}
In the cms.json
example above, the uploader
key specifies how you want to upload images. Use "fs"
to upload images directly into your roots project on the server (Note, there are no security precautions taken with this feature, use at your own risk, getting this to be production ready is on the roadmap). You can also use s3
to upload images to an Amazon S3 bucket (requires aws
to be defined).
img_upload_dir
will specify a directory inside either assets/img
or on the S3 bucket (depending on the uploader) where uploaded images should be stored.
I like to put it in /var/www
as well, but you can choose another location if you want: cd /var/www && git clone <git_url>
Roots-CMS needs to know where your roots project is. For now we'll store this config information in a shared file, we'll link it to the current release in the next step.
cd /var/www/roots-cms/shared/
touch config.json
- Edit the file to contain the following:
{
"project_dir": "/var/www/<your-roots-project>"
}
We'll need a post deploy script to manage linking the shared config file into the current release directory, to load any new npm dependencies, as well as to restart the node server. This can easily be done with deploy.
Open up your deploy.conf
and add this last line to the file:
post-deploy sh ../shared/post_deploy.sh
On the server add post_deploy.sh
into /var/www/roots-cms/shared/
Here's my post-deploy.sh
file, feel free to edit for your needs. Mine runs npm install
, symlinks the config file into the current relase, and restarts the node server via pm2.
(cd ../current/; npm install)
rm ../current/config.json
ln -s ../shared/config.json ../current/config.json
pm2 kill
nohup pm2 start ../current/app.coffee >/dev/null 2>&1 </dev/null
echo "Daemon started"
Note that there's no robust authentication system in roots-cms right now outside of HTTP basic auth, please do your due diligence if you need a secure system.