Skip to content

Commit

Permalink
sqlite wal mode setup for litefs
Browse files Browse the repository at this point in the history
  • Loading branch information
goodeats committed May 22, 2024
1 parent e76c768 commit 6677be6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
9 changes: 6 additions & 3 deletions other/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}

Expand Down
1 change: 1 addition & 0 deletions other/litefs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 6677be6

Please sign in to comment.