This guide will show you how to deploy GrowthBook with Northflank. GrowthBook’s public docker image growthbook/growthbook:latest
will be used for the deployment. You have the option to deploy to Northflank Cloud and your own cloud (BYOC).
GrowthBook is the most popular open-source platform for feature flagging and A/B testing experimentation. Think of it as a way to de-risk new feature rollouts by limiting exposure of new features to a subset of real users. GrowthBook includes a visual editor for your pages, auto-generates SQL queries for analyzing data, and stores your data in whatever data storage you prefer.
Since GrowthBook controls the essential functionality of your website, it’s also an ideal app to deploy on your own cloud. Read more about why you might want to do that in the BYOC section.
GrowthBook gives non-coding roles the power to make site changes themselves. It includes a visual editor for your existing web pages. When it is time to analyse the impact of a feature, it also provides a flexible report-building solution.
The other main benefit of GrowthBook is it keeps you in control of your data. All reports are exportable as Jupyter notebooks, and any report’s SQL query can be modified or copied. You choose where you store your data. This means you can use Snowflake or nearly any other data warehouse solution as your source of truth.
Northflank simplifies the deployment of GrowthBook. Many of the values of the deployment will automatically fill in from the Dockerfile. Installing a database as an addon is also easy to do in a few clicks.
This guide will show you how to deploy GrowthBook on Northflank with a MongoDB database addon, a deployment service for the GrowthBook docker image, and a secret group for securely managing connection details.
To start, you need to sign up or sign in to your Northflank account.
A project is a namespace for resources. It allows your resources to communicate securely with each other. You can deploy to different regions, to Northflank's managed cloud, or bring your own cloud provider (BYOC).
Click the
create new
button at the top of the page, and click to create a newproject
Fill in a name and region, and then submit
Next, you need to create a MongoDB addon. Think of addons as a managed database service on Northflank. Tasks like upgrades, backups, and disaster recovery are configurable in just a few clicks.
- On the top navigation click the
addons
option and on the next page click thecreate new addon
button. Select MongoDB and choose a name and version for the database.
Click the
create addon
button at the bottom of the pageOn the left hand navigation click
connection details
. On the upper right of the page clicklink to secret groups
and follow the prompt.Choose a name, and then scroll down to the section named
linked addons
. Clickshow addons
and choose theconfigure
button next to your MongoDB instanceFrom the list of environment variables click on
MONGO_SRV
. On the row below it click theadd
button next toaliases
. Name the aliasMONGODB_URI
.Click
create secret group
Next, you need to deploy the GrowthBook container as a service. In Northflank, a service is just a shorthand for similar phrases like microservice, deployment, or workload. Deployment services can deploy an image built on Northflank or from an external container registry like in this example. If you want to build from your own Git repository, click here to see those docs.
At the top of the page click the
create new
button and chooseservice
From the top row of three options, click
deploy a docker Image
. Give your service a name and in thedeployment
section clickexternal image
. Since GrowthBook is hosted publicly on DockerHub you can make the image pathgrowthbook/growthbook:latest
.To improve maintainability you should rename the ports. Scroll down to the
Networking
section and rename port 3000 toapp
. If port 3100 is set as TCP, change it to HTTP. Click the boxPublicly expose this port to the internet
and rename it toapi
.At the bottom of the page click the
Create service
button
You’re on the final steps! Next, you need to set a few environment variables. This is often where programs store configuration values or secrets such as API keys. Secret groups on Northflank can also automatically link to your addon's connection details to your application. Since these values often contain sensitive information, Northflank securely encrypts and injects these at runtime in order to improve security.
The values are taken from GrowthBook’s Git repo and their docs. This guide includes everything you need to get up and running, but you have these links in case you want to look more closely at the values.
Set environment variables by going to
secrets
and select your secret group. In the upper right of the table of values, click theenv
option.Copy and paste the following values into the free text field that appears.
``` APP_ORIGIN="https://ReplaceThisWithTheAppURL:443" API_HOST="https://ReplaceThisWithTheApiURL:443" NODE_ENV="production" JWT_SECRET="ReplaceThisWithaSecureGeneratedKey" ENCRYPTION_KEY="ReplaceThisWithaSecureGeneratedKey" CORS_ORIGIN_REGEX=".*" ```
You’ll notice in this script that a few of these values need to be added by you. Thankfully, everything you need to do that should be on your current project.In the upper right of the table, you should see a button with a key icon that says
Generate secret values
. Use this to create values forJWT_SECRET
andENCRYPTION_KEY
. A length of 256 or more is recommended.Similarly, on the top navigation bar locate the
Services
link and open it in a new tab. Select your service. In the upper right of the page you should find URLs that look likeapi-projectname-r4ss2gd9bzvt.code.run
. Copy the URL beginning with app forAPP_ORIGIN
and the api URL forAPI_HOST
.For both URLs, prepend
https://
at the beginning. Append:443
at the end. This ensures GrowthBook runs with TLS enabled.Click
Update Configuration
to save your changes to the secret group.
You should restart your service to pick up the secrets changes and then you can view your new GrowthBook app. Northflank's dashboard for your service gives you access to your application at the code.run domain provided by Northflank, which is displayed prominently in the header.
From here you can monitor the progress of builds, check the status of deployed containers, and scale, pause and restart your service. Access more configuration options and deployment information from the sidebar.
- To do so, navigate to your GrowthBook deployment under
Services
. Click the icon that looks like an arrow forming a circle. When you hover your mouse over the icon it should sayRollout restart
. - Wait for your service to fully restart. You can tell the redeploy is done, if the progress bar near the top right of the page is green in color.
- In the upper right of the page find the URL beginning with
app
and click the button to the right of it to open it.
What if you want to codify GrowthBook’s deployment? Then you need Northflank’s templates. Templates create dynamic and reproducible infrastructure as code (IaC) for any project.
You can use templates to quickly reproduce the same environment and deploy the same app into different clouds or regions with a single click.
Create a new template
- Click the
Create New
button at the top of the page, and click onTemplate
. Scroll down and click the buttonGet started with the visual editor
. - This should show you a page with two panes. The left is the visual representation of the template, and the right is a set of options for whichever node you have selected.
- On the project node, which should be already selected, set the name to
growthbook
for the project and a pick a deployment region. Click onSave node
. - The prior name is for the project that will be deployed when you run the template. You will also need to pick a name like
GrowthBook
for the template itself. TheName
field for this is on the upper left of the page.
- Click the
From the right hand bar, click and drag
Addon
to the bottom of your template below the project node.- Click MongoDB, set the name to
mongo
, and for the version chooselatest
- Click
Save node
- Click MongoDB, set the name to
You want the database to be up and running before the service gets deployed. Let’s add a node to make the service wait. From the right-hand bar, click and drag
await condition
to the bottom of your template.- In the options pane pick Addon for the resource kind, the database name
mongo
which you just created for resource. For the fieldWait until…
selectresource is running
. - Click to save node
- In the options pane pick Addon for the resource kind, the database name
From the right-hand bar, click and drag
deployment service
to the bottom of the visual editor.- Set the service name to
growthbook-svc
, select external image, and set the docker image togrowthbook/growthbook:latest
. - Scroll down to the networking section. For port 3000 set the name to
app
. For port 3100 change the protocol to HTTP and click the box topublicly expose this port to the internet
. Finally, for port 3100 set the name toapi
.
- Set the service name to
From the right-hand bar, click and drag
Secrets group
to the bottom of the template below the deployment.- Give your secret group the name
connection
, and scroll down to theSecrets
section. Click theEnv
option and copy and paste the following.APP_ORIGIN="https://${refs.growthbook-svc.ports.0.dns}:443" API_HOST="https://${refs.growthbook-svc.ports.1.dns}:443" NODE_ENV="production" JWT_SECRET="${fn.randomSecret(256, 'base64')}" ENCRYPTION_KEY="${fn.randomSecret(256, 'base64')}" CORS_ORIGIN_REGEX=".*"
- The next step is adding the connection string from the MongoDB Addon created in one of the previous steps. Scroll down to
Linked Addons
and click on your Addon. - Click on
MONGO_SRV
. UnderAliases
click the plus mark and enterMONGODB_URI
. Click save node.
- Give your secret group the name
The final step is to restart the deployment, so it can pick up the new environment variables in the secrets group. This is necessary since you made a secrets group with a reference to the deployment (like
${refs.growthbook-svc.ports.0.dns}
). The deployment has to exist before that reference will have a value.- From the right-hand bar, click and drag
Run action
below the secrets group node. SetKind
to service. SetProject
togrowthbook
(which you set in the first step). SetResource
togrowthbook-svc
, which is the name you chose in step 2. - Set
Action
to restart and clicksave node
. - Finally, click to save changes and click the
Run
button on the upper right of the template page. A new project namedgrowthbook
will be created, and as steps are successfully executed you will see them turn green. Once everything is green, you can explore your project.
- From the right-hand bar, click and drag
You can integrate your cloud account with Northflank to deploy into other cloud providers, such as GCP, AWS, or Azure. This will let you deploy Northflank-managed clusters into your chosen cloud provider and fine-tune your infrastructure and networking to suit your requirements.
You can deploy the same workloads and projects across any cloud provider, manually or using templates, without having to change a single configuration detail.
Try exploring the GrowthBook’s docs for setting up your first test. Alternatively, you can learn more about adding a domain, which would solve the issue of the CORS_ORIGIN_REGEX
needing to be a .*
catch all. Or, you could read our docs for creating a release flow that includes ephemeral preview environments.
You can add pipelines and releases flows. These can automate your entire DevOps workflow from dev to prod. Set up ephemeral preview environments to automatically share your work with reviewers on your team.
Get production ready with Northflank through horizontal and vertical scaling. You have observability, metrics, and logs to explore for your project.
Northflank allows you to deploy your code and databases within minutes. Sign up for a Northflank account and create a free project to get started.
- Deployment of Docker containers
- Create your own stateful workloads
- Persistent volumes
- Observe & monitor with real-time metrics & logs
- Low latency and high performance
- Backup, restore and fork databases