Skip to content

Commit

Permalink
Maintenance: Docker improvements.
Browse files Browse the repository at this point in the history
* Use container init system 'dumb-init'.
* Fix and enhance docker-compose and environment.
  • Loading branch information
tschaefer committed Mar 15, 2024
1 parent 08a85c1 commit ef7e145
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 20 deletions.
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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"]
3 changes: 2 additions & 1 deletion docker-compose.env
Original file line number Diff line number Diff line change
@@ -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"
26 changes: 16 additions & 10 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}
18 changes: 18 additions & 0 deletions rootfs/opt/beets/bin/beets-start
Original file line number Diff line number Diff line change
@@ -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}

0 comments on commit ef7e145

Please sign in to comment.