Build on Docker

Hello,

I think this doc should be superseded by https://docs.snapcraft.io/building-the-snap-on-docker/6757

First of all, it gives docker installation instruction which seems out of scope (and a moving target depending on version of ubuntu and docker).

Then it uses sudo to interact with docker, which is not needed if the user is in the docker group.

Finally, it forgets to mention the command to be run against the docker container, so:

$ sudo docker run -v "$PWD":/snapcraft_build \
       -w /snapcraft_build snapcore/snapcraft 
$ snapcraft

This doesn’t result in an interactive shell, so either it should be something like (-it was added to Keep STDIN open even if not attached and Allocate a pseudo-TTY; we could also add --rm to clean after the operation):

$ docker run -it -v "$PWD:/snapcraft_build" -w /snapcraft_build snapcore/snapcraft
# snapcraft       // <-- this is being executed within the container

Or something like the other page suggests (different folder names don’t matter, but snapcraft at the end does).

$ docker run -v "$PWD":/build -w /build snapcore/snapcraft snapcraft

Another things is that we need more than just snapcraft, see Building the snap on Docker - #2 by ijohnson

I think this should be updated to mention that before running snapcraft from the container, apt update needs to be run, because as it is the snapcore/snapcraft docker image has out of date apt sources and as such snapcraft will fail to install/download packages when using apt because the sources/sites are out of date

What do you folks think?

1 Like