How to Deploy Discourse with Juju
Discourse is an open-source, next-generation discussion platform built for the next decade of the Internet. Juju is a service orchestration management tool developed by Canonical. This guide requires a configured and successfully bootstrapped Juju environment. Please walk through getting started with Juju guide if you are not familiar with the tool yet.
Firstly, you have to fork Discourse and prepare it for deployment with Juju. For this purpose, add
config/redis.yml like shown below.
<%= ENV['RAILS_ENV'] %>:
uri: <%= uri = URI.parse(ENV['REDIS_URL']) %>
host: <%= uri.host %>
port: <%= uri.port %>
password: <%= uri.password %>
cp config/environments/production.rb.sample config/environments/production.rb
Add new files to Git.
git add --force config/environments/production.rb config/redis.yml
Update your repository.
git add .
git commit -m 'prepare to deploy with juju'
git push origin master
Now, Discourse is ready for the deployment with JuJu.
Create Rack charm config using
discourse.yml as shown below.
Important: Discourse requires
SECRET_TOKEN to be defined for sessions storage.
More configuration and deployment options are available on the Rack charm page.
Deploy Discourse with Rack charm.
juju deploy rack --config discourse.yml discourse
Deploy and relate Redis.
juju deploy redis-master
juju add-relation redis-master:redis-master discourse
Deploy and relate PostgreSQL.
juju deploy postgresql
juju add-relation postgresql:db-admin discourse
Generally, you should use the
db relation for PostgreSQL, but Discourse creates the
hstore extension in migrations, that’s why you have to use
Finally, expose Discourse.
juju expose discourse
juju status or
juju debug-log to watch for deployment progress.
When Discourse is deployed, create, migrate, and seed the database.
juju ssh discourse/0 run rake db:create
juju ssh discourse/0 run rake db:migrate
juju ssh discourse/0 run rake db:seed_fu
juju ssh discourse/0 run rake assets:precompile
juju ssh discourse/0 sudo restart rack
Navigate to Discourse and create your account. When you are done, promote your account to admin in the Rails console.
juju ssh discourse/0 run rails c
me = User.find_by_username_or_email('email@example.com')
me.admin = true
Now, you can configure Discourse from the
/admin console. To learn more details about getting started with Discourse, check out this guide.
- Easy Deployment of Rack Applications with Juju
- How to Implement Integration Tests for Juju Charms
- Juju Charms for Cloud Foundry: How to Deploy, Customize, and Upgrade
About the author