From 2884cc263c03c46ca7ba7ed94aa5fc5ffba50301 Mon Sep 17 00:00:00 2001 From: Robert Ross Date: Sun, 21 Jan 2024 14:49:42 -0500 Subject: [PATCH] Switch to using `D3Zyre/Elodie` fork and include `inotifywait-polling` option. --- .github/workflows/publish.yml | 26 +++++++++++++++++++++++ Dockerfile | 40 +++++++++++++++++++---------------- README.md | 15 +++++++------ entrypoint.sh | 7 +++++- 4 files changed, 62 insertions(+), 26 deletions(-) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..2927876 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,26 @@ +name: Docker Image CI + +on: + push: + branches: + - master + - main + pull_request: + branches: + - master + - main + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Docker Login + env: + DOCKER_USER: ${{secrets.DOCKER_USER}} + DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}} + run: docker login -u $DOCKER_USER -p $DOCKER_PASSWORD + - name: Docker Build + run: docker build . --file Dockerfile --tag ${{secrets.DOCKER_USER}}/elodie:$(date +%s) --tag ${{secrets.DOCKER_USER}}/elodie:latest + - name: Docker Publish + run: docker push --all-tags ${{secrets.DOCKER_USER}}/elodie \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index df8f050..b90c73e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,24 +3,27 @@ ENV PYTHONUNBUFFERED 1 # Install runtime dependencies RUN apk --update upgrade && \ - apk add --update inotify-tools exiftool zlib jpeg lcms2 tiff openjpeg su-exec && \ - rm -rf /var/cache/apk/* - + apk add --update inotify-tools exiftool zlib jpeg lcms2 tiff openjpeg su-exec && \ + rm -rf /var/cache/apk/* + # Install build dependencies RUN apk --update upgrade && \ - apk add --update git \ - build-base \ - jpeg-dev \ - zlib-dev \ - lcms2-dev \ - openjpeg-dev \ - tiff-dev && \ - rm -rf /var/cache/apk/* + apk add --update git \ + build-base \ + jpeg-dev \ + zlib-dev \ + lcms2-dev \ + openjpeg-dev \ + tiff-dev && \ + rm -rf /var/cache/apk/* WORKDIR /wheels -RUN git clone https://github.com/jmathai/elodie.git /elodie && \ - pip wheel --no-cache-dir -r /elodie/requirements.txt && \ - rm -rf /elodie/.git +RUN git clone https://github.com/D3Zyre/Elodie.git /elodie && \ + pip wheel --no-cache-dir -r /elodie/requirements.txt && \ + rm -rf /elodie/.git + +RUN git clone https://github.com/javanile/inotifywait-polling.git /inotifywait-polling && \ + chmod +x /inotifywait-polling/inotifywait-polling.sh FROM python:3-alpine LABEL maintainer="pierre@buyle.org" @@ -28,16 +31,17 @@ ENV PYTHONUNBUFFERED 1 # Install runtime dependencies RUN apk --update upgrade && \ - apk add --update inotify-tools exiftool zlib jpeg lcms2 tiff openjpeg su-exec && \ - rm -rf /var/cache/apk/* + apk add --update inotify-tools exiftool zlib jpeg lcms2 tiff openjpeg su-exec bash && \ + rm -rf /var/cache/apk/* COPY --from=builder /wheels /wheels COPY --from=builder /elodie /elodie +COPY --from=builder /inotifywait-polling/inotifywait-polling.sh /usr/local/bin/inotifywait-polling WORKDIR /elodie RUN pip install --no-cache-dir -r requirements.txt -f /wheels && \ - rm -rf /wheels - + rm -rf /wheels + COPY entrypoint.sh /entrypoint.sh ENV PUID=1000 diff --git a/README.md b/README.md index 6d7a216..71c9a2f 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,10 @@ # elodie-docker -Docker container for [Elodie](https://github.com/jmathai/elodie) +Docker container for a more recently updated fork of [Elodie](https://github.com/D3Zyre/Elodie.git) -

+

- -The container default command is to watch a source folder using `inotifywait` and automatically execute `elodie` to import added images to a destination folder. +The container default command is to watch a source folder using `inotifywait` or [`inotifywait-polling`](https://github.com/javanile/inotifywait-polling) and automatically execute `elodie` to import added images to a destination folder. ## Usage @@ -32,10 +31,11 @@ docker run \ | DESTINATION | /destination | Copy imported files into this directory | TRASH | | Set to move files to this trash folder after copying files | EXCLUDE | | Regular expression for directories or files to exclude -| ALLOW_DUPLICATE | | Set to import the files even if theu have already been imported +| ALLOW_DUPLICATE | | Set to import the files even if theu have already been imported | ALBUM_FROM_FOLDER | | Set to use images' folders as their album names | MAPQUEST_KEY | | Mapquest API key for geo-code location from EXIF's GPS fields | DEBUG | | Set to enable debug messages +| INOTIFYWAIT_POLLING | | Set to enable use of inotifywait polling. Useful for CIFS/SMB/NFS mounts. ### Advanced configurtion @@ -53,7 +53,7 @@ docker run \ pbuyle/elodie ``` -Note: If a custom configuartion file is used then setting the `MAPQUEST_KEY` environment variable will have not effect. +Note: If a custom configuration file is used then setting the `MAPQUEST_KEY` environment variable will have not effect. ### User / Group Identifiers @@ -62,7 +62,8 @@ When using volumes (-v flags) permissions issues can arise between the host OS a Ensure any volume directories on the host are owned by the same user you specify and any permissions issues will vanish like magic. In this instance PUID=1000 and PGID=1000, to find yours use id user as below: + ``` $ id username uid=1000(dockeruser) gid=1000(dockergroup) groups=1000(dockergroup) -``` \ No newline at end of file +``` diff --git a/entrypoint.sh b/entrypoint.sh index b6e3738..1d1a65d 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -4,6 +4,7 @@ set -eu PYTHON="su-exec ${PUID}:${PGID} python" ELODIE="${PYTHON} /elodie/elodie.py" +INOTIFY_BIN="inotifywait" IMPORT_OPTIONS="--destination ${DESTINATION}" @@ -29,13 +30,17 @@ if [ "${DEBUG:-}" ]; then IMPORT_OPTIONS="${IMPORT_OPTIONS} --debug" fi +if [ "${INOTIFYWAIT_POLLING:-}" ]; then + INOTIFY_BIN="inotifywait-polling" +fi + if [ ! -e "${ELODIE_APPLICATION_DIRECTORY}/config.ini" ] && [ "${MAPQUEST_KEY:-}" ] ; then echo -e "[MapQuest]\nkey=${MAPQUEST_KEY}\nprefer_english_names=False" > "${ELODIE_APPLICATION_DIRECTORY}/config.ini" fi case "${1:-watch}" in watch) - inotifywait -e close_write -mr "${SOURCE}" | while read -r EV; + ${INOTIFY_BIN} -e close_write -mr "${SOURCE}" | while read -r EV; do ( NOW=$($PYTHON -c "import time;print(time.time());")