create-t3-app Dockerizing base install fails with Prisma?

I am trying to learn and understand how to do things with Docker, and I saw a Deployment part of the Website which seemed great, but i seem to get stuck on the DATABASE_URL env variable. I was trying to set up a docker-compose for it, but by default it isnt showing how to stand up a separate prisma setup server of sorts. I want to flush out this a bit more, since prisma can make a postgres or various other setups, but i didnt see much regarding it when looking at how to take this base app and create the appropriate containers for it. Can someone point me in some direction on how to get this aspect working? Seems like I will need it to generate a db container, or some other mechanism. to see how I can build the rest of this aspect.
3 Replies
__fallenreaper
__fallenreaperOP2y ago
It seems that the prisma website might be attempting to say to set up a postgres container, and then the DATABASE url would be in the format of: postgresql://USER:PASSWORD@HOST:PORT/DATABASE?KEY1=VALUE&KEY2=VALUE&KEY3=VALUE which I may be able to use to properly connect to the database, but the DATABASE_URL Property is rejected as an Invalid URL so i was unsure if this was the right thing or not. I did a proof of concept setting that in the docker-compose env area, to say: DATABASE_URL=postgresql://USER:PASSWORD@HOST:PORT/DATABASE?KEY1=VALUE&KEY2=VALUE&KEY3=VALUE to see if it would be valid and it failed. So i was curious if zod's url() command is not accurate in understanding the connection string as a url
__fallenreaper
__fallenreaperOP2y ago
ALMOST a 1:1 that I did manage to find which proves somewhat useful is: https://github.com/nicolomaioli/t3-docker-compose It uses mysql but is a decent starting point. The only thing I am trying to figure out and do is encapsulate the non mysql npm commands into the DB. What I surmise is that I will need to create an updated database which also does the prisma push from within its build to retain its correctness or something. Then I should be able to deploy the rest of this to its own container.
GitHub
GitHub - nicolomaioli/t3-docker-compose: A docker-compose example...
A docker-compose example for Create T3 App. Contribute to nicolomaioli/t3-docker-compose development by creating an account on GitHub.
__fallenreaper
__fallenreaperOP2y ago
I ended up using a different image. BASE_IMAGE=node:18-alpine3.17
npm cache clear
npm install
next build && prisma generate && prisma migrate diff --to-schema-datamodel prisma/schema.prisma --from-empty --script > prisma/postgres.sql && docker compose build
docker compose up
npm cache clear
npm install
next build && prisma generate && prisma migrate diff --to-schema-datamodel prisma/schema.prisma --from-empty --script > prisma/postgres.sql && docker compose build
docker compose up
Want results from more Discord servers?
Add your server