Finalisation Docker Raspberry et corrections dashboard

This commit is contained in:
2026-04-25 19:13:28 +02:00
parent 3a722867a7
commit 9a1ec86d33
6 changed files with 33 additions and 19 deletions

7
.dockerignore Normal file
View File

@@ -0,0 +1,7 @@
venv/
__pycache__/
*.pyc
.env
.git/
.gitignore
*.log

View File

@@ -16,7 +16,7 @@ RUN pip install --no-cache-dir -r requirements.txt
# On copie tout le reste du projet (tes HTML, CSS, app.py, etc.) # On copie tout le reste du projet (tes HTML, CSS, app.py, etc.)
COPY . . COPY . .
# On expose le port 5000 pour ton Mac # On expose le port 5000 du conteneur
EXPOSE 5000 EXPOSE 5000
# La commande pour démarrer le serveur # La commande pour démarrer le serveur

View File

@@ -2,7 +2,7 @@ import os
class Config: class Config:
DB_HOST = os.environ.get("DB_HOST", "localhost") DB_HOST = os.environ.get("DB_HOST", "localhost")
DB_PORT = os.environ.get("DB_PORT", "5433") DB_PORT = os.environ.get("DB_PORT", "5432")
DB_NAME = os.environ.get("DB_NAME", "ecocharge") DB_NAME = os.environ.get("DB_NAME", "ecocharge")
DB_USER = os.environ.get("DB_USER", "postgres") DB_USER = os.environ.get("DB_USER", "postgres")
DB_PASSWORD = os.environ.get("DB_PASSWORD", "Safouane2005#") DB_PASSWORD = os.environ.get("DB_PASSWORD", "Safouane2005#")

View File

@@ -1,11 +1,11 @@
import psycopg2 import psycopg2
from werkzeug.security import generate_password_hash from werkzeug.security import generate_password_hash
DB_HOST = "localhost" DB_HOST = "db"
DB_PORT = "5433" DB_PORT = "5432"
DB_NAME = "ecocharge" DB_NAME = "ecocharge"
DB_USER = "postgres" DB_USER = "ecocharge_user"
DB_PASSWORD = "Safouane2005#" DB_PASSWORD = "ecocharge_password"
USERNAME = "admin" USERNAME = "admin"
PLAIN_PASSWORD = "admin123" PLAIN_PASSWORD = "admin123"

View File

@@ -2,30 +2,36 @@ services:
db: db:
image: postgres:15-alpine image: postgres:15-alpine
container_name: ecocharge_db container_name: ecocharge_db
restart: unless-stopped
environment: environment:
POSTGRES_USER: ecocharge_user POSTGRES_USER: ecocharge_user
POSTGRES_PASSWORD: ecocharge_password POSTGRES_PASSWORD: ecocharge_password
POSTGRES_DB: ecocharge POSTGRES_DB: ecocharge
ports:
- "5432:5432"
volumes: volumes:
- postgres_data:/var/lib/postgresql/data - postgres_data:/var/lib/postgresql/data
- ./database.sql:/docker-entrypoint-initdb.d/init.sql - ./database.sql:/docker-entrypoint-initdb.d/init.sql
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ecocharge_user -d ecocharge"]
interval: 5s
timeout: 5s
retries: 10
web: web:
build: . build: .
container_name: ecocharge_web container_name: ecocharge_web
restart: unless-stopped
ports: ports:
- "5001:5000" - "5001:5000"
depends_on: depends_on:
- db db:
condition: service_healthy
environment: environment:
- DB_HOST=db DB_HOST: db
- DB_PORT=5432 DB_PORT: 5432
- DB_NAME=ecocharge DB_NAME: ecocharge
- DB_USER=ecocharge_user DB_USER: ecocharge_user
- DB_PASSWORD=ecocharge_password DB_PASSWORD: ecocharge_password
- SECRET_KEY=super_cle_secrete_projet SECRET_KEY: super_cle_secrete_projet
volumes: volumes:
postgres_data: postgres_data:

View File

@@ -301,7 +301,8 @@ async function fetchDatabaseData() {
humEl.innerText = data.humidity_ext !== null ? Math.floor(data.humidity_ext) : "--"; humEl.innerText = data.humidity_ext !== null ? Math.floor(data.humidity_ext) : "--";
if (data.battery_level !== null) { if (data.battery_level !== null) {
updateBattery(Math.floor(data.battery_level), data.battery_alert); const batteryAlert = data.battery_alert === true || data.battery_alert === "true" || data.battery_alert === 1 || data.battery_alert === "1";
updateBattery(Math.floor(data.battery_level), batteryAlert ? "Alerte batterie" : null);
} }
updateSolar( updateSolar(
@@ -349,6 +350,6 @@ fetchHistoryData();
checkSystemStatus(); checkSystemStatus();
setInterval(fetchRealWeather, 900000); setInterval(fetchRealWeather, 900000);
setInterval(fetchDatabaseData, 3000); setInterval(fetchDatabaseData, 10000);
setInterval(fetchHistoryData, 5000); setInterval(fetchHistoryData, 30000);
setInterval(checkSystemStatus, 1000); setInterval(checkSystemStatus, 10000);