This document describes getting a local stack of Ghost + Discourse + DoG setup locally so you can test out and develop the integration.
Note: these instructions assume MacOS or Linux distributions, and are compiled from offical docs of the respective components.
When setting all this up, I found it useful to have everything alongside each other for easy access. For example:
├── working-directory │ ├── ghost │ ├── discourse │ ├── discourse-on-ghost
Step 1. Install Ghost-CLI
npm install ghost-cli@latest -g
Step 2. Install Ghost
ghost directory (diagrammed above), run the install command:
ghost install local
The official Ghost install docs can be found here: https://ghost.org/docs/install/local/
Step 1. Install Docker
Step 2. Install Discourse
Clone Discourse repository to your local device. Perform the following from the
working-directory in the diagram above:
git clone https://github.com/discourse/discourse.git discourse
Step 3. Start container
cd discourse d/boot_dev --init # wait while: # - dependencies are installed, # - the database is migrated, and # - an admin user is created (you'll need to interact with this) # In one terminal: d/rails s # And in a separate terminal d/ember-cli
Then open a browser on http://localhost:4200 and voila!, you should see Discourse.
For more details, see offical docs: https://meta.discourse.org/t/install-discourse-for-development-using-docker/102009
From the root of
Step 1. Install DoG
git clone https://github.com/vikaspotluri123/discourse-on-ghost.git discourse-on-ghost # Install dependencies cd discourse-on-ghost yarn install
Step 2. Set up DoG
.env based on the configuration guide. If this is your first time setting up DoG, I also recommend going through the excellent Integrating Ghost SSO With Discourse Forum on Linux Handbook along with the configuration guide.
- For testing locally, make sure
Step 3: Start DoG
Once your .env file is setup correctly, you can start DoG, from within your
If everything went well, you should see something like:
User ~/Sites/discourse-on-ghost-dev (master)$ yarn dev yarn run v1.22.17 $ node scripts/dev.js Watching for changes... [2023-08-07 19:34:55] INFO Listening on http://127.0.0.1:3286
Step 4: Setup ghost session dev-proxy
The following assumes you are testing the
session mode (rather than
jwt) up for DoG.
Head over to your
current/core/boot.js and insert the following around line 483, immediately after
const rootApp = require('./app')();
const dog = await import("/path-to-working-directory/discourse-on-ghost/dist/targets/dev-proxy.js"); await dog.load("/path-to-working-directory/discourse-on-ghost/dist/", rootApp);
The final hack should look something like this:
// Step 2 - Start server with minimal app in global maintenance mode debug("Begin: load server + minimal app"); const rootApp = require("./app")(); const dog = await import("/path-to-working-directory/discourse-on-ghost/dist/targets/dev-proxy.js"); await dog.load("/path-to-working-directory/discourse-on-ghost/dist/", rootApp);
Save the file and restart Ghost:
If Ghost starts up with out complaining, you can start testing the integration.
- To fully test, DoG, you’ll want to have your local Ghost installation be able to send emails. There are many ways to do this but it’s not the scope of this documentation.
- As you are testing, you can check the DoG terminal (step 3 above) for output.
- If you are testing logging in from Discourse, and the subsequent redirect back to page on Discourse where you logged in from, please see this note on some complexities around redirect urls.