goreleaser / goreleaser-cross

Docker image for Golang cross-compiling with CGO
MIT License
146 stars 24 forks source link

How to Build Snaps? #59

Closed JonathanHope closed 9 months ago

JonathanHope commented 10 months ago

When I try and build a snap with this image I get the following error:

error=snapcraft not present in $PATH

I looked into installing snapcraft and found the following instructions:

sudo apt update
sudo apt install snapd
sudo snap install core

I tried to add this to a Dockerfile:

FROM goreleaser/goreleaser-cross:v1.21

RUN apt-get update \
 && apt-get install --no-install-recommends -y -q \
    snapd
RUN snap install core
RUN snap install snapcraft --classic

But that fails with:

error: cannot communicate with server: Post "http://localhost/v2/snaps/core": dial unix /run/snapd.socket: connect: no such file or directory

Any ideas on how build snaps with this Docker image?

caarlos0 commented 10 months ago

unfortunately, afaik, snapd (or snapcraft, dont really remember) don't work inside docker containers... we may need to document this.

JonathanHope commented 9 months ago

No worries. I was able to figure out a workaround by building with Zig on MacOS agents and then using the Snapcraft Docker images to build the snap. Thanks for getting back to me!