From 798c559c9079dea9d07550e4cfb44b3a01f9fdf7 Mon Sep 17 00:00:00 2001 From: "peter.fong" Date: Fri, 7 Feb 2025 10:30:32 +0000 Subject: [PATCH] weatherforecast dockerized --- WeatherForecast/Dockerfile | 34 +++++++++++++++++++ WeatherForecast/cronfile | 1 + .../database.py | 0 WeatherForecast/docker-compose.yml | 18 ++++++++++ .../logger.py | 0 {weather forecast => WeatherForecast}/main.py | 0 .../requirements.txt | 0 .../script_getforecast.py | 0 .../weather.py | 0 qrcodegen/requirements.txt | 6 +++- 10 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 WeatherForecast/Dockerfile create mode 100644 WeatherForecast/cronfile rename {weather forecast => WeatherForecast}/database.py (100%) create mode 100644 WeatherForecast/docker-compose.yml rename {weather forecast => WeatherForecast}/logger.py (100%) rename {weather forecast => WeatherForecast}/main.py (100%) rename {weather forecast => WeatherForecast}/requirements.txt (100%) rename weather forecast/getforecast.py => WeatherForecast/script_getforecast.py (100%) rename {weather forecast => WeatherForecast}/weather.py (100%) diff --git a/WeatherForecast/Dockerfile b/WeatherForecast/Dockerfile new file mode 100644 index 0000000..6412a2e --- /dev/null +++ b/WeatherForecast/Dockerfile @@ -0,0 +1,34 @@ +# Gebruik een officiƫle Python-image als basis +FROM python:3.9-slim + +RUN apt-get update && apt-get -y install cron nano procps +# Werkdirectory instellen +WORKDIR /app + +# Kopieer je Python-bestanden naar de container +COPY . /app + +# Kopieer de requirements.txt naar de container +COPY requirements.txt . +# Kopieer de requirements.txt naar de container +COPY .env . + +# Installeer de vereiste Python dependencies +RUN pip install --no-cache-dir -r requirements.txt + +# Installeer cron en zorg ervoor dat de cron-demon actief is +RUN apt-get update && apt-get install -y cron + +# Voeg het cron-script toe +COPY cronfile /etc/cron.d/cronfile +# Zorg ervoor dat het cron-script uitvoerbaar is +RUN chmod 0644 /etc/cron.d/cronfile + +# Voeg een cronjob toe die de Python-script dagelijks uitvoert +RUN crontab /etc/cron.d/cronfile + +# Voeg een cronjob toe die de Python-script dagelijks uitvoert +RUN crontab /etc/cron.d/cronfile + +# Start de cron-demon en houd de container draaiend +CMD ["cron", "-f"] diff --git a/WeatherForecast/cronfile b/WeatherForecast/cronfile new file mode 100644 index 0000000..08c9a50 --- /dev/null +++ b/WeatherForecast/cronfile @@ -0,0 +1 @@ +0 13 * * * /usr/local/bin/python /app/script_getforecast.py >> /var/log/cron.log 2>&1 diff --git a/weather forecast/database.py b/WeatherForecast/database.py similarity index 100% rename from weather forecast/database.py rename to WeatherForecast/database.py diff --git a/WeatherForecast/docker-compose.yml b/WeatherForecast/docker-compose.yml new file mode 100644 index 0000000..44bf0fe --- /dev/null +++ b/WeatherForecast/docker-compose.yml @@ -0,0 +1,18 @@ +# docker compose -f energyprices_docker-compose.yml up -d --build + +version: "3.3" +services: + weatherforecast: + restart: always + container_name: weatherforecast + environment: + - PUID=1000 + - PGID=1000 + - TZ=Europe/Amsterdam + build: + dockerfile: ./Dockerfile + env_file: + - .env + deploy: + mode: replicated + replicas: 1 diff --git a/weather forecast/logger.py b/WeatherForecast/logger.py similarity index 100% rename from weather forecast/logger.py rename to WeatherForecast/logger.py diff --git a/weather forecast/main.py b/WeatherForecast/main.py similarity index 100% rename from weather forecast/main.py rename to WeatherForecast/main.py diff --git a/weather forecast/requirements.txt b/WeatherForecast/requirements.txt similarity index 100% rename from weather forecast/requirements.txt rename to WeatherForecast/requirements.txt diff --git a/weather forecast/getforecast.py b/WeatherForecast/script_getforecast.py similarity index 100% rename from weather forecast/getforecast.py rename to WeatherForecast/script_getforecast.py diff --git a/weather forecast/weather.py b/WeatherForecast/weather.py similarity index 100% rename from weather forecast/weather.py rename to WeatherForecast/weather.py diff --git a/qrcodegen/requirements.txt b/qrcodegen/requirements.txt index 5d56fdd..958b3c4 100644 --- a/qrcodegen/requirements.txt +++ b/qrcodegen/requirements.txt @@ -1,2 +1,6 @@ pandas -matplotlib +qrcode[pil] +Pillow +reportlab +requests +python-dotenv