I am using snapcraft with --provider lxd
option to build my snaps which require some resources from the host, like binding a directory from the host to the LXC container. Because snapcraft doesn’t use LXC profiles for creating its own class of containers, I had to change the default profile and add those configure sections to the containers. But this is not a good practice in general, because it would be applied to all the containers that will not be necessary related to my build environment. I went through the code on GitHub a little bit, and I didn’t notice anywhere that you apply a specific configuration or profile so I can provide one. A workaround is to create the containers manually, apply the profiles, and then the snapcraft will skip the creation, which seems more like a hack to me and obviously is not a stable solution. My request from the snapcraft team is:
- Provide means to apply LXC profiles that are for example provided in the snap directory of the project. So the snapcraft should check if a file like
lxc.config
is in the snap directory of the project, and if it’s the case, then apply this config by creating a profile or directly to the container. Another option would be to pass a list of profiles in an environment variable likeSNAPCRAFT_LXC_PROFILES
as a comma-separated list, and then calllxc assign
to apply these profiles to the builder containers directly, then delegate the task of populating the profiles to the users. I suppose the second solution could be applied in few lines of the code. - The same feature for Multipass would also be great. In general I’m not familiar with how you can edit the Multipass configurations as it is with LXC profiles, so I cannot use them with my project at all or give you comments on how you can possibly make this feature.