Skip to content

Commit

Permalink
Switch to using D3Zyre/Elodie fork and include `inotifywait-polling…
Browse files Browse the repository at this point in the history
…` option.
  • Loading branch information
Robert Ross committed Jan 22, 2024
1 parent 7fae8a6 commit 52cb227
Show file tree
Hide file tree
Showing 5 changed files with 286 additions and 32 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -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@v4
- 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
52 changes: 28 additions & 24 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,50 +1,54 @@
FROM python:3-alpine AS builder
FROM python:3.9-alpine AS builder
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

#Using internal modified copy of file for now
#RUN git clone https://github.com/javanile/inotifywait-polling.git /inotifywait-polling && \
# chmod +x /inotifywait-polling/inotifywait-polling.sh

FROM python:3-alpine
FROM python:3.9-alpine
LABEL maintainer="[email protected]"
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 findutils && \
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
COPY --chown=root:root --chmod=0777 inotifywait-polling.sh /usr/local/bin/inotifywait-polling

ENV PUID=1000
ENV PGID=1000
ENV SOURCE=/source
ENV DESTINATION=/destination
ENV ELODIE_APPLICATION_DIRECTORY=/elodie
ENV DEFAULT_COMMAND=watch
ENV ELODIE_APPLICATION_DIRECTORY=~/.elodie
ENV ELODIE_DEFAULT_COMMAND=watch

ENTRYPOINT ["/entrypoint.sh"]
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)

<p align="center"><img src ="https://raw.githubusercontent.com/jmathai/elodie/master/creative/[email protected]" /></p>
<p align="center"><img src ="https://raw.githubusercontent.com/D3Zyre/elodie/master/creative/[email protected]" /></p>


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

Expand All @@ -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

Expand All @@ -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

Expand All @@ -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)
```
```
7 changes: 6 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ set -eu

PYTHON="su-exec ${PUID}:${PGID} python"
ELODIE="${PYTHON} /elodie/elodie.py"
INOTIFY_BIN="inotifywait"

IMPORT_OPTIONS="--destination ${DESTINATION}"

Expand All @@ -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());")
Expand Down
Loading

0 comments on commit 52cb227

Please sign in to comment.