v1
Double column
API
CLI
JS Client

Services /

Create build service

Creates a new build service.

Required permission

Project > Services > General > Create

Path parameters

    • projectId

      string required

      ID of the project

Request body

  • {object}
    • name

      string required

      The name of the service.

      min length
      3
      max length
      20
      pattern
      ^[a-zA-Z]((-|\s)?[a-zA-Z0-9]+((-|\s)[a-zA-Z0-9]+)*)?$
    • description

      string

      A description of the service.

      max length
      200
      pattern
      ^[a-zA-Z0-9.,?\s\\/'"()[\];`%^&*\-_:!]+$
    • billing

      {object} required
      • deploymentPlan

        string required

        The ID of the deployment plan to use.

        pattern
        ^[A-Za-z0-9-]+$
    • vcsData

      {object} required
      • projectUrl

        string required

        URL of the Git repo to build.

        pattern
        ^(https:\/\/)?((www(\.[a-zA-Z0-9\-]{2,})+\.)?[a-zA-Z0-9\-]{2,})(\.([a-zA-Z0-9\-]{2,}))+(\/([a-zA-Z0-9\-._]{2,}))+?$
      • projectType

        string required

        The VCS provider to use.

        one of
        bitbucket, gitlab, github, self-hosted
      • selfHostedVcsId

        string

        If projectType is self-hosted, the ID of the self-hosted vcs to use.

        pattern
        ^[A-Za-z0-9-]+\/[A-Za-z0-9-]+$
      • accountLogin

        string

        By default, if you have multiple version control accounts of the same provider linked, Northflank will pick a linked account that has access to the repository. If accountLogin is provided, Northflank will instead use your linked account with that login name.

    • buildSettings

      (multiple options) required
      • {object}

        Build from a Dockerfile

        • dockerfile

          {object} required
          • buildEngine

            string

            Build engine to use. Defaults to recommended build engine kaniko

            one of
            kaniko, buildkit
          • useCache

            boolean

            Should intermediate image layers be cached? Only supported by Kaniko.

          • dockerFilePath

            string required

            The file path of the Dockerfile.

            pattern
            ^\/([a-zA-Z0-9-._]+\/)*[a-zA-Z0-9-._]+$
          • dockerWorkDir

            string required

            The working directory of the Dockerfile.

            pattern
            ^\/([a-zA-Z0-9-._]+\/)*[a-zA-Z0-9-._]*$

        OR

      • {object}

        Build from a Buildpack

        • buildpack

          {object} required
          • builder

            string

            Buildpack stack to use. Defaults to recommended stack HEROKU_20.

            one of
            HEROKU_20, HEROKU_18, GOOGLE_V1, CNB_ALPINE, CNB_BIONIC, PAKETO_TINY, PAKETO_BASE, PAKETO_FULL
          • buildpackLocators

            [array]

            Array of custom Buildpacks to use.

            • string

              Url or registry identifier of custom Buildpack.

          • buildContext

            string

            The working directory to build in.

            pattern
            ^\/([a-zA-Z0-9-._]+\/)*[a-zA-Z0-9-._]*$
    • buildConfiguration

      {object}
      • prRestrictions

        [array]

        An array of pull request build rules. Only supported for build services. Each commit belonging to a pull request on a branch that matches one of the provided build rules will be built automatically.

        • string

          A pull request build rule. Can contain * as a wildcard to match multiple branch names. For example, feature/* will build all commits from pull requests from branches that start with feature/.

          pattern
          ^[^?:@$~ [\]{}]*$
      • branchRestrictions

        [array]

        An array of branch build rules. Only supported for build services. Each commit belonging to a branch that matches one of the provided build rules will be built automatically.

        • string

          A branch build rule. Can contain * as a wildcard to match multiple branch names. For example, feature/* will build all commits from branches that start with feature/.

          pattern
          ^[^?:@$~ [\]{}]*$
      • pathIgnoreRules

        [array]

        An array of path ignore rules. A commit will only be built if a file has been changed that does not match any of the ignore rules. Path ignore rules follow .gitignore syntax.

        • string

          A path ignore rule, following .gitignore syntax. For example, *.md will ignore all files ending with .md.

    • buildArguments

      {object}

      An object containing the build arguments to set for the service

      • buildFiles

        {object}

        Secret files as JSON object, encrypted at rest. File path must be absolute

      Response body

      • {object}

        Response object.

        • data

          {object} required

          Result data.

          • id

            string required

            Identifier for the service

          • appId

            string required

            Full identifier used for service deployment

          • name

            string required

            Service name

          • description

            string

            A short description of the service

          • projectId

            string required

            ID of the project that the service belongs to

          • createdAt

            date required

            The time the service was created.

          • disabledCI

            boolean required

            Whether Continuous Integration is disabled

          • disabledCD

            boolean required

            Whether Continuous Deployment is disabled

          • billing

            {object} required
            • deploymentPlan

              string required

              ID of the billing plan used by this service

          • status

            {object} required

            Details about the current service status.

            • build

              {object}

              Details about the status of the most recent build.

              • status

                string required

                The current status of the build.

                one of
                PENDING, STARTING, CLONING, BUILDING, UPLOADING, ABORTED, FAILURE, SUCCESS, CRASHED
              • lastTransitionTime

                date

                The timestamp of when the build reached this status.

            • deployment

              {object}

              Details about the current deployment status.

              • status

                string required

                The current status of the deployment.

                one of
                IN_PROGRESS, COMPLETED
              • reason

                string required

                The reason the current deployment was started.

                one of
                SCALING, DEPLOYING
              • lastTransitionTime

                date

                The timestamp of when the deployment reached this status.

          • servicePaused

            boolean required

            Is the service paused?

          • serviceType

            string required

            Type of the service (combined, build or deployment)

            one of
            combined, build, deployment
          • vcsData

            {object}
            • projectUrl

              string required

              URL of the repository being built

            • projectType

              string required

              VCS provider for the repo being built

              one of
              bitbucket, gitlab, github, self-hosted
            • selfHostedVcsId

              string

              ID of the self-hosted VCS, if applicable.

            • projectBranch

              string

              Branch of the repo being built

            • publicRepo

              boolean

              Whether the repo is being accessed without authentication.

            • dockerWorkDir

              string required

              Working directory used by the dockerfile

            • dockerFilePath

              string required

              File path of the Dockerfile

          • buildConfiguration

            {object}
            • branchRestrictions

              [array]
              • string
            • prRestrictions

              [array]
              • string
            • pathIgnoreRules

              [array] required
              • string
          • buildEngineConfiguration

            {object} required
            • buildEngine

              string

              The build engine used.

              one of
              buildpack, kaniko, buildkit
            • buildpack

              {object}

              Details about Buildpack settings.

              • builder

                string

                The Buildpack stack used.

                one of
                HEROKU_20, HEROKU_18, GOOGLE_V1, CNB_ALPINE, CNB_BIONIC, PAKETO_TINY, PAKETO_BASE, PAKETO_FULL
              • buildpackLocators

                [array]

                Array of custom Buildpacks used.

                • string

                  Url or registry identifier of custom Buildpack.

            • kaniko

              {object}

              Details about Kaniko settings.

              • useCache

                boolean

                Should intermediate image layers be cached?

      API
      CLI
      JS Client

      POST /v1/projects/{projectId}/services/build

      Example request

      Request body
      curl
      curl --header "Content-Type: application/json" \
        --header "Authorization: Bearer NORTHFLANK_API_TOKEN" \
        --request POST \
        --data '{"name":"Example Service","description":"A service description","billing":{"deploymentPlan":"nf-compute-20"},"vcsData":{"projectUrl":"https://github.com/northflank/gatsby-with-northflank","projectType":"github","accountLogin":"github-user"},"buildSettings":{"dockerfile":{"buildEngine":"kaniko","useCache":false,"dockerFilePath":"/Dockerfile","dockerWorkDir":"/"}},"buildConfiguration":{"prRestrictions":["feature/*"],"branchRestrictions":["feature/*"],"pathIgnoreRules":["README.md"]},"buildArguments":{"ARGUMENT_1":"abcdef","ARGUMENT_2":"12345"},"buildFiles":{"/dir/fileName":{"data":"VGhpcyBpcyBhbiBleGFtcGxlIHdpdGggYSB0ZW1wbGF0ZWQgJHtOT0RFX0VOVn0gdmFyaWFibGU=","encoding":"utf-8"}}}' \
        http://api.northflank.com/v1/projects/{projectId}/services/build

      Example response

      200 OK

      Details about the newly created service.

      JSON

      {
        "data": {
          "id": "example-service",
          "appId": "/example-user/default-project/example-service",
          "name": "Example Service",
          "description": "This is the service description",
          "projectId": "default-project",
          "createdAt": "2021-01-20T11:19:53.175Z",
          "disabledCI": false,
          "disabledCD": false,
          "billing": {
            "deploymentPlan": "nf-compute-20"
          },
          "status": {
            "build": {
              "status": "SUCCESS",
              "lastTransitionTime": "2021-11-29T11:47:16.624Z"
            },
            "deployment": {
              "status": "COMPLETED",
              "reason": "DEPLOYING",
              "lastTransitionTime": "2021-11-29T11:47:16.624Z"
            }
          },
          "serviceType": "build",
          "vcsData": {
            "projectUrl": "https://github.com/northflank/gatsby-with-northflank",
            "projectType": "github",
            "selfHostedVcsId": "example-team/self-hosted-vcs",
            "projectBranch": "master",
            "publicRepo": false,
            "dockerWorkDir": "/",
            "dockerFilePath": "/Dockerfile"
          },
          "buildConfiguration": {
            "branchRestrictions": [
              "feature/*"
            ],
            "prRestrictions": [
              "feature/*"
            ],
            "pathIgnoreRules": [
              "README.md"
            ]
          },
          "buildEngineConfiguration": {
            "buildEngine": "buildpack",
            "buildpack": {
              "builder": "HEROKU_20",
              "buildpackLocators": [
                "https://buildpack-registry.heroku.com/cnb/mars/create-react-app"
              ]
            },
            "kaniko": {}
          }
        }
      }

      Example response

      409 Conflict

      There is already a service with the same derived identifier

      © 2022 Northflank Ltd. All rights reserved.