Store cook log DB in writable data dir, not read-only recipes mount
Build and Deploy / build-and-deploy (push) Successful in 2m43s
Build and Deploy / build-and-deploy (push) Successful in 2m43s
The cook log SQLite DB was created at recipeDir/cook-log.db. In the Docker deployment /recipes is mounted read-only, so SQLite could never create the file there — the cook log has never worked in the container. The writable /data volume was mounted but unused. - initDb now creates the DB's parent directory if missing, so startup initialization is self-contained and idempotent. - app takes a dataDir and places cook-log.db there. - Add optional --data-dir flag (defaults to the recipe dir, preserving local-dev behavior); Docker CMD passes --data-dir /data. Verified end-to-end as root against a read-only recipe dir and a non-existent data dir: the dir and DB are created and cook-log POST/GET round-trips. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+10
-6
@@ -74,12 +74,15 @@ readRequestBody req = do
|
||||
then pure (reverse acc)
|
||||
else gather (chunk : acc)
|
||||
|
||||
{- | Build the WAI 'Application' given a path to the recipe directory and config.
|
||||
{- | Build the WAI 'Application' given the recipe directory, a writable data
|
||||
directory, and config.
|
||||
|
||||
Recipes are scanned at startup and then watched live via fsnotify.
|
||||
Recipes are scanned at startup and then watched live via fsnotify. The cook log
|
||||
database is created (if absent) in @dataDir@, which must be writable — the
|
||||
recipe directory may be mounted read-only (as it is in the Docker deployment).
|
||||
-}
|
||||
app :: FilePath -> RouxConfig -> IO Wai.Application
|
||||
app recipeDir config = do
|
||||
app :: FilePath -> FilePath -> RouxConfig -> IO Wai.Application
|
||||
app recipeDir dataDir config = do
|
||||
putStrLn $ "[roux] scanning recipes from " <> recipeDir
|
||||
recipes <- Idx.scanRecipes recipeDir
|
||||
let count = length recipes
|
||||
@@ -101,8 +104,9 @@ app recipeDir config = do
|
||||
forkIO $
|
||||
watchRecipes absDir state changeLog `catch` \e ->
|
||||
putStrLn $ "[roux] watcher thread crashed: " <> show (e :: SomeException)
|
||||
-- Initialize cook log database
|
||||
let dbPath = recipeDir </> "cook-log.db"
|
||||
-- Initialize cook log database in the writable data directory (initDb
|
||||
-- creates the directory and file if they are not already present).
|
||||
let dbPath = dataDir </> "cook-log.db"
|
||||
db <- CookLog.initDb dbPath
|
||||
putStrLn $ "[roux] cook log DB: " <> dbPath
|
||||
pure (router absDir config state changeLog db)
|
||||
|
||||
Reference in New Issue
Block a user