From 5cc27ca6b901a4bb06866e67c4775002f292850a Mon Sep 17 00:00:00 2001 From: socrates Date: Tue, 12 Dec 2023 12:36:36 +0100 Subject: [PATCH] changed docker for better persistence --- Dockerfile | 16 +++++++++------- {conf => init}/conf.json | 0 {conf => init}/crontab | 2 +- kill-chrome => kill-chrome.sh | 0 run.sh | 12 ++++++++++++ 5 files changed, 22 insertions(+), 8 deletions(-) rename {conf => init}/conf.json (100%) rename {conf => init}/crontab (64%) rename kill-chrome => kill-chrome.sh (100%) create mode 100644 run.sh diff --git a/Dockerfile b/Dockerfile index 922d610..742d577 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,18 @@ FROM debian:bookworm-slim ENV DEBIAN_FRONTEND=noninteractive -RUN apt update && apt install -y cron tzdata python3-openpyxl python3-selenium python3-pyvirtualdisplay && rm -rf /var/lib/apt/lists/* +RUN apt update && apt install -y vim cron tzdata python3-openpyxl python3-selenium python3-pyvirtualdisplay && rm -rf /var/lib/apt/lists/* RUN cp -r -f /usr/share/zoneinfo/Europe/Berlin /etc/localtime -COPY . /app/ +COPY /parser.py /app/ +COPY /kill-chrome.sh /app/ +COPY /run.sh /app/ +COPY /init /app/init RUN mkdir -p /app/files RUN mkdir -p /app/log +RUN mkdir -p /app/conf +RUN chmod +x /app/run.sh +RUN chmod +x /app/kill-chrome.sh -WORKDIR /app/ - -RUN crontab conf/crontab - -CMD [ "cron", "-f" ] +CMD [ "/app/run.sh" ] diff --git a/conf/conf.json b/init/conf.json similarity index 100% rename from conf/conf.json rename to init/conf.json diff --git a/conf/crontab b/init/crontab similarity index 64% rename from conf/crontab rename to init/crontab index b8ee09c..4d71afe 100644 --- a/conf/crontab +++ b/init/crontab @@ -1,3 +1,3 @@ # m h dom mon dow cmd */5 8-20 * * 1-5 cd /app/ && ./parser.py -0 0 * * * /app/kill-chrome +0 0 * * * /app/kill-chrome.sh diff --git a/kill-chrome b/kill-chrome.sh similarity index 100% rename from kill-chrome rename to kill-chrome.sh diff --git a/run.sh b/run.sh new file mode 100644 index 0000000..96e4636 --- /dev/null +++ b/run.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +if ! test -f "/app/conf/crontab"; then + cp "/app/init/crontab" "/app/conf/crontab" +fi +crontab "/app/conf/crontab" + +if ! test -f "/app/conf/conf.json"; then + cp "/app/init/conf.json" "/app/conf/conf.json" +fi + +cron -f \ No newline at end of file