From 6677be66c0f18481d106fe462b178a8dfab441f3 Mon Sep 17 00:00:00 2001 From: Pat Needham Date: Wed, 22 May 2024 19:07:00 -0400 Subject: [PATCH] sqlite wal mode setup for litefs --- other/Dockerfile | 9 ++++++--- other/litefs.yml | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/other/Dockerfile b/other/Dockerfile index 4806c86a..d1e6d82d 100644 --- a/other/Dockerfile +++ b/other/Dockerfile @@ -55,10 +55,14 @@ ENV DATABASE_FILENAME="sqlite.db" ENV DATABASE_PATH="$LITEFS_DIR/$DATABASE_FILENAME" ENV DATABASE_URL="file:$DATABASE_PATH" ENV CACHE_DATABASE_FILENAME="cache.db" -ENV CACHE_DATABASE_PATH="/$LITEFS_DIR/$CACHE_DATABASE_FILENAME" +ENV CACHE_DATABASE_PATH="$LITEFS_DIR/$CACHE_DATABASE_FILENAME" ENV INTERNAL_PORT="8080" ENV PORT="8081" ENV NODE_ENV="production" +# For WAL support: https://github.com/prisma/prisma-engines/issues/4675#issuecomment-1914383246 +# PR to enable WAL mode for litefs: https://github.com/epicweb-dev/epic-stack/pull/621 +# good explainer of WAL mode: https://www.mycelial.com/learn/sqlite-journal-mode-options +ENV PRISMA_SCHEMA_DISABLE_ADVISORY_LOCK = "1" # add shortcut for connecting to database CLI RUN echo "#!/bin/sh\nset -x\nsqlite3 \$DATABASE_URL" > /usr/local/bin/database-cli && chmod +x /usr/local/bin/database-cli @@ -70,13 +74,12 @@ COPY --from=build /myapp/node_modules/.prisma /myapp/node_modules/.prisma COPY --from=build /myapp/server-build /myapp/server-build COPY --from=build /myapp/build /myapp/build -COPY --from=build /myapp/public /myapp/public COPY --from=build /myapp/package.json /myapp/package.json COPY --from=build /myapp/prisma /myapp/prisma COPY --from=build /myapp/app/components/ui/icons /myapp/app/components/ui/icons # prepare for litefs -COPY --from=flyio/litefs:0.5.8 /usr/local/bin/litefs /usr/local/bin/litefs +COPY --from=flyio/litefs:0.5.11 /usr/local/bin/litefs /usr/local/bin/litefs ADD other/litefs.yml /etc/litefs.yml RUN mkdir -p /data ${LITEFS_DIR} diff --git a/other/litefs.yml b/other/litefs.yml index 0e7f5c15..0a96341f 100644 --- a/other/litefs.yml +++ b/other/litefs.yml @@ -55,4 +55,5 @@ exec: # it has led mainly to starting over from scratch # this is why the deploy action was commented out in deploy.yml for so long # going to try this out and see if it helps +# enabling WAL mode for sqlite db may have had an effect on this, proceed to monitor exit-on-error: true