The shell script working on a cron, with all the packages I now have installed on the system, and with some distributed configuration items… I made a Docker Image with the little stuff I have.
FROM ubuntu:latest
RUN apt-get update \
&& apt-get install -y ocrmypdf \
&& apt-get install tesseract-ocr-deu \
&& apt-get install -y imagemagick \
&& apt-get install -y cron
RUN groupadd -g 1001 scanner \
&& useradd -rm -d /home/scanner -s /bin/bash -g 1001 -u 1001 scanner
WORKDIR /home/scanner
COPY --chown=scanner:scanner . .
VOLUME /home/scanner/archive
VOLUME /home/scanner/scanner
RUN crontab -l | { cat; echo "* * * * * timeout 1h flock -n /home/scanner/apps/lock/translateNewFiles.lock su scanner -c /home/scanner/apps/scripts/translateNewFiles.sh"; } | crontab -
CMD ["cron", "-f"]
Behold, the Dockerfile. It would have worked out of the box, but… there is of course on thing in there that is not okay, the user management. I want to really have a “scanner” user on the system which writes all the files of our project. After a lot of failed attempts, the cron is running as root in the container and the translateNewfiles.sh is executed with the scanner user, where at the moment the user is hardcoded in uid and gid matching the outside user. I should change that.
The data store is on the outside, just directories mounted in.
version: "3.3"
services:
dochauser:
build: .
volumes:
- /home/scanner/dochauser_mount/archive:/home/scanner/archive
- /home/scanner/dochauser_mount/scanner:/home/scanner/scanner
Which means the docker-compose.yml looks like this and is quite simple for my tests.
This will not be the nicest Docker Image ever created, but it works for me for the moment.
Oh shit, why do I get an access denied error trying to stop my own container?
– All Ubuntu Server LTS users ever?
i don’t know if this is common, but I had to remove docker-compose and docker and snap and apparmor and install everything freshly via apt-get. Now the system feels stable. But I had a bit of hate for this basic workflow not to go properly for me in Ubuntu Linux.