-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add prisma Docker target + CI to setup db in staging/prod #325
Conversation
@humphd Interesting approach, but do we have to build a separate docker image just for this? What if we used something like this lib: |
It's not a good idea to run I have to create a different image because I'm not using the usual stages to end at the production image. Let me know if I'm misunderstanding your comment. |
@dadolhay thinking about your comment more. What we could do is create a |
@humphd Thanks, that sounds like a much simpler solution |
I've updated this PR and made some changes:
Some questions I still have:
To test this:
NOTE: it currently crashes on startup because the env var for |
I think intil we reach the DB baseline, this should be OK. If we encounter errors, we can change it to a full reset, but that could be destruptive to manual testers
I think it does, spares an extra step, but this is not a strong opinion Approved, I like this approach much more, it's a lot simpler |
8326ea4
to
19b1702
Compare
Rebased and cleaned up a bit. I like this approach better, too. |
package.json
Outdated
@@ -19,7 +19,8 @@ | |||
"db:reset": "prisma migrate reset", | |||
"db:format": "prisma format", | |||
"db:studio": "prisma studio", | |||
"setup": "run-s db:generate db:push db:seed", | |||
"db:setup": "run-s db:generate db:push", | |||
"setup": "run-s db:setup db:seed", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit. I'm wondering if there are better names to distinguish the two setups. They are both database related, and the only difference is whether we seed, not whether it's database related (db
).
Maybe db:setup
can be setup:seedless
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not actually using this in my code, so I think I'll revert it back to what it was.
Agree. If we don't need to worry about migration files or checking for database drift (via shadow database),
I suppose you can look at container as part of the app and therefore make sense to start it as part of starting the app. Let me know if I'm misunderstanding you. |
19b1702
to
d290118
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Part of #291
In order to ship to staging/production, we need to be able to set up the database. Doing so requires running Prisma with our schema from the staging/production VMs. This creates a Docker build stage that can be optionally run in a stand-alone way to accomplish this.
Every time we push to
main
, CI will create bothstartchart
andstarchart-prisma
images. The latter is used to push the current schema to the database (there might be a better set of commands for us to run, let me know what you think).We won't do this automatically, but I need this to exist so I can run it manually via Docker.
This change also does the following:
db:setup
npm script that does everything except seeds the dbThis doesn't need to get looked at until next week as part of 0.6.