- Prerequisites
- Local Development
- Production Deployment
- NPM Scripts
- Environment Variables
- Add A New Migration
- Docker Engine >=v20.10.24
- Docker Compose >=v2.17.2
- Nodejs >=v22.14.0
Prepare your local development environment with a single command:
npm run setup:dev
This command will do the following for you:
- Removes and reinstalls the node_modules with
npm run cleanup:dev
- Stops all previous containers with
npm run setdown:dev
- Spin up the database with
docker compose --file local-compose.yaml up --detach
- Generate the types from the Prisma Schema for your database with
npm run prisma:generate:dev
- Run all database migrations so your database is always on the latest schema with
npm run migrate:dev
If you want to stop all containers after developing you can run:
npm run setdown:dev
Start the server with:
npm run start:dev
You can now visit http://localhost:5000/ping and start developing.
Start the application in production with:
docker compose up --build
This command will spin up:
- the database
- run run the database migrations
- start the web app that can communicate with the database on [http://localhost:5000/ping](http://localhost:5000/ping]
npm run build
: will transpile the typescript app to javascript executable by nodejsnpm run start
: will start the server found in thedist
foldernpm run migrate
: will start the migrationsnpm run prisma:generate
: will create the types for the database interactions (create, update, delete, etc, ...)npm run start:dev
: will start the server with nodemon that watches for changes in the codenpm run migrate:dev
: will start the migrations in development modenpm run prisma:generate:dev
: will create the types for the database interactions in development mode (create, update, delete, etc, ...)npm run setup:dev
: will prepare and setup your local environment with a single commandnpm run setdown:dev
: will stop all running development containersnpm run cleanup:dev
: will remove and reinstall all node_modules
We use dotenv-cli
to pass the environment variables to a command, like:
dotenv -e .env -- npx prisma migrate deploy
For local development modify the .env.local
file and for production the .env
file, like:
# commments
MY_NEW_VARIABLE="my-new-value"
Modify the prisma.schema
in app/database/prisma/prisma.schema
, like:
model SomeNewModel {
// add your table fields
}
and run npm run migrate
.
We use GitHub Actions to run the tests and build the application on every push to the master
branch. The workflow is defined in .github/workflows/test-build-push.yml
.
The workflow will:
- Test the application with
npm run test
. - Build the Docker image.
- Push the Docker image to the registry, using the package version from
package.json
as the tag.