From 7f1e17db2b44ad0d022bfd73faa02cc5b40b6e80 Mon Sep 17 00:00:00 2001 From: DanielS Date: Tue, 22 Sep 2026 23:18:39 +0200 Subject: [PATCH] =?UTF-8?q?fix(persistence):=20Robustes=20/data=20Volume?= =?UTF-8?q?=20f=C3=BCr=20SQLite=20data.db=20&=20WAL-Dateien?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + db.js | 9 ++++++++- docker-compose.yml | 4 +++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 3598976..5facefe 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,6 @@ node_modules/ data.db data.db-wal data.db-shm +data/ .env .DS_Store diff --git a/db.js b/db.js index a5a04e1..b853624 100644 --- a/db.js +++ b/db.js @@ -3,9 +3,16 @@ const path = require('path'); const Database = require('better-sqlite3'); const bcrypt = require('bcryptjs'); -const dbPath = path.join(__dirname, 'data.db'); +// Verzeichnis für Persistenz sicherstellen (/data im Docker Container oder local dir) +const dataDir = process.env.DATA_DIR || (fs.existsSync('/data') ? '/data' : __dirname); +if (!fs.existsSync(dataDir)) { + fs.mkdirSync(dataDir, { recursive: true }); +} + +const dbPath = path.join(dataDir, 'data.db'); const db = new Database(dbPath); +// Standard Journal Mode db.pragma('journal_mode = WAL'); // Tabellen anlegen diff --git a/docker-compose.yml b/docker-compose.yml index 607c0b2..9e179b3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,5 +6,7 @@ services: restart: unless-stopped ports: - "8085:80" + environment: + - DATA_DIR=/data volumes: - - ./data.db:/app/data.db + - ./data:/data