Skip to content

Instantly share code, notes, and snippets.

@jee-r
Last active January 24, 2024 08:58

Revisions

  1. jee-r revised this gist Jan 24, 2024. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion Dockerfile
    Original file line number Diff line number Diff line change
    @@ -11,4 +11,6 @@ RUN apk update ; \
    inotify-tools ; \
    rm -rf /tmp/* /var/cache/apk/*

    COPY ./entrypoint /usr/local/bin/entrypoint
    COPY ./entrypoint /usr/local/bin/entrypoint

    CMD ["/usr/local/bin/entrypoint"]
  2. jee-r created this gist Jan 24, 2024.
    14 changes: 14 additions & 0 deletions Dockerfile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    FROM alpine:3.19

    ENV WATCH_DIR \
    BETANIN_API_KEY \
    BETANIN_API_URL

    RUN apk update ; \
    apk upgrade ; \
    apk add --no-cache \
    curl \
    inotify-tools ; \
    rm -rf /tmp/* /var/cache/apk/*

    COPY ./entrypoint /usr/local/bin/entrypoint
    35 changes: 35 additions & 0 deletions docker-compose.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    version: '3'

    services:
    betanin:
    image: ghcr.io/jee-r/beets:main
    container_name: betanin
    hostname: betanin
    user: 1000:1000
    ports:
    - 4030:4030
    environment:
    - MODE=betanin
    - BETANIN_HOST=0.0.0.0
    - BETANIN_PORT=4030
    - UMASK_SET=022
    - TZ=Europe/Paris
    volumes:
    - ./betanin/config/:/config
    - /torrents:/torrents
    - /Media/Music:/Media/Music

    watcher:
    container_name: beet_watcher
    image: ghcr.io/jee-r/watcher:main
    build: ./
    user: 1000:1000
    environment:
    - UMASK_SET=022
    - TZ=Europe/Paris
    - BETANIN_API_KEY=REDACTED
    - BETANIN_API_URL=http://betanin:4030/api/torrents
    - WATCH_DIR=/Media/Music/Unsorted/
    volumes:
    - /Media/Music:/Media/Music

    7 changes: 7 additions & 0 deletions entrypoint
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    #!/bin/sh

    inotifywait -m -e create,moved_to --format '%w%f' "$WATCH_DIR" | while IFS= read -r dir_path; do
    sleep 20s
    response=$(curl --silent --output /dev/null --request POST --data-urlencode "both=$dir_path" --header "Accept: application/json" --header "X-API-Key: $BETANIN_API_KEY" "$BETANIN_API_URL")
    echo $response
    done