I would like to run an initiator script and a cron job to run an updater script, both are in a Docker container that has a connection to the mongo database. Could someone help me how to run the cron job in the background inside the docker-entrypoint.sh file?
My docker-entrypoint.sh looks like this:
#!/usr/bin/env bash
set -m
cron & (
source /venv/bin/activate
python3 /code/FBInitializer.py
)
My Dockerfile looks like this:
FROM python:3.8.6-slim
RUN apt-get update && apt-get -y install python3 cron vim
RUN pip3 install --upgrade pip
COPY . /code
WORKDIR /code
COPY requirements.txt .
RUN python3 -m venv /venv
RUN . /venv/bin/activate && pip3 install -r requirements.txt
ADD crontab /etc/cron.d/
ADD FBInitializer.py /code
ADD FBUpdater.py /code
# Create the log file to be able to run tail
RUN touch /var/log/cron.log
RUN chmod 0644 crontab
# RUN chmod 777 ./venv/lib/python3.8/site-packages
# RUN chmod 755 ./venv/bin/activate
#RUN crontab crontab
#CMD ["cron"]
COPY /docker-entrypoint.sh /docker-entrypoint.sh
RUN ["chmod", "+x", "/docker-entrypoint.sh"]
ENTRYPOINT ["/docker-entrypoint.sh"]
EXPOSE 6000
COPY . .
The initiator script runs, but the container stops working with the following error:
exited with code 0
Any idea?