diff --git a/Dockerfile b/Dockerfile index d938e86..5c1eead 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ FROM docker.io/bitnami/minideb:latest LABEL org.opencontainers.image.source="https://github.com/tschaefer/beets-store" -RUN install_packages pipx curl +RUN install_packages pipx curl dumb-init COPY rootfs / ARG BUILD_BRANCH=main @@ -18,4 +18,5 @@ EXPOSE 3000 USER root WORKDIR /opt/beets -ENTRYPOINT ["/opt/beets/entrypoint"] +ENTRYPOINT ["/usr/bin/dumb-init", "--"] +CMD ["bash", "-c", "/opt/beets/bin/beets-setup && exec /opt/beets/bin/beets-start"] diff --git a/docker-compose.env b/docker-compose.env index 30e7721..35dc97e 100644 --- a/docker-compose.env +++ b/docker-compose.env @@ -1,6 +1,7 @@ # shellcheck disable=SC2034 BEETS_BIND_IP="0.0.0.0" BEETS_BIND_PORT="3000" -BEETS_REDIS_URL="redis://beets_redis:6378" +BEETS_REDIS_URL="redis://beets_redis:6379" BEETS_MUSIC_VOLUME="/usr/share/music" #BEETS_VOLUME="/var/lib/beets" +#BEETS_FORCE_IMPORT="true" diff --git a/docker-compose.yml b/docker-compose.yml index a914d1c..0689c1b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,25 +1,31 @@ -version: "3.8" - +--- +version: '3.8' services: beets_redis: container_name: beets_redis image: docker.io/library/redis:7 restart: unless-stopped - beets_store: container_name: beets_store - image: ghcr.io/tschaefer/beets-store:develop + image: ghcr.io/tschaefer/beets-store:latest depends_on: - - beets_redis + - beets_redis ports: - - 3000:3000 + - 3000:3000 healthcheck: - test: ["CMD", "curl", "-fs", "-S", "--max-time", "2", "http://${BEETS_BIND_IP}:${BEETS_BIND_PORT}"] + test: + - CMD + - curl + - "-fs" + - "-S" + - "--max-time" + - '2' + - http://${BEETS_BIND_IP}:${BEETS_BIND_PORT} interval: 30s timeout: 10s retries: 5 volumes: - # - ${BEETS_VOLUME}/config/beets.yml:/opt/beets/config/beets.yml - # - ${BEETS_VOLUME}/db:/opt/beets/db - - ${BEETS_MUSIC_VOLUME}:/opt/beets/media/music + - "${BEETS_MUSIC_VOLUME}:/opt/beets/media/music" + # - ${BEETS_VOLUME}/config/beets.yml:/opt/beets/config/beets.yml + # - ${BEETS_VOLUME}/db:/opt/beets/db restart: unless-stopped diff --git a/rootfs/opt/beets/entrypoint b/rootfs/opt/beets/bin/beets-setup similarity index 88% rename from rootfs/opt/beets/entrypoint rename to rootfs/opt/beets/bin/beets-setup index 48710e3..e1cab75 100755 --- a/rootfs/opt/beets/entrypoint +++ b/rootfs/opt/beets/bin/beets-setup @@ -15,9 +15,6 @@ if [[ ! -f $BEETS_CONFIG ]]; then exit 1 fi -BEETS_REDIS_URL=${BEETS_REDIS_URL:=redis://beets_redis:6379} -export BEETS_REDIS_URL - if [[ $BEETS_FORCE_IMPORT == "true" ]]; then echo "Forcing import ..." rm -f $BEETS_DB @@ -61,7 +58,3 @@ fi echo "Fetching album art ..." beet --config $BEETS_CONFIG fetchart echo "done." - -echo "Starting beets ..." -rq worker --url $BEETS_REDIS_URL & -beet --config $BEETS_CONFIG store --wsgi ${BEETS_BIND_IP:=0.0.0.0} ${BEETS_BIND_PORT:=3000} diff --git a/rootfs/opt/beets/bin/beets-start b/rootfs/opt/beets/bin/beets-start new file mode 100755 index 0000000..dc2b892 --- /dev/null +++ b/rootfs/opt/beets/bin/beets-start @@ -0,0 +1,18 @@ +#!/bin/bash + +# set -x + +PATH=/opt/beets/.local/pipx/bin:$PATH +BEETS_CONFIG=/opt/beets/config/beets.yml + +if [[ ! -f $BEETS_CONFIG ]]; then + echo "No config file found. Shutting down." >&2 + exit 1 +fi + +BEETS_REDIS_URL=${BEETS_REDIS_URL:=redis://beets_redis:6379} +export BEETS_REDIS_URL + +echo "Starting beets ..." +rq worker --url $BEETS_REDIS_URL & +beet --config $BEETS_CONFIG store --wsgi ${BEETS_BIND_IP:=0.0.0.0} ${BEETS_BIND_PORT:=3000}