CI/CD Pipelines for Realm - Keeping the Code in a Single Repo

Hey Peeps,

We’ve had conversations previously about how to setup CI/CD pipelines for Realm Serverless apps, so I wanted to provide an update on my latest pipeline changes.

I’ve just finished updating my CI/CD pipeline so that code for each stage is in a branch in a single repo. Previously, the code for each stage was in its own repo, because Realm auto-deploys only worked from the master branch. Now that Realm auto-deploys can be configured to work from any branch, I’ve moved the code to a single repo. This should make it easier to manage moving code between the stages.

I’ve updated the Readme of my app to explain how I’ve configured the pipeline: https://github.com/mongodb-developer/SocialStats/blob/master/README.md

@Lukas_deConantseszn1 I wanted to let you know about the updates to my Readme in case you found them helpful ^^

How is your pipeline going? Have you learned anything along the way? Is your pipeline similar to mine, or have you found another approach to work better?

2 Likes

Hi @Lauren_Schaefer! Thank you so much for your message!

I did find them super helpful. I ended up changing a few things. For instance, I decided to use multiple clusters per your own architecture. And I decided to use the same DB name in each cluster so I didn’t have to change that up.

I still had to use the script from @kraenhansen to replace things like the cluster name, app_d domiain information like custom_domain and app_default_domain. I don’t know if using github auto deploy would remove the need for some of this search and replace, but I haven’t explored that enough. I’m still using github actions to run tests and deploy code. One thing I noticed with using the realm CLI to deploy, is sometimes it can mess up your data cluster link and database triggers will start failing

Anyway, I still want to implement some of the cool stuff from your setup like function tests and UI tests. Hopefully soon!

Love the README! :grin:

2 Likes

@Lukas_deConantseszn1 I’m happy to hear you were able to get your pipeline working!

Multiple clusters makes a lot of sense if you’re not using the free clusters.

FWIW, I just deleted the app specific stuff in my config files…and everything kept working. I don’t know if there are any consequences to that. @kraenhansen Is that problematic? For example, if I export my Realm app in the Realm web UI, my services/mongodb-atlas/config.json file looks like:

{
    "id": "reallylongappid",
    "name": "mongodb-atlas",
    "type": "mongodb-atlas",
    "config": {
        "clusterName": "Cluster0",
        "readPreference": "primary",
        "wireProtocolEnabled": false
    },
    "version": 1
}

The services/mongodb-atlas/config.json file in my repo looks like this:

{
    "name": "mongodb-atlas",
    "type": "mongodb-atlas",
    "config": {
        "readPreference": "primary",
        "wireProtocolEnabled": false
    },
    "version": 1
}

The config.json in the root directory of my exported app looks like:

{
    "app_id": "myappid",
    "config_version": 20200603,
    "name": "SocialStats-Staging",
    "location": "US-VA",
    "deployment_model": "GLOBAL",
    "security": {},
    "hosting": {
        "enabled": true,
        "app_default_domain": "mydomain.mongodbstitch.com"
    },
    "custom_user_data_config": {
        "enabled": false
    },
    "sync": {
        "development_mode_enabled": false
    }
}

The stitch.json (I haven’t renamed the file yet since the rebrand from Stitch to Realm) looks like:

{
    "config_version": 20180301,
    "security": {},
    "custom_user_data_config": {
        "enabled": false
    },
    "realm_config": {
        "development_mode_enabled": false
    }
}