This repository contains Snapcraft rocks and the sources to generate them. The rocks are OCI-compliant container images that run different versions of Snapcraft to create snaps.
Each rock in this repository bundles a specific version of Snapcraft, targeting snaps for a specific core. The currently supported versions and cores have the following tags:
7_core22
, bundling the latest Snapcraft 7 capable of buildingcore22
snaps.8_core22
, bundling the latest Snapcraft 8 capable of buildingcore22
snaps.8_core24
, bundling the latest Snapcraft 8 capable of buildingcore24
snaps.
The contained Snapcraft needs access to the directory containing the project
that you want to snap (the directory containing the snap
folder with a
snapcraft.yaml
file), and this directory needs to be exposed to the
running container as /project
. For example, the following command will
mount the current directory into a new container and run pack
on the
latest version of Snapcraft 7 for core22 snaps:
docker run -it -v `pwd`:/project ghcr.io/canonical/snapcraft:7_core22 pack
Other commands, like clean
or build
, can be called simply by replacing
pack
in the example above. Every argument provided after the image name is
forwarded to Snapcraft.
Please report all issues, improvements and feature requests at https://github.com/canonical/snapcraft-rocks.
The sources in this repository are capable of building different versions of
Snapcraft, targeting snaps for different cores. The sources are separated
into Git branches in the form coreX-Y
, where X
is a core number (like
22
or 24
), and Y
is a major version of Snapcraft (like 7
or
8
).
For example, branch core22-7
contains the Rockcraft project to create
a rock containing the latest stable version of Snapcraft 7 and can be used
to create snaps targetting core22
.
These are the currently supported combinations of Snapcraft versions and cores:
- Branch
core22-7
, for rocks with latest Snapcraft 7 to buildcore22
snaps. - Branch
core22-8
, for rocks with latest Snapcraft 8 to buildcore22
snaps. - Branch
core24-8
, for rocks with latest Snapcraft 8 to buildcore24
snaps.
- Rockcraft is needed to generate the rocks (minimum version
1.1.0
). - Docker or some other engine is needed to create containers from the images.
Note: Docker can sometimes make
iptables
changes that break LXD instances used by Rockcraft. See this page for details.
- First, choose a target Snapcraft version and core and checkout the appropriate
branch. As an example, let's use branch
core22-7
. - Run
rockcraft pack
to create a rock whose name starts withsnapcraft-core22_7
. The remainder of the name depends on the actual full version of Snapcraft and the host architecture. For example, running this command on anamd64
machine when7.5.4
is the latest stable Snapcraft 7 version will yield a rock calledsnapcraft-core22_7.5.4_amd64.rock
. - Use a tool like Skopeo to convert and load the rock into Docker's local
registry. You can use the
skopeo
binary included in Rockcraft's snap for this (see the instructions on Rockcraft's docs). - Finally, use Docker to create containers to run Snapcraft as described in the Usage section above.