#Correct way to setup prisma + docker

6 messages · Page 1 of 1 (latest)

timber knoll
#

(I am new to prisma this is my first project using it) Hi I am currently trying to dockerise one of my typescript apps (discord bot) which is using prisma with sqlite database. I am in the middle of writing the dockerfile
This is it so far:

FROM node:18-alpine

# Set the working directory inside the container
WORKDIR /usr/src/app

# Copy package.json and package-lock.json to the working directory
COPY package.json package-lock.json ./

# Install dependencies
RUN npm install

# Copy the rest of the application files
COPY . .

# Build the TypeScript code
RUN npm run build

# Prisma needs to generate the client
RUN npx prisma generate

# Run the bot using the built JavaScript file
CMD ["npm", "run", "start"]

My question is what is the proper way to set up migrations or something so that when I push a new version of the scheme.prisma the database automatically gets updated without wiping current data. The sqlite database is persistent across the container builds.

calm mountain
#

I use a boot.sh script


#! /bin/bash

npx prisma migrate deploy
npx prisma generate
npm start
#

and then this in the docker file CMD [ "./boot.sh" ]

timber knoll
#

What about the first deployment?

calm mountain
#

Like most I develop locally, before shoving out into staging/prod.

I use npx prisma migrate dev --name migration_name to generate my migration files after a schema change, the first line applies those migrations on remote