Skip to content

Commit

Permalink
Improve docker image.
Browse files Browse the repository at this point in the history
  • Loading branch information
tschaefer committed Dec 18, 2023
1 parent 6b6f3d0 commit 5e8b5d2
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 36 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/docker-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ jobs:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
REFERENCE: ${{ github.ref == 'refs/heads/main' && 'latest' || 'github.ref_name' }}
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:develop
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.REFERENCE }}
9 changes: 3 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
FROM docker.io/bitnami/minideb:latest
LABEL org.opencontainers.image.source="https://github.com/tschaefer/beets-store"

RUN install_packages nginx pipx redis-server curl
RUN install_packages pipx curl
COPY rootfs /

RUN bash -c ' \
PIPX_HOME=/opt/beets/.local/pipx \
PIPX_BIN_DIR=$PIPX_HOME/bin \
pipx install --include-deps https://github.com/tschaefer/beets-store/archive/refs/heads/develop.zip \
'
RUN ln -s /etc/nginx/sites-available/beets-store /etc/nginx/sites-enabled/beets-store
RUN rm /etc/nginx/sites-enabled/default

VOLUME ["/opt/beets/media/music", "/opt/beets/config"]
EXPOSE 80
VOLUME ["/opt/beets/media/music"]
EXPOSE 3000

USER root
WORKDIR /opt/beets
Expand Down
5 changes: 5 additions & 0 deletions docker-compose.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# shellcheck disable=SC2034
BEETS_BIND_IP=0.0.0.0
BEETS_BIND_PORT=3000
BEETS_REDIS_URL=redis://beets_redis:6378
BEETS_MUSIC_VOLUME=/music
23 changes: 23 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
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
depends_on:
- beets_redis
ports:
- 3000:3000
healthcheck:
test: ["CMD", "curl", "-fs", "-S", "--max-time", "2", "http://${BEETS_BIND_IP}:${BEETS_BIND_PORT}"]
interval: 30s
timeout: 10s
retries: 5
volumes:
- ${BEETS_MUSIC_VOLUME}:/opt/beets/media/music
restart: unless-stopped
25 changes: 0 additions & 25 deletions rootfs/etc/nginx/sites-available/beets-store

This file was deleted.

13 changes: 13 additions & 0 deletions rootfs/opt/beets/config/beets.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
directory: /opt/beets/media
library: /opt/beets/db/beets.db
import:
write: no
copy: no
move: no
resume: no
autotag: no
plugins: store fetchart
fetchart:
auto: no
store:
zipdir: /opt/beets/media/store
8 changes: 4 additions & 4 deletions rootfs/opt/beets/entrypoint
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ if [[ ! -f $BEETS_CONFIG ]]; then
exit 1
fi

redis-server --daemonize yes
nginx
BEETS_REDIS_URL=${BEETS_REDIS_URL:=redis://beets_redis:6379}
export BEETS_REDIS_URL

rq worker &
rq worker --url $BEETS_REDIS_URL &
if [[ -f /opt/beets/beets.db ]]; then
beet --config $BEETS_CONFIG update
else
beet --config $BEETS_CONFIG import /opt/beets/media/music
fi
beet --config $BEETS_CONFIG fetchart
beet --config $BEETS_CONFIG store --wsgi
beet --config $BEETS_CONFIG store --wsgi ${BEETS_BIND_IP:=0.0.0.0} ${BEETS_BIND_PORT:=3000}

0 comments on commit 5e8b5d2

Please sign in to comment.