The DBEST
(DrizzleORM, Bun, ElysiaJS, SolidStart, Tailwind CSS) stack is a bun-based 🔥 BLAZINGLY FAST
🔥 full-stack 100% type-safe
web development solution that provides everything
you need to build a production-ready
web app based on the performant and scalable SolidStart meta-framework. It consists of:
Create a new project
bun create itsyoboieltr/dbest-stack
Optionally specify a name for the destination folder. If no destination is specified, the name dbest-stack
will be used.
bun create itsyoboieltr/dbest-stack my-app
Bun will perform the following steps:
- Download the
template
- Copy all template files into the
destination folder
- Install dependencies with
bun i
. - Initialize a fresh Git repo. Opt out with the
--no-git
flag.
Once the project is created and the dependencies are installed, the environment variables need to be set up. The following environment variables can be configured:
DATABASE_URL="postgresql://postgres:xxxx@database:5432/dbest"
VITE_HOST_URL="http://localhost:3000"
COMPOSE_APP_PORT="3000"
COMPOSE_DATABASE_PORT="5432"
COMPOSE_DATABASE_USER="postgres"
COMPOSE_DATABASE_PASSWORD="xxxx"
COMPOSE_DATABASE_NAME="dbest"
COMPOSE_DATABASE_BACKUP_PATH="$HOME/backup"
COMPOSE_PROFILES="development"
It is recommended to use a .env
file to configure the environment variables.
- For local development
.env.local
should be used, as this is ignored by docker compose. - For production deployment
.env
should be used, as this is used by docker compose.
The most important thing to configure is the database connection, as running the app without a database connection will result in an instant error.
In case your database schema does not match the schema defined by drizzle
, then the database needs to be synchronized. This can be done by running the following command:
bun push
In addition, drizzle studio
can be leveraged to connect to the database and browse, add, delete and update data based on the declared drizzle schema
.
bun studio
If everything is set up correctly, you can start the development server
with:
bun dev
Build for production
by running the following command:
bun run build
Run in production
by running the following command:
bun start
Using the Dockerfile or the compose.yaml file, the application can be deployed to any docker host
. The following command will build the docker image
and start the application.
docker compose up
Important notes for production use:
- In a production setting, you might want to enable
backups for the database
. This can be done by setting theCOMPOSE_PROFILES
environment variable toproduction
.
COMPOSE_PROFILES="production"
- The
COMPOSE_DATABASE_BACKUP_PATH
environment variable can be used tocustomize
the path where thedatabase backups
are stored.
COMPOSE_DATABASE_BACKUP_PATH="$HOME/backup"