Deploy GrowthBook
Feature flags and A/B testing, pinned 5.2.1, MongoDB and uploads on volumes
MongoDB
Just deployed
/data/db
GrowthBook
Just deployed
/usr/local/src/app/packages/back-end/uploads
Deploy and Host GrowthBook on Railway
GrowthBook is an open-source platform for feature flags, A/B testing and product analytics. You roll out features gradually, run experiments, and analyse the results with its statistics engine against your own data warehouse or event data. SDKs exist for JavaScript, React, Python, Go, PHP, Ruby, Java, mobile and more.
About Hosting GrowthBook
This template deploys GrowthBook 5.2.1 from the official image, pinned by version and digest, plus MongoDB 7.0 for its data. Both keep their state on Railway volumes: MongoDB at /data/db and uploaded images at the GrowthBook uploads folder. GrowthBook normally needs two public addresses, one for the web app and one for the API, and its login cookies break when they are on two *.up.railway.app domains. Here a small proxy serves both on one domain, with the API under /backend, so nothing has to be pasted after deploy. Secrets are generated at deploy, and a health check at /healthz waits for both parts.
Common Use Cases
- Turn features on and off, or roll them out to a percentage of users, without redeploying your app
- Run A/B tests and multi-armed bandits, and analyse them with Bayesian or frequentist statistics
- Keep feature flag and experiment data on your own infrastructure instead of a SaaS
Dependencies for GrowthBook Hosting
- MongoDB 7.0 (included, with a volume)
- A Railway volume for uploaded images (included)
Deployment Dependencies
- GrowthBook self-hosting docs: https://docs.growthbook.io/self-host
- Environment variables: https://docs.growthbook.io/self-host/env
- Release notes: https://github.com/growthbook/growthbook/releases/tag/v5.2.1
- Template source: https://github.com/aalfath/growthbook-railway-template
Implementation Details
After deploy: open the public URL and register straight away. The first account becomes the admin, and there is no default login. In your SDKs, use https://YOUR-DOMAIN/backend as the API host; GrowthBook's SDK setup pages show it for you.
Variables: none to fill in. JWT_SECRET, ENCRYPTION_KEY and the MongoDB password are generated, and APP_ORIGIN comes from the Railway domain. If you add a custom domain, set APP_ORIGIN to it. Never change ENCRYPTION_KEY once you have added a data source.
Optional features: add them as variables on the GrowthBook service. Email for invites and password resets uses EMAIL_ENABLED=true, EMAIL_HOST, EMAIL_PORT, EMAIL_HOST_USER, EMAIL_HOST_PASSWORD and EMAIL_FROM. DISABLE_TELEMETRY=true turns off usage telemetry. AI features take OPENAI_API_KEY or ANTHROPIC_API_KEY.
Updates: the GrowthBook service builds from the template's GitHub repo. When we bump the pinned version, Railway shows you an update notice, and the repo's CHANGELOG.md lists what changed. GrowthBook migrates its data itself on start. Upstream recommends about 2 GB of RAM.
Why Deploy GrowthBook on Railway?
Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.
By deploying GrowthBook on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.
Template Content
MongoDB
mongo:7.0.48GrowthBook
aalfath/growthbook-railway-template
