Dockerfile:
FROM python:3.10-slim
WORKDIR /watch
ADD requirements.txt /app/requirements.txt
RUN pip install --no-cache-dir -r /app/requirements.txt
ADD webwatcher /app/webwatcher
VOLUME /watch
ENV IS_DOCKER=true
ENV PYTHONPATH "/app"
ENTRYPOINT python3 -m webwatcher
My __main__.py in the module
import signal
from time import sleep
from .watchdog import register_observer
observer = register_observer()
def finish(signum, frame):
print('\nExiting application...')
observer.stop()
observer.join()
exit(0)
print('Registering signals')
signal.signal(signal.SIGTERM, finish)
signal.signal(signal.SIGINT, finish)
print('Running module')
observer.start()
while True:
sleep(1)
I then build the container
docker build -t webwatcher:latest .
And run
docker run --rm --name web -v path:/watch/path webwatcher:latest
But when I run, it shows no output at all. It also does not let me quit with Ctrl+C from the run command, nor does docker stop work (it times out then kills it).
Why isn't the module being run properly from the container?