Reproducible Snap Builds via Snapcraft and LXD

in #linux7 years ago (edited)

Advantages of Reproducible Builds

  • Reproducible, that's a win in itself.
  • You avoid polluting your environment.
  • Your build environment is consistent.

How are Reproducible Builds Made

  • snap
  • snapcraft
  • lxd

Examples of building via LXD containers

Ensure Snap is installed and Running

sudo systemctl start snapd

Installing LXD

sudo apt-get install lxd

Configuring LXD

sudo lxc init
You'll be prompted with setup questions, I recommend keeping the defaults.

Starting a Build via LXD

snapcraft cleanbuild
cleanbuild will automatically setup a new lxd container to execute your build. This makes for a completely clean build of your application.

snapcraft cleanbuild --debug
The following command will build the package in container and remain on failure. This gives you the opportunity to test and debug your build in a bash shell.

Official Video

If you'd like to hear about it in more detail, here is snapcraft's official video on the subject.