Integration with Prisma/Docker
An easier way to integrate these tools into our project.
Let's begin by automatically integrating Prisma and Docker with Nest. We shall first install this schematic by Marc Stammerjohann, which allows for exactly that, and then add it to our project.
And then create the DatabaseModule
, to configure Prisma...
...and add the following to its imports
so that Prisma is available globally.
And finally, some more steps...
Adjust .env file and create .env.example
Add .env to .gitignore
In package.json, in the prisma scripts, replace
npx
withyarn
In the Dockerfile, adjust to use yarn
In docker-compose.yml, use the environment variables and clean up the file a bit
Turn on the database container
We'll also change the migration scripts, so that their usage becomes simpler. So, in package.json, let's alter the following scripts:
Change
migrate:dev
tomigrate:run
Change
migrate:dev:create
tomigrate:create
and add a-n
at the end
Commit - Prisma and docker setup
Last updated