v1

To build and run code from one branch on a repository you can use:

  • a combined service
  • a build service linked to a deployment service
  • a cron or manual job

Create a new service or job, select the Git provider that contains the repository you want to build from, then select the branch.

Once created your service will build an image for every new commit to the branches or pull requests it is monitoring, as long as CI is enabled.

You can manually trigger a build by navigating to the branch or pull request to build from and selecting a commit to build.

You can find the list of branches and pull requests in the build service menu, or by clicking the build button in the build service header.

Northflank will begin building your commit, which may take several minutes. You can monitor the progress from the builds page and click through to view the logs for the build.

If you have a single repository with multiple services, or your repository is structured so that your build context or Dockerfile are not in the root, you can specify their locations when creating or editing your services.

You can specify the set of files to be used in the Docker build process by referring to a specific subdirectory relative to the root of your repository. To build all files from the root, use / as the build context or refer to a subdirectory such as /directory or /directory/subdirectory.

Learn more about Docker contexts .

You can specify the location of the Dockerfile relative to the root of the repository. For example root: /Dockerfile, or in a subdirectory: /directory/subdirectory/Dockerfile.

Learn more about the Dockerfile .

Available on combined and build services.

Build arguments (ARG) can be set to be passed to the Docker container at build-time. These can be set for individual builds on the build arguments page or set as project secrets to be applied to all or specific builds in a project.

Build arguments will be passed to the Dockerfile on build via the --build-arg flag. They do not persist in the built image and are set as key-value pairs. Variables must be declared in the Dockerfile with ARG before being accessed. For example, a variable set as "packages" : "npm-cache" can be accessed in the Dockerfile by declaring the ARG:

ARG packages
# or initialise with a default value:
# ARG packages=default_value

RUN echo "Using: ${packages}"

Build arguments are entered as key-value pairs, or by using JSON by toggling JSON view on and using the following format:

{
    "key1": "value1",
    "key2": "value2"
}

An .env file can also be uploaded and edited using the following format:

KEY_1=value1
KEY_2=value2

You can build your projects on Northflank by supplying a Dockerfile in your repository.

A custom Dockerfile gives you full control over each step of the build process, including things like build arguments and custom base images. You must specify the location of the Dockerfile in your repository and the build context (root by default).

Select Dockerfile as the build type when creating your service, or change an existing service from the build options page.

See Docker's guide on writing Dockerfiles and the Dockerfile reference for more information.

Build engine

Choose between Kaniko (default) or BuildKit under advanced build settings. You may want to choose another build engine if you experience any issues with reliability.

You can build your projects on Northflank using buildpacks . This does not require you to supply a Dockerfile as a buildpack will try to automatically determine how to build your project. You must specify the build context (root by default).

Select buildpack as the build type when creating your service, or change an existing service from the build options page.

You can select from a list of popular buildpacks under advanced build settings if you require support for other languages. Check the provider's documentation for more information on base images and language versions.

Buildpack stacks on Northflank

BuildpackBase imageSupported languages
heroku/buildpacks:20 Ubuntu 20.04Ruby, Node.js, Clojure, Python, Java, Gradle, JVM, Grails 3.x, Scala, Play 2.x, PHP, Go
heroku/buildpacks:18 Ubuntu 18.04Ruby, Node.js, Python, Java, PHP, Go
gcr.io/buildpacks/builder:v1 Ubuntu 18.04.NET Core, Java, Python, Node.js, Go
cnbs/sample-builder:alpine Alpine 3.10Java, Kotlin
cnbs/sample-builder:bionic Ubuntu 18.04Java, Kotlin, Ruby
paketobuildpacks/builder:tiny Ubuntu 18.04Java, Go

Custom buildpack group

You can use multiple buildpacks together to provide support for more complex builds. For example you might use one buildpack to install Java, and another buildpack to use Maven to build your application. The builder will run through all the buildpacks to identify the correct ones to use in the build.

You can include other buildpacks by providing the URLs of buildpacks (for example https://buildpack-registry.heroku.com/cnb/mars/create-react-app).

Heroku buildpacks can be found on the Elements marketplace . A direct link can be found by replacing parts of the following URL with the namespace and buildpack you want to use.

Heroku commandURL
heroku buildpacks:set [namespace]/[buildpack]https://buildpack-registry.heroku.com/cnb/[namespace]/[buildpack]

For example to use the create-react-app buildpack from mars, which would use the Heroku command heroku buildpacks:set mars/create-react-app, you would enter the URL https://buildpack-registry.heroku.com/cnb/mars/create-react-app.

You can check the URL is correct by navigating to it in your browser, which should point towards a tar.gz file.

© 2021 Northflank Ltd. All rights reserved.