Skip to content

dossierhq/dossier-next-sqlite-app

Repository files navigation

dossier-next-sqlite-app

Node CI Demo - Deploy to Fly

This is a template for an app using Dossier, Next.js and SQLite.

In order to keep things as simple as possible, this template doesn't have any auth. I.e. there's no need to login and all users use the same anonymous user. In order to protect the data, in production (pnpm run start:production) only read-only published content can be accessed, and the Dossier web interface is disabled.

Warning When deploying to Netlify or Vercel you will only be able to use Dossier at build-time, since Next.js running in serverless mode don't support opening SQLite databases in run-time. Running locally, or in a "normal" Node server doesn't have this restriction.

Getting started

  • npm init using dossierhq/dossier-next-sqlite-app my-project
  • cd my-project
  • git init && git add . && git commit -m '🚀 Created project 🚀'
  • pnpm install
  • pnpm run build
  • pnpm start

You should now have a working app running at http://localhost:3000. Try to add an entity type to the schema and create some entities.

A new SQLite database will be created in data/database.sqlite. By adding it to Git you can keep the state of Dossier and synchronize it between computers.

Deploy

Docker

  • docker build --target runner -t dossier-next-sqlite-app .
  • docker run -p 3000:3000 --mount type=bind,source="$(pwd)"/data,target=/data --env SQLITE_FILE=/data/database.sqlite dossier-next-sqlite-app

Fly.io

Fly.io allows to deploy apps with generous free allowance.

Follow the guide to install flyctl, sign up and sign in to Fly.io. The generate a new Fly app:

$ cd my-project
$ fly launch # select NO on deploy now

Change the generated file fly.toml and set the PORT environment variable to 8080, like so:

[env]
  PORT = "8080"

Now you can go ahead and deploy:

$ fly deploy
$ fly open
  • Demo (using the demo branch)
  • The database file is part of the deployed app, but it's read-only. Fly supports persistent storage, but if you're using a deployed writable database you most likely want auth as well, so it's out of scope for this template

Netlify

Deploy with Netlify

  • Demo (using the demo branch)
  • N.B Only static (i.e. build-time) usages of Dossier are supported on Netlify when using an SQLite database.

Vercel

Deploy with Vercel