parent
78af76b2b9
commit
fdcdd82260
@ -0,0 +1,36 @@
|
||||
# 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.energie /etc/cron.d/cronfile.energie
|
||||
# Zorg ervoor dat het cron-script uitvoerbaar is
|
||||
RUN chmod 0644 /etc/cron.d/cronfile.energie
|
||||
|
||||
# Voeg een cronjob toe die de Python-script dagelijks uitvoert
|
||||
RUN crontab /etc/cron.d/cronfile.energie
|
||||
|
||||
|
||||
# Voeg start.sh toe
|
||||
COPY start.sh /start.sh
|
||||
RUN chmod +x /start.sh
|
||||
|
||||
# Gebruik start.sh om zowel cron als currentprice.py te starten
|
||||
CMD ["/start.sh"]
|
||||
@ -0,0 +1,20 @@
|
||||
# docker compose -f energyprices_docker-compose.yml up -d --build
|
||||
|
||||
version: "3.3"
|
||||
services:
|
||||
WeatherApp:
|
||||
restart: always
|
||||
container_name: WeatherApp
|
||||
environment:
|
||||
- PUID=1000
|
||||
- PGID=1000
|
||||
- TZ=Europe/Amsterdam
|
||||
- FLASK_ENV=production
|
||||
- FLASK_APP=main.py
|
||||
build:
|
||||
dockerfile: ./Dockerfile
|
||||
env_file:
|
||||
- .env
|
||||
deploy:
|
||||
mode: replicated
|
||||
replicas: 1
|
||||
@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Laad omgevingsvariabelen als .env bestaat
|
||||
if [ -f .env ]; then
|
||||
export $(grep -v '^#' .env | xargs)
|
||||
fi
|
||||
|
||||
# Start de cron-service correct
|
||||
service cron start
|
||||
|
||||
# Start de Flask-app met Gunicorn (betere productie-optie)
|
||||
gunicorn --bind 0.0.0.0:5000 main:app --workers 4 &
|
||||
|
||||
# Houd de container draaiende en log cron-uitvoer
|
||||
tail -f /var/log/cron.log
|
||||
Binary file not shown.
Loading…
Reference in new issue