Skip to content

Commit

Permalink
Add Dockerfile for mp3fs image
Browse files Browse the repository at this point in the history
This also includes a Docker Compose configuration file and a README
explaining how to use Docker with mp3fs.
  • Loading branch information
khenriks committed May 23, 2020
1 parent deb2f2d commit de9fb35
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ staticcheck:
# and the check is made automatically passing because the headers aren't
# preserved properly.
mdcheck:
@set -e ; for f in *.md ; do \
@set -e ; for f in *.md */*.md ; do \
echo "Checking format for $$f." ; \
if [ "$$f" = mp3fs.1.md ] ; then \
sed 's/\.\\/!./g' "$$f" | pandoc -d .pandocfmt.yaml -f markdown -t markdown | sed 's/!\./.\\/g' | diff -u $$f - || : ; \
Expand Down
33 changes: 33 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
FROM debian:buster-slim AS base

FROM base AS build

RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
ca-certificates \
curl \
libflac++-dev \
libfuse-dev \
libid3tag0-dev \
libmp3lame-dev \
&& rm -rf /var/lib/apt/lists/*

RUN curl -sL https://github.com/khenriks/mp3fs/releases/download/v0.91/mp3fs-0.91.tar.gz | \
tar -xz && \
cd mp3fs-0.91 && \
./configure && make && make install

FROM base

RUN apt-get update && apt-get install -y --no-install-recommends \
fuse \
libflac++6v5 \
libid3tag0 \
libmp3lame0 \
&& rm -rf /var/lib/apt/lists/*

COPY --from=build /usr/local /usr/local

RUN mkdir /music

ENTRYPOINT ["mp3fs", "-d", "/music", "/mnt", "-oallow_other"]
55 changes: 55 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Docker Instructions

There is now a [Docker
image](https://hub.docker.com/repository/docker/khenriks/mp3fs) available for
mp3fs. Most users will probably prefer to use the command normally, but it's
available for those who want it.

## docker run

To use this with the `docker run` command, run:

``` console
$ docker run --device /dev/fuse \
--cap-add SYS_ADMIN \
--security-opt apparmor:unconfined \
-v /home/khenriks/Music:/music:ro \
-v /tmp/mp3:/mnt:shared \
khenriks/mp3fs \
-b 256
```

There's a lot here, so let's unpack the command.

- `docker run` is how you run a docker container.
- `--device /dev/fuse` is needed to allow FUSE access.
- `--cap-add SYS_ADMIN` is necessary to mount filesystems inside Docker
containers. This might not be needed in the future for FUSE (see
[docker/for-linux\#321](https://github.com/docker/for-linux/issues/321)),
but for now it's required.
- `--security-opt apparmor:unconfined` is also needed to mount filesystems
inside Docker.
- `-v /home/khenriks/Music:/music:ro` mounts the host directory
`/home/khenriks/Music` read-only in the container. This will be the input
for mp3fs. The host directory can be replaced with anything, but `/music`
is required because that's where the container expects it.
- `-v /tmp/mp3:/mnt:shared` mounts the directory `/tmp/mp3` inside the
container. This will be the output from mp3fs. Again, the host directory
can be anything, but `/mnt` is required by the container. `shared` makes
the mp3fs mount inside the container show up in the host directory outside.
- `khenriks/mp3fs` is the name of the Docker image.
- `-b 256` is the normal mp3fs flag for bitrate. You can use any mp3fs flags
here, after the image name.

## Docker Compose

There's also a `docker-compose.yml` file available, if that's your jam. To use
it, run:

``` console
$ MUSICDIR=/home/khenriks/Music MP3DIR=/tmp/mp3 MP3FS_FLAGS="-b 256" \
docker-compose up
```

This will do the same thing as the previous command, but is hopefully simpler
to use. `MUSICDIR`, `MP3DIR`, and `MP3FS_FLAGS` can be customized as desired.
15 changes: 15 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Basic Docker Compose file for mp3fs
version: '3'
services:
mp3fs:
image: khenriks/mp3fs
devices:
- /dev/fuse
cap_add:
- SYS_ADMIN
security_opt:
- apparmor:unconfined
volumes:
- ${MUSICDIR}:/music:ro
- ${MP3DIR}:/mnt:shared
command: ${MP3FS_FLAGS}

0 comments on commit de9fb35

Please sign in to comment.