Prisma migration issue on BlitzJS project

Hi,
I’m having issues with prisma, when specifying the DATABASE_URL to the internal built-in variable, I get a can’t reach database error, from dockerfile and when using buildpack.
The database is set on private.

a random dockerfile to test

FROM node:16-alpine
ARG DATABASE_URL
ARG SESSION_SECRET
WORKDIR /app
ENV DATABASE_URL=${DATABASE_URL}
ENV SESSION_SECRET=${SESSION_SECRET}
COPY . .
RUN npm install --legacy-peer-deps
RUN npx prisma migrate deploy
EXPOSE 3000
CMD ["npm", "run", "start"]

Hi @jaaouany ,

You can take a look at this thread since it’s related.

In a nutshell :chestnut:, you can’t run RUN npx prisma migrate deploy since it’s executed at the build time of your container and the build process does not have access to your database. I would recommend using an entrypoint.sh and executing the migrate command before that your node process starts. You can take a look at this guide.

1 Like