Remote build

There are two methods for building snaps on Canonical-hosted servers, and both are available to every snap publisher:

  • Build from GitHub This is a build service integrated into every publisher’s Developer Account on snapcraft.io. It works by linking a snap’s GitHub repository with our Launchpad build service. See Build from GitHub for further details.

  • Snapcraft remote-build The snapcraft remote-build command offloads the snap build process to the Launchpad build farm, pushing the potentially multi-architecture snap back to your machine. See below for further details.

Remote build is a feature in Snapcraft that enables anyone to run a multi-architecture snap build process on remote servers using Launchpad.

With remote build, you can build snaps for hardware you don’t have access to and free up your local machine for other tasks.

Supported build architectures can be found here.

:information_source: See Creating a snap for details on creating the metadata required to build a snap. For other ways to build a snap, see Build options.


Prerequisites

Launchpad

Prospective snaps need to be open source, as the code will be publicly available, and you’ll need a Launchpad account.

Platforms and Architectures

core24

Platforms can be defined within a snap’s snapcraft.yaml using the platforms keyword.

If platforms is not defined within snapcraft.yaml, architectures can be specified at build-time with the --build-for argument:

snapcraft remote-build --build-for=amd64,arm64

core22 | core20

Build architectures can be defined within a snap’s snapcraft.yaml using the architectures keyword. See the architectures reference for more information.

If architectures is not defined within snapcraft.yaml, target architectures can be specified at build-time with the --build-for argument.

If no architecture is specified, remote build will default to amd64. For more details on how snaps handle build and run architectures, see Architectures.

Git repository

Starting in snapcraft 8, projects must be in the top level of a git repository, except when the legacy remote-build behavior is triggered (see the legacy remote build section).

Shallowly cloned repositories are not supported (git clone --depth=<n>) because they cannot be pushed to Launchpad.

Using remote build

To instantiate a remote build, use the remote-build argument with snapcraft:

snapcraft remote-build
  1. You are first asked to confirm that you’re happy for your local project to be transferred to a remote build server and become publicly available:

    All data sent to remote builders will be publicly available. Are you sure 
    you want to continue? [y/N]: y
    

    Skip the above by passing --launchpad-accept-public-upload to snapcraft as an extra argument.

  2. Snapcraft will now launch your default browser with an authorisation URL. The URL is also output to the terminal to allow you to copy and paste it.

    The authorization page:
     (https://launchpad.net/+authorize-token? 
    oauth_token=xxx&allow_permission=DESKTOP_INTEGRATION)
    should be opening in your browser. Use your browser to authorize
    this program to access Launchpad on your behalf.
    Waiting to hear from Launchpad about your decision...
    

    This prompt occurs the first time you use remote build from a new machine. Access can be enabled until you disable it, for one hour, for one day, or for one week. Alternatively, you can use the same link to disable access completely.

    Credentials are stored under $XDG_DATA_DIR/snapcraft/launchpad-credentials.

The remote build process will now start.

Example remote-build output

The following is typical output for a successful single architecture remote build:

Sending build data to Launchpad... (https://<username>:<token>@git.launchpad.net/<username>/+git/snapcraft-hello-22ef03/)
If interrupted, resume with: 'snapcraft remote-build --recover'
Building snap package for amd64. This may take some time to finish.
Build status as of 2019-11-29 11:44:50.017631:
        arch=amd64      state=Needs building
Build status as of 2019-11-29 11:45:20.215169:
        arch=amd64      state=Currently building
Build status as of 2019-11-29 11:45:50.472400:
        arch=amd64      state=Currently building
Build status as of 2019-11-29 11:46:20.968422:
        arch=amd64      state=Currently building
Build status as of 2019-11-29 11:46:51.206255:
        arch=amd64      state=Uploading build
Build status as of 2019-11-29 11:47:21.871779:
        arch=amd64      state=Uploading build
Build status as of 2019-11-29 11:47:52.197560:
        arch=amd64      state=Successfully built
Snapped hello_2.10_amd64.snap
Build log available at 'hello_amd64.1.txt'
Build complete.

Snapcraft waits for the build to complete before retrieving the resultant snaps, and build logs, and placing them all in your local build directory. Build time depends on the target architecture, the package size, and the availability of builder back-ends.

If your build is interrupted for any reason, it can be resumed with the --recover argument:

snapcraft remote-build --recover

Monitor a build

Command output from remote build will show build progress for each architecture. You can retrieve the same output from another terminal session within the build directory using the --status argument:

snapcraft remote-build --status

To see build progress outside of your command line session, open the following URL in a web browser: https://launchpad.net/~/+snaps.

From the snap packages web page, select the build data for the job you want to monitor. The specific name for a job is part of the output from the remote-build command, such as snapcraft-hello-22ef03.

Launchpad remote build management

Selecting the build page for a build allows you to monitor the build progress for each architecture, and access the completed build log for each.

Launchpad remote build progress

The Launchpad build page and the remote build are removed after a build terminates, regardless of whether the build was successful or not.

Launchpad project

By default, the remote-builder will create a project in Launchpad under https://launchpad.net/<launchpad-username>-craft-remote-build.

To use a different project, use snapcraft remote-build --project <project-name>. The user must create the project before running remote-build. Private projects are supported.

Legacy remote build

Remote-build in Snapcraft 7 and earlier versions tarballed sources, modified the snapcraft.yaml, and created a new git repository. Starting in snapcraft 8, remote-build has improved git-based workflow that no longer modifies your project.

The legacy behavior is still available for core20 and core22 snaps. The environment variable SNAPCRAFT_REMOTE_BUILD_STRATEGY can be set to:

  • disable-fallback to force the new feature
  • force-fallback to force the legacy feature of tarballing the sources

If the environment variable is unset, snaps will use the new remote-build.


Last updated 7 months ago.