Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,27 @@ RUN npm install && \
FROM alpine:3.18 AS builder-mp3gain
WORKDIR /tmp
COPY alpine/mp3gain/APKBUILD .
RUN apk update && \
RUN mkdir -p /tmp/out && \
apk update && \
apk add --no-cache abuild && \
abuild-keygen -a -n && \
cp /root/.abuild/*.rsa.pub /etc/apk/keys/ && \
REPODEST=/tmp/out abuild -F -r


FROM alpine:3.18 AS builder-mp3val
WORKDIR /tmp
COPY alpine/mp3val/APKBUILD .
RUN apk update && \
RUN mkdir -p /tmp/out && \
apk update && \
apk add --no-cache abuild && \
abuild-keygen -a -n && \
cp /root/.abuild/*.rsa.pub /etc/apk/keys/ && \
REPODEST=/tmp/out abuild -F -r


FROM alpine:3.18
LABEL org.opencontainers.image.source https://github.com/sentriz/betanin
LABEL org.opencontainers.image.source=https://github.com/sentriz/betanin
WORKDIR /src
COPY . .
COPY --from=builder-frontend /src/dist/ /src/betanin_client/dist/
Expand All @@ -35,7 +39,7 @@ ENV UID=1000
ENV GID=1000

RUN apk add --no-cache --upgrade --virtual=build-dependencies build-base cmake libffi-dev openssl-dev python3-dev jpeg-dev libpng-dev zlib-dev jpeg-dev cargo llvm14-dev openblas openblas-dev && \
apk add --no-cache --upgrade sudo python3 py-pip libev chromaprint ffmpeg gstreamer flac keyfinder-cli libsndfile && \
apk add --no-cache --upgrade python3 py-pip libev chromaprint ffmpeg gstreamer flac keyfinder-cli libsndfile && \
apk add --no-cache --allow-untrusted /pkgs/* && \
env LLVM_CONFIG="$(which llvm14-config)" pip install --no-cache-dir . --requirement requirements-docker.txt && \
apk del --purge build-dependencies && \
Expand All @@ -48,5 +52,7 @@ VOLUME /b/.config/beets/
ENV HOME=/b
ENV PYTHONUNBUFFERED=1
ENV PYTHONWARNINGS="ignore:Unverified HTTPS request"
ENV PIP_EXTRA_PACKAGES=''
ENV EXTRA_COMMAND=''

ENTRYPOINT [ "/src/docker-entry" ]
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ betanin:
environment:
- UID=1000 # (optionally) set user id
- GID=1000 # (optionally) set group id
- PIP_EXTRA_PACKAGES=beetstream # (optional) comma separated values of additional plugins to install
- EXTRA_COMMANDS="beet beetstream &" # (optional) extra commands to run at start (note the `&` at the end to run it in the background)
volumes:
- ${DATA}/betanin/data:/b/.local/share/betanin/
- ${DATA}/betanin/config:/b/.config/betanin/
Expand Down
40 changes: 36 additions & 4 deletions docker-entry
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,40 @@ echo "!! https://github.com/sentriz/betanin"
echo "!!"
echo "!! thanks!"

[ "$UID" -eq 0 ] && exec betanin
if [ "$(id -u)" -eq 0 ]; then
# Running as root: install additional plugins
if [ -n "$PIP_EXTRA_PACKAGES" ]; then
echo "Installing additional pip packages: $PIP_EXTRA_PACKAGES"
pip install $(echo "$PIP_EXTRA_PACKAGES" | tr ',' ' ')
echo "Finished installing additional pip packages."
fi

adduser -D -h "$HOME" -u "$UID" -g "$GID" betanin 2>/dev/null
chown -R betanin:betanin "$HOME"
exec sudo -u betanin -g betanin betanin
# and drop to an unpriviledged user
CURRENT_UID=${UID:-1000}
CURRENT_GID=${GID:-1000}

adduser -D -h "$HOME" -u "$UID" -g "$GID" betanin 2>/dev/null
chown -R betanin:betanin "$HOME"
echo "Switching to betanin user (UID: $CURRENT_UID, GID: $CURRENT_GID)"
exec su betanin -c "/bin/sh -c '$0'"
else
# Not running as root: warn about unsupported features
echo " "
echo " "
echo "/!\ WARNING: Running this container using docker's `user` feature comes with some caveats:"
echo "- You need to have the proper volumes mounted, with the right permissions"
echo "- You won't be able to use additional plugins (they need to be installed by root for beets to see them)"
echo " "
echo " "
fi

if [ -n "$EXTRA_COMMANDS" ]; then
echo "Launching extra commands: $EXTRA_COMMANDS"
echo "$EXTRA_COMMANDS" | awk -v RS=',' '{print}' | while read -r cmd; do
if [ -n "$cmd" ]; then
sh -c "$cmd"
fi
done
fi

exec betanin
2 changes: 1 addition & 1 deletion requirements-docker.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ pillow
unidecode
jsonpath-rw
pyyaml
beets-bpmanalyser @ https://github.com/adamjakab/BeetsPluginBpmAnalyser/archive/devel.zip
beets-bpmanalyser @ https://github.com/adamjakab/BeetsPluginBpmAnalyser/archive/refs/heads/master.zip