Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minimal container based on Alpine Linux #156

Open
odiroot opened this issue Dec 31, 2024 · 10 comments
Open

Minimal container based on Alpine Linux #156

odiroot opened this issue Dec 31, 2024 · 10 comments

Comments

@odiroot
Copy link

odiroot commented Dec 31, 2024

You might find it useful, if not please just close this issue.

I managed to build a very lightweight container starting with an Alpine Linux 3.20 base.
The result

REPOSITORY                                     TAG                 IMAGE ID      CREATED             SIZE
docker.io/odiroot/go-librespot                 0.1.3               e2413272e241  58 seconds ago      38.7 MB

See it published here.

Here's the Dockerfile I used

FROM alpine:3.20 AS build

RUN apk -U --no-cache add \
    git go alsa-lib-dev libogg-dev libvorbis-dev

RUN git clone https://github.com/devgianlu/go-librespot.git

RUN cd go-librespot \
    && go build -v ./cmd/daemon


#####

FROM alpine:3.20

RUN apk -U --no-cache add \
    libpulse avahi libgcc gcompat alsa-lib

COPY --from=build go-librespot/daemon /usr/bin/go-librespot

CMD ["/usr/bin/go-librespot", "--config_dir", "/config"]
@praul
Copy link

praul commented Jan 1, 2025

Tested it and its working great for me. Thanks, this is more elegant than my own dockerfile.

@devgianlu
Copy link
Owner

Have you used any particular flag to run the container? It is not able to talk to ALSA on my setup.

@odiroot
Copy link
Author

odiroot commented Jan 1, 2025

Have you used any particular flag to run the container? It is not able to talk to ALSA on my setup.

My bad, only tested with pulse (well, pipewire).
I could look into the alsa problem.

@odiroot
Copy link
Author

odiroot commented Jan 1, 2025

I also forgot to mention how I run this one.

Minimal compose file would be

services:
  go_librespot
    image: docker.io/odiroot/go-librespot:latest
    network_mode: host
    volumes:
      - "./vol_config:/config"
      - "/home/<your username>/.config/pulse/cookie:/pulse_cookie:ro"
      - "/run/user/<your uid>/pulse/native:/pulse_native"
    environment:
      PULSE_SERVER: "unix:/pulse_native"
      PULSE_COOKIE: "/pulse_cookie"
    userns_mode: keep-id

Naturally <your username> has to be replaced with e.g. whoami and <your uid> with id -u.

Now for running with ALSA I believe this should work:

services:
  go_librespot:
    image: docker.io/odiroot/go-librespot:latest
    network_mode: host
    volumes:
      - "./vol_config:/config"
      - "/usr/share/alsa:/usr/share/alsa:ro"
    devices:
      - "/dev/snd:/dev/snd"
    userns_mode: keep-id

@devgianlu
Copy link
Owner

Can confirm that the PulseAudio setup works, I was not able to get ALSA to work, but nontheless I'll add this to the repo and make official docker images!

@odiroot
Copy link
Author

odiroot commented Jan 1, 2025

Can confirm that the PulseAudio setup works, I was not able to get ALSA to work, but nontheless I'll add this to the repo and make official docker images!

Sorry about the ALSA thing. I also couldn't get it to work but for a completely unrelated reason (config being ignored).
I might need to look into the build step. Could be that not all required libraries are provided.

devgianlu added a commit that referenced this issue Jan 1, 2025
@devgianlu
Copy link
Owner

Could be that not all required libraries are provided.

Build fines for me and on the CI too: https://github.com/devgianlu/go-librespot/actions/runs/12573825057/job/35047226348

I'll leave this open if you think there are possible improvements, feel free to make a PR too!

@odiroot
Copy link
Author

odiroot commented Jan 1, 2025

Hey @devgianlu
Just one small nitpick. You link to your other project's containers in Readme: https://github.com/devgianlu/go-librespot?tab=readme-ov-file#using-docker

@devgianlu
Copy link
Owner

Hey @devgianlu Just one small nitpick. You link to your other project's containers in Readme: https://github.com/devgianlu/go-librespot?tab=readme-ov-file#using-docker

Oops, copy pasted too much, thanks for noticing :^)

@praul
Copy link

praul commented Jan 2, 2025

Have you used any particular flag to run the container? It is not able to talk to ALSA on my setup.

My bad, sorry - I only used it with pipe output which should be the most easy scenario for a docker setup

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants