From 080e73c1db8a040347c2bc09e14588c2e3d811c9 Mon Sep 17 00:00:00 2001 From: "Kasper D. Fischer" Date: Fri, 21 Mar 2025 14:22:59 +0100 Subject: [PATCH] [update] update Dockerfile - mojor update of Dockerfile - reverted location of simulate_fail.json file for simulating errors, e.g. to test sending e-mails --- Dockerfile | 35 +++++++++++++++++++++++++++++++---- survBot.py | 2 +- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 14aa895..4c5b95e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,38 @@ FROM python:3 -WORKDIR /usr/src/app +# metadata +LABEL maintainer="Kasper D. Fischer " +LABEL version="0.2-docker" +LABEL description="Docker image for the survBot application" -COPY requirements.txt ./ -RUN pip install --no-cache-dir -r requirements.txt +# install required system packages RUN apt update && apt install -y bind9-host iputils-ping -COPY . . +# create user and group +RUN groupadd -r survBot && useradd -r -g survBot survBot +# change working directory +WORKDIR /usr/src/app + +# install required python packages +RUN --mount=type=bind,source=requirements.txt,target=/tmp/requirements.txt \ + pip install --no-cache-dir --requirement /tmp/requirements.txt + +# switch to user survBot +USER survBot + +# copy application files +COPY survBot.py utils.py write_utils.py LICENSE README.md ./ + +# copy configuration files +VOLUME /usr/src/app/conf +COPY parameters.yaml mailing_list.yaml simulate_fail.json conf/ +RUN ln -s conf/simulate_fail.json simulate_fail.json + +# copy www files +VOLUME /usr/src/app/www +COPY logo.png stylesheets/desktop.css stylesheets/mobile.css www/ +RUN ln -s www/index.html survBot_out.html + +# run the application CMD [ "python", "./survBot.py", "-html", "www", "-parfile", "conf/parameters.yaml" ] diff --git a/survBot.py b/survBot.py index 53357d7..2d5fef5 100755 --- a/survBot.py +++ b/survBot.py @@ -704,7 +704,7 @@ class StationQC(object): return 'active' return False - def _simulated_error_check(self, key, fname='conf/simulate_fail.json'): + def _simulated_error_check(self, key, fname='simulate_fail.json'): if not os.path.isfile(fname): return with open(fname) as fid: