Blitz: Bundle docker-compose for local database

Created on 26 Apr 2020  路  8Comments  路  Source: blitz-js/blitz

What do you want and why do you want it?.
Awesome project! On starting, the demo asking you to run a db migrate. Of course this doesn't work cause there's no database up to this point. The instructions on the README then suggest you installing postgres locally.

Instead, I think we can provide a better experience by bundling an already setup docker-compose file and maybe even start the container on blitz start

Possible implementation(s)
Add a docker-compose file to the db folder. Maybe something like the old prisma2 one https://github.com/prisma/prisma2-cli/blob/master/.buildkite/docker-compose.yml

kinbad-experience scopexamples

All 8 comments

@iRoachie wanna work on this?, if not I'll add "ready to work on label" so other people can work on this

What's the best way to do it? I could definitely add a docker-compose file, unsure about the running it part.

Does that mean that docker now is a dependency of the project we're asking users to have?

If they have postgres running on their system they can just use that via the ENV variable. Otherwise they could use docker-compose.

It's an optional dependency if you don't have postgres/don't want to install it.

@flybayer what do you think about this?

You'll need to add a docker file and a docker-compose.yml file for this to work.

Would it be easier to bundle sqlite3 by default instead? We can install that from npm have it write to a file and then we don't necessarily need to muck around with docker. We may want to make docker/postgres combo an installer later?

Here's my thoughts:

The goal here is to have a database running as easy as possible.

  • On macOS, this is already very easy brew install postgres. So Docker is probably worse here
  • Windows it seems is much harder, so Docker may be the easiest for this

I think we should stick with Postgres because it's likely what people will use in production. If we use sqlite, then the project grinds to a halt when they try to deploy. I'd rather frontload this difficulty than defer it. And once PG is set up on their machine, they are set for "life".

I think we should solve this with tooling & docs. An installer is a great idea.

If we use sqlite, then the project grinds to a halt when they try to deploy.

I think that happens no matter what you do. Deploying a stateful system is always a little difficult mainly because you have to setup a production database. The danger in changing dialect might be important if you are deep in the thick of app development and have used non compatible queries but I doubt that would be the case when you first have to do this which would happen as you add state to the application and prisma should take care of all the simple cases.

In my opinion the best case scenario is that blitz just works with no db.

When you first run blitz db * the cli should prompt you to install and select a db.

This will increase adoption around the usecase of a startup moving from a marketing site to a production app which I think is going to be a pretty common usecase. You should not need a database to deploy a blitz app. You should be able to add blitz to a next app and iterate until you have the remote database ready.

Prisma should handle sqlite/psql switching, so we could allow people to just run sqlite as an starting point option, but have psql as the recommended option

Ok, great points you all! Switching to SQLite to #283

Was this page helpful?
0 / 5 - 0 ratings