Skip to content

Local backend development

danslapman edited this page Jun 5, 2023 · 8 revisions

Here's a small guide about how to build & run mockingbird locally.

Prerequisites

To run mockingbird in any variant on your personal machine, you'll need a running mongodb instance.

Running mockignbird on JVM

Follow the following steps:

  1. Install JDK 17. JDK vendor doesn't matter, you can use your preferred distribution.
  2. Download frontend artifacts from one of the latest workflow runs
  3. Create /dist/out directory in /frontend directory and unpack artifact archive into it
  4. Create local.conf file in /backend/mockingbird/src/main/resources (this path is already git-ignored). Here is a minimal example of configuration file:
include classpath("application.conf")

ru.tinkoff.tcb {
  db {
    mongo {
        uri = "mongodb://localhost:27017/localdb" <- URI of you mongodb instance/cluster
    }
  }

  security {
    secret = "..."
  }
}
  1. Go to /backend directory
  2. Run sbt "project mockingbird-api; run"

Running mockinbird as a native image

Follow the following steps:

  1. Install GraalVM or Liberica NIK.
  2. Install native-image module via gu
  3. Download frontend artifacts from one of the latest workflow runs
  4. Create /dist/out directory in /frontend directory and unpack artifact archive into it
  5. Go to /backend directory
  6. Run sbt "project mockingbird-native; GraalVMNativeImage / packageBin"
  7. Create qa.conf in /mockingbird-native/target/graalvm-native-image with the following contents:
include classpath("application.conf")
include file("./mockingbird-native/target/graalvm-native-image/secrets.conf")

ru.tinkoff.tcb {
  db.mongo = ${?secrets.mongodb}
  server = ${?secrets.server}
  security = ${secrets.security}
  proxy = ${?secrets.proxy}
  event = ${?secrets.event}
}
  1. Create secrets.conf in /mockingbird-native/target/graalvm-native-image with the following contents:
secrets {
    mongodb {
        "uri": "mongodb://localhost:27017/localdb"
      }

  security {
    secret = "..."
  }
}
  1. Assuming you are in /backend directory, run ./mockingbird-native/target/graalvm-native-image/mockingbird-native -Dconfig.file=./mockingbird-native/target/graalvm-native-image/qa.conf