Recommended Docker Compose Workflow
Hey all, I'm new to making full stack applications and am working with Drizzle to make mine. I have a question on what the best practice is when using databases that are spun up using Docker Compose and how to initialize them with Drizzle tables.
I have the following
docker-compose.yaml
I am using a code-first approach with Drizzle where I want my codebase to be the source of truth for the database since there is tight coupling between the DB and my API server + SPA. The question I have is, when my app is being spun up for a production deployment, how can I ensure that when my PostgresDB from docker spins up, it also prepped with my Drizzle tables via running drizzle-kit push
when it comes alive?
Essentially, I want to make sure that the definition of my database container being "ready" means, the Postgres container is up, and I pushed my Drizzle tables to it (alongside any optional seed script I decide to run -- I actually have a seed_db.ts
script that I typically invoke locally using bun ./scripts/seed_db.ts
which I would like to run for local dev workflows)1 Reply
Feel free to correct my thinking if I perhaps suggested anything unhealthy above. I can use all the guidance I can get. I was just thinking that when it comes to "productionizing" my application, I would want to automate as much of the pipeline as possible. And if I could somehow make the step of "Push my Drizzle tables to the database" as part of the "Spin up docker database" process, that would leave me in a better position.