Building snap using a lxd remote

Is there a means to have snapcraft use a “lxd remote” rather than spawning a lxc container on localhost?

We have a lxd-remote which we would like to be able to use as a better build-platform and use that with local github action-runners.

Anyone that knows if this is possible?

Hi @lonroth,

Unfortunately, Snapcraft only supports local LXD instances and cannot build on a remote LXD server.

Would it be possible to add that support? It would be a killer feature!

Agreed, it’d be really useful! It’s been discussed before but I’m not sure if or when it will be implemented.

1 Like

We want to include our lxd host in github actions, which would be a massive win. Can we help out somehow to get that feature enabled?

Meanwhile, do you know how to incorporate lxd with a local github action-runner to build snap:s ?

Have you checked out this github action by the snapcore team? It says it installs and configures LXD as part of the snap build process.

Yes. The issue is that its spawning the lxd environment on a tiny little running in some cloud, which is not really possible for us (build times and costs are way to high). I can’t see how we can use this on a private runner?

We can look into adding support for this in Snapcraft (which would mean it comes for Charmcraft and Rockcraft too)

1 Like

We would love to see that. The use case it that a user can super-quickly spawn a “prebaked” image with a build environment and use that within a private github/github runner - effectively speeding up build-times with factors. Having it support Incus beside lxd would also be great!

I misunderstood. I thought you were bringing your own runners and wanted something that plugged into the Github Actions ecosystem without rolling your own action.

That’s correct, but I don’t want to be forced to roll up a lxd host on whatever machine that is hosting the runner which is what the above action does?

If the current github-action could then be perhaps modified to allow to specify enough information to connect to a lxd-remote with credentials.

snapcraft pack --use-lxd-remote https://lxc-incus-host:8443 --lxd-credentials ....

We could then have a tiny lxc container, running a github or gitlab runner which would be active at all times running the above thing for building snaps pretty much on demand with little resources needed for snaps to by built on the much more powerful lxd remote.

I found something that we might test here (Yes, we are running juju) https://charmhub.io/github-runner