Your submission was sent successfully! Close

Thank you for contacting us. A member of our team will be in touch shortly. Close

You have successfully unsubscribed! Close

Thank you for signing up for our newsletter!
In these regular emails you will find the latest updates about Ubuntu and upcoming events where you can meet our team.Close

Fabrica – Your self-hosted snap factory

This article is more than 4 years old.


There are many ways one can go about building snaps. You can do it on your local system, by manually running commands in a terminal window. If you have a developer account in the Snap Store, you can use the integrated build functionality to create snaps. You can also use Launchpad, Electron Builder or a range of CI/CD systems. And you can also run your own, self-hosted snap building factory!

Setting up shop

Fabrica is a brand new, early development, locally hosted Web service designed to help developers build snaps. The idea behind Fabrica is simple and clever. You get an automated system that can hook up remote repositories and build snaps whenever there is a change in the source tree. This way, you can manage multiple projects and generate up-to-date builds, with little to no interaction.

Fabrica consists of two layers:

  • A simple Web UI that allows you to add an unlimited number of publicly available, clonable Git trees. You can choose different (or multiple) branches for each tree.
  • Under the hood, Fabrica runs the LXD container service, which spawns container instances, inside which the Git trees are cloned and snaps built. You can then “download” the built snaps, test and use them.

Fabrica prerequisites

The first step is to install and configure the LXD service on your system. If you already have it, then you can skip this step. If not, you should install the LXD snap, and go through the first-time setup wizard on the command line. For most users, the default options will work just fine.

snap install lxd
sudo lxd init

Once the LXD component is set up, you can install Fabrica:

snap install fabrica

After the snap is installed, you will need to do just a tiny bit of manual work. Snaps are designed to be self-contained applications, with strong security and isolation from the underlying system and other software running on it. Granular access to system resources is possible through a mechanism called interfaces. Some interfaces are auto-connected; when you install a snap, the requested resources are provisioned automatically. Some, for security reasons, are not.

In this particular case, you will need to grant Fabrica permission to access the LXD service, mount-observe (read mount table and quota information), and system-observe (read process and system information).

snap connect fabrica:lxd lxd:lxd
snap connect fabrica:mount-observe
snap connect fabrica:system-observe

Now, you are all set.

Fabrica in action

Fabrica runs and listens on port 8000. At the moment, the connection is available via HTTP, and there is no secure tunnel or authentication, which means you ought to test and run this service over trusted networks only. As a project in development, it should receive new features and capabilities in the future.

You can now add repositories. Choose the desired project and branch.

Once added, you can manually trigger a build, or wait for a scheduled operation. Fabrica polls the added repositories for changes every five minutes, and will trigger a build if one is required.

While a build is running, you can inspect what’s happening by clicking on the “i” icon in each build line. This will expand the log and show the commands running inside the build container, like perhaps the repository data fetch, system update, compilation, or other commands. All of this happens in isolation from your underlying system.

Once the snap is built, you can use the “Download” button to fetch it from inside the container build environment and place it somewhere on your disk. And that’s it. You have a repository configured for automated builds in a simple and convenient way.

Fabrica currently generates builds only for the local architecture (like say AMD64), so if you want to create builds for other platforms, you will need to set up Fabrica on corresponding hardware (like say Raspberry Pi 4). But this may become simpler and easier in the future.

Summary

For people looking for a largely hands-free setup to automate their snaps builds, Fabrica offers a simple, convenient solution. It is not designed to replace the existing methods; instead, it complements the robust build and integration mechanisms already in place, and offers yet another practical toolbox to developers and enthusiastic users.

Now, some options and features are currently unavailable, like perhaps authentication or customizable build trigger period, but this is where you come in! Grab Fabrica and run your own tests, and if you have any recommendations or suggestions, please join our forum, and share your thoughts.

Photo by Science in HD on Unsplash.

Ubuntu cloud

Ubuntu offers all the training, software infrastructure, tools, services and support you need for your public and private clouds.

Newsletter signup

Get the latest Ubuntu news and updates in your inbox.

By submitting this form, I confirm that I have read and agree to Canonical's Privacy Policy.

Related posts

Snapcraft 8.0 and the respectable end of core18

‘E’s not pinin’! ‘E’s passed on! This base is no more! He has ceased to be! ‘E’s expired and gone to meet ‘is maker! ‘E’s a stiff! Bereft of life, ‘e rests in...

Craft team welcomes you to another episode of its adventures

Welcome to the second article in the Craft team saga. Previously, on Craft Team, we gave you a brief introduction into the team’s function, we announced our...

The long ARM of KDE

With over 100 applications available in the Snap Store, KDE is by far the biggest publisher of snaps around. What unifies this impressive portfolio is the...