This repository contains the pre-deploy configuration for deploying Discourse on Railway using the Bitnami Discourse template.
This setup uses Railway's pre-deploy script feature to automatically:
- Clone the
discourse-oauth2-basicplugin for Clerk SSO integration - Clone a private configuration repository (optional)
- Install additional plugins from a plugins list
- Set up all necessary configuration files
forum/
├── pre-deploy.sh # Main pre-deploy script
├── config/
│ ├── discourse.conf # Discourse configuration template
│ ├── site_settings.yml # Site settings template
│ └── plugins.txt # List of additional plugins
└── README.md # This file
- Go to Railway Dashboard
- Click "New Project" → "Deploy from Template"
- Search for "Discourse" and select the Bitnami Discourse template
- Railway will create the necessary services (Discourse, Sidekiq, PostgreSQL, Redis)
In your Railway project settings:
- Go to the Discourse service
- Navigate to Settings → Deploy
- In the Pre-Deploy Command field, enter:
curl -sSL https://raw.githubusercontent.com/YOUR_USERNAME/bequant/main/forum/pre-deploy.sh | bashReplace YOUR_USERNAME with your actual GitHub username.
Add these environment variables to your Discourse service:
# Basic Configuration
DISCOURSE_HOSTNAME=forum.bequant.dev
DISCOURSE_DEVELOPER_EMAILS=[email protected],[email protected]
# Database (Railway will auto-generate these)
DATABASE_HOST=${DATABASE_HOST}
DATABASE_NAME=${DATABASE_NAME}
DATABASE_USERNAME=${DATABASE_USERNAME}
DATABASE_PASSWORD=${DATABASE_PASSWORD}
# Redis (Railway will auto-generate these)
REDIS_HOST=${REDIS_HOST}
REDIS_PORT=${REDIS_PORT}
REDIS_PASSWORD=${REDIS_PASSWORD}
# SMTP Configuration (Gmail)
DISCOURSE_SMTP_USER_NAME=[email protected]
DISCOURSE_SMTP_PASSWORD=your-app-password
# Clerk OAuth2 Configuration
CLERK_OAUTH2_CLIENT_ID=your-clerk-oauth-client-id
CLERK_OAUTH2_CLIENT_SECRET=your-clerk-oauth-client-secret# Private Config Repository (if using)
CONFIG_REPO_URL=[email protected]:your-username/your-private-config-repo.git
GITHUB_DEPLOY_KEY=-----BEGIN OPENSSH PRIVATE KEY-----\n...\n-----END OPENSSH PRIVATE KEY-----For the Sidekiq service, add the same environment variables but reference the Discourse service:
# Inherit all variables from Discourse service
DISCOURSE_HOSTNAME=${{Discourse.DISCOURSE_HOSTNAME}}
DISCOURSE_DEVELOPER_EMAILS=${{Discourse.DISCOURSE_DEVELOPER_EMAILS}}
DATABASE_HOST=${{Discourse.DATABASE_HOST}}
DATABASE_NAME=${{Discourse.DATABASE_NAME}}
DATABASE_USERNAME=${{Discourse.DATABASE_USERNAME}}
DATABASE_PASSWORD=${{Discourse.DATABASE_PASSWORD}}
REDIS_HOST=${{Discourse.REDIS_HOST}}
REDIS_PORT=${{Discourse.REDIS_PORT}}
REDIS_PASSWORD=${{Discourse.REDIS_PASSWORD}}
DISCOURSE_SMTP_USER_NAME=${{Discourse.DISCOURSE_SMTP_USER_NAME}}
DISCOURSE_SMTP_PASSWORD=${{Discourse.DISCOURSE_SMTP_PASSWORD}}
CLERK_OAUTH2_CLIENT_ID=${{Discourse.CLERK_OAUTH2_CLIENT_ID}}
CLERK_OAUTH2_CLIENT_SECRET=${{Discourse.CLERK_OAUTH2_CLIENT_SECRET}}Also set the same pre-deploy command for Sidekiq.
If you want to use a private repository for configuration:
- Create a private GitHub repository with this structure:
your-private-config-repo/
├── discourse.conf
├── site_settings.yml
└── plugins.txt
- Generate a GitHub deploy key:
ssh-keygen -t rsa -b 4096 -C "[email protected]" -f ~/.ssh/railway_deploy_key- Add the public key to your private repository's deploy keys
- Add the private key content to Railway as
GITHUB_DEPLOY_KEY - Set
CONFIG_REPO_URLto your private repository's SSH URL
- Environment Check: Verifies it's running in Bitnami Discourse
- Directory Setup: Creates necessary plugin and config directories
- OAuth2 Plugin: Clones the
discourse-oauth2-basicplugin - SSH Setup: Configures GitHub deploy key if provided
- Config Repository: Clones and processes private config repo if specified
- Plugin Installation: Installs additional plugins from
plugins.txt - Permissions: Sets correct file ownership for Bitnami user
- Check Railway logs for the exact error
- Verify the script URL is accessible
- Ensure all required environment variables are set
- Verify
CLERK_OAUTH2_CLIENT_IDandCLERK_OAUTH2_CLIENT_SECRETare set - Check that Clerk OAuth2 application is configured correctly
- Review Discourse admin logs for OAuth2 errors
- Check that
discourse.confandsite_settings.ymlare in the correct format - Verify environment variable interpolation is working
- Restart the Discourse service after configuration changes
Edit config/plugins.txt and add GitHub repository URLs, one per line.
Update config/discourse.conf and config/site_settings.yml as needed. The files use environment variable interpolation with ${VARIABLE_NAME} syntax.
Modify pre-deploy.sh to add custom setup steps like:
- Installing system packages
- Setting up SSL certificates
- Configuring custom themes
- Running database migrations
To update the configuration:
- Modify the files in this repository
- Push changes to GitHub
- Redeploy the Railway service (the pre-deploy script will pull the latest version)
For issues with this setup:
- Check Railway deployment logs
- Verify all environment variables are set correctly
- Test the pre-deploy script locally if possible
- Review Discourse documentation for configuration options