drizzle-team / drizzle-orm

Headless TypeScript ORM with a head. Runs on Node, Bun and Deno. Lives on the Edge and yes, it's a JavaScript ORM too 😅
https://orm.drizzle.team
Apache License 2.0
23.14k stars 564 forks source link

Deploying drizzle studio to production? #1598

Open pat-mw opened 9 months ago

pat-mw commented 9 months ago

Hi there,

I'm using Drizzle ORM in my NextJS 14 project and my client wants the ability to access and modify the database directly.

My plan was to run Drizzle Studio alongside my Vercel production app - or perhaps even under a subdomain which I can put behind an authentication barrier.

I'm looking at the documentation and I don't see a way to run Drizzle studio outside of localhost.

Is this possible?

Sadly, if not, then I will be moving to Prisma.

I would appreciate any guidance as soon as possible :)

Thanks

theonlyway commented 9 months ago

I'm not sure what doco you are looking at since I don't run it on localhost on my end. But there is flags to change both the listening address and the port in the doco. I mean Turso also basically gives you the drizzle studio UI given it says "powered by drizzle studio" in the top right of it when you want to view/edit your tables so it's certainly doable. How? That'll be up to you to figure out I guess but the flags are there for you to do it

https://orm.drizzle.team/drizzle-studio/overview/#launch-drizzle-studio

pat-mw commented 9 months ago

@theonlyway thanks for getting back to me. I'm using Planetscale as my db provider, not Turso. Planetscale unfortunately doesn't have any UI to view and edit the database.

Re: Drizzle studio - if you're not running on localhost then how are you running it? As per the docs: drizzle studio is available at 'local.drizzle.studio' which simply listens to a localhost port.

Problem is, I'm using Vercel / NextJS for my deployment and I don't know how I can set up a concurrent application on a different port.

Vercel app running on: https://website.com

Ideally, I can have drizzle studio always running at either a subdomain: https://admin.website.com or at a specific page: https://website.com/admin

This service should also be password protected (unlike the default drizzle studio config)

carloslfu commented 7 months ago

I just hit the same use case for a dev platform I am building. I would love for Drizzle Kit to offer an option here. Prisma Studio is not really an option for my use case, and they don't offer this as well.

@pat-mw. The Turso UI seems to be a partnership or collaboration with Drizzle. Drizzle Team, correct me if I am wrong.

I think this is part of a plan to make Drizzle earn money. I am in the very early stages of developing a dev tool, so I can relate.

Having to build this myself would be really time-consuming and would be very basic at first. I prefer a ready-made fully functional component that I don't bother maintaining even if I have to pay along the way. Like Clerk, I use Clerk, and it's great!

Idea: Make it so people can embed the Drizzle Studio UI in the same way you allow Turso to do it and document it somewhere. The integration can be free up to X users and then paid or free with the Drizzle branding and paid if you want to remove it, something along those lines. For instance, the guys at Val Town use Turso and Drizzle but have built their own visualizer, which is very basic (attached a screenshot). I would guess they need it, too.

cc @AndriiSherman @AlexBlokh @dankochetov.

Screenshot 2024-02-06 at 7 22 59 AM

pat-mw commented 7 months ago

hey @carloslfu - appreciate you adding some insight to this thread. I agree, I think it's pretty necessary at this point to allow this feature even if its behind a paywall.

I've unfortunately already committed to Planetscale as my DB provider so I don't have liberty to try Turso for this project. It's something I'll consider for future projects but realistically it's not always going to be an option.

If Drizzle wants to be the go-to headless connector for NextJS, in my opinion, this is something that needs to be addressed. Many applications, both user-facing and internal-tools, will need the ability for admins to enter the database layer and make edits without having to set up their own local development environment.

scr2em commented 3 weeks ago

I ended up using running drizzle studio on my remote server on port REMOTE_PORT then used SSH tunneling on my device

ssh -L LOCAL_PORT:localhost:REMOTE_PORT username@remote_server_ip

then visit https://local.drizzle.studio/?port=LOCAL_PORT

I'd prefer having hosted and protected by basic auth, but this solution works too

LeulAria commented 4 days ago

i want to deploy drizzle studio under subdomain no truso no nonsense am using bare metal postgres

?? any one