How to Deploy from a Monorepo

Deploy Using Monorepo as the Source

  1. Visit the Apps page and click Create App.

  2. Select the GitHub repository that contains your source code and specify the branch or tag in your repository that contains your app’s source code. If you’d like to automatically re-deploy your app when pushing to this branch/tag, select Autodeploy code changes and click Next.

  3. In the Source Directory field, specify the folder that contains the source and click Find Directory.

    If your app needs to access files outside of its subdirectory at run-time, use / as the source directory.

    At the beginning of the build, the entire repo is cloned to /workspace. When you specify a source directory, it is used as the working directory for the entire build instead of /workspace. Files outside of the selected source directory are accessible only during the build. At run-time, only files inside the source directory are accessible. Therefore, if your app needs to access files outside its subdirectory at run-time, you should not specify a source directory and instead adjust the build and run commands using cd <subdirectory> directives as needed.

  4. Configure any details such as HTTP routes, environment variables, the run command, or the HTTP port.

  5. On the next page, give your app a name.

  6. Select the plan and instance size you would like to use when a container is created from the image. Click Launch App.

Deploy Apps from Node.js Monorepo

For Node.js monorepos, you need to configure the build and run commands as follows when creating the app:

  • For YARN Workspaces:

    1. Edit the Build Command section and add the following:
    cd <path-to-source-subdirectory>
    yarn build
    
    1. Edit the Run Command section and add the following:
    cd <path-to-source-subdirectory>
    yarn serve
    
  • For Lerna and NPM, Lerna and YARN, or Lerna and YARN Workspaces:

    1. Add lerna bootstrap to the scripts property in the package.json file:
    "scripts": {
        "bootstrap": "lerna bootstrap",
        "postinstall": "lerna bootstrap"
    }
    
    1. Edit the Build Command section and add the following:
    yarn bootstrap
    cd <path-to-source-subdirectory>
    yarn build
    
    1. Edit the Run Command section and add the following:
    cd <path-to-source-subdirectory>
    npm run serve
    

Sample Monorepos

We provide the following sample monorepos that you can deploy using App Platform:

  • sample-monorepo: A sample monorepo GitHub repository where each subdirectory is an independent app.
  • sample-yarn-workspaces-monorepo: A sample Node.js monorepo GitHub repository that uses Yarn workspaces and has an app with dependencies outside its subdirectory.
  • sample-yarn-lerna-monorepo: A sample Node.js monorepo GitHub repository that uses Lerna and has an app with dependencies outside its subdirectory.
The build and run commands are the command-line statements that compile your app component at build time and launch your app component after it has been built, respectively.
A region is a physical location in the world where DigitalOcean has a datacenter that can run your App Platform app.
Scaling is the process of adding more capacity to a component in your app, either horizontally (more containers) or vertically (more CPU and memory per container).