Skip to content

fix(docker): pass --config to prisma migrate deploy in bot CMD - #463

Merged
LucasSantana-Dev merged 1 commit into
mainfrom
fix/dockerfile-prisma-config
Apr 1, 2026
Merged

LucasSantana-Dev merged 1 commit into
mainfrom
fix/dockerfile-prisma-config

Conversation

@LucasSantana-Dev

@LucasSantana-Dev LucasSantana-Dev commented Apr 1, 2026 •

Copy link
Copy Markdown
Owner

Problem

The bot container is crash-looping in production — /version, /play, and all bot commands are broken.

Error: The datasource.url property is required in your Prisma config file when using prisma migrate deploy.

This repeats infinitely because the bot CMD runs prisma migrate deploy before starting the Node process, and Prisma can't find the database URL.

Root cause

The Dockerfile bot CMD was:

CMD ["sh", "-c", "npx prisma migrate deploy && node packages/bot/dist/index.js"]

But prisma migrate deploy in Prisma 7.x requires --config prisma/prisma.config.ts to resolve the datasource URL (which reads DATABASE_URL from the environment). Without it, Prisma defaults to looking for a url field directly in schema.prisma — which doesn't have one (it's in the config file).

The root package.json already passes --config prisma/prisma.config.ts correctly:

"db:deploy": "prisma migrate deploy --config prisma/prisma.config.ts"

The Dockerfile CMD was the only place missing it.

Evidence

  • Homelab: lucky-bot container status: Restarting (1) 53 seconds ago
  • Container logs: 50+ repetitions of the same Prisma error, never reaching node packages/bot/dist/index.js
  • Sentry: 0 issues — bot process dies before Sentry initializes
  • Health endpoint: backend is up (/api/health returns ok), bot is down
  • Deploy SHA: e7f91ab4 is deployed (lyrics PR), images are correct but bot can't start

Fix

-CMD ["sh", "-c", "npx prisma migrate deploy && node packages/bot/dist/index.js"]
+CMD ["sh", "-c", "npx prisma migrate deploy --config prisma/prisma.config.ts && node packages/bot/dist/index.js"]

Verification

  • Matches the working pattern in package.json:db:deploy
  • CI Quality Gates green
  • After deploy: lucky-bot container shows Up instead of Restarting

Summary by CodeRabbit

  • Chores
    • Enhanced production deployment process to ensure database migrations execute properly before the application starts, with automatic rollback if migrations fail.

The bot container crash-loops because 'npx prisma migrate deploy' cannot
find the datasource URL without the --config flag. The root package.json
scripts all pass '--config prisma/prisma.config.ts' but the Dockerfile
CMD was missing it, causing prisma to fail with:
  'The datasource.url property is required in your Prisma config file'

This breaks /version, /play, and all bot commands since the process
never reaches node packages/bot/dist/index.js.
@vercel

vercel Bot commented Apr 1, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lucky Ready Ready Preview, Comment Apr 1, 2026 10:36pm

Request Review

@github-actions github-actions Bot added the infra label Apr 1, 2026
@coderabbitai

coderabbitai Bot commented Apr 1, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 59a881b2-9a07-4891-94e9-5726ba61ca51

📥 Commits

Reviewing files that changed from the base of the PR and between 5ada8a6 and a895d67.

📒 Files selected for processing (1)
  • Dockerfile
📜 Recent review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: SonarCloud Scan
  • GitHub Check: Quality Gates
🧰 Additional context used
🧠 Learnings (8)
📓 Common learnings
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T21:57:49.951Z
Learning: When working with Prisma schema, migrations, DB/Redis in shared packages, use the `prisma-redis-lucky` skill
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T21:57:49.951Z
Learning: When making Prisma schema changes or migrations, use the `database-migration` ecosystem skill
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/lucky-shared.mdc:0-0
Timestamp: 2026-03-09T20:21:15.595Z
Learning: Applies to packages/shared/**/*.ts : Use the single Prisma client located at `packages/shared/src/utils/database/prismaClient.ts`; maintain schema in repo root at `prisma/schema.prisma`; run migrations from root using `npm run db:migrate`
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/subagent-data.mdc:0-0
Timestamp: 2026-03-09T20:21:46.291Z
Learning: Applies to prisma/migrations/**/* : Database migrations must be located in `prisma/migrations/`
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/lucky-discord-bot.mdc:0-0
Timestamp: 2026-03-09T20:20:47.877Z
Learning: Applies to packages/bot/**/*.{ts,tsx} : Use services from `lucky/shared` (DatabaseService, Redis client) for database and cache access; do not instantiate Prisma or Redis directly in the bot package
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/subagent-data.mdc:0-0
Timestamp: 2026-03-09T20:21:46.291Z
Learning: Use `npm run db:generate` command from repo root for Prisma code generation
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/lucky-project.mdc:0-0
Timestamp: 2026-03-09T20:21:08.612Z
Learning: Applies to package.json : Use `npm run dev:bot`, `npm run dev:backend`, and `npm run dev:frontend` for development, and `npm run db:*` commands for database operations
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/subagent-data.mdc:0-0
Timestamp: 2026-03-09T20:21:46.291Z
Learning: Use `npm run db:studio` command from repo root for opening Prisma Studio
📚 Learning: 2026-03-09T20:21:15.595Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/lucky-shared.mdc:0-0
Timestamp: 2026-03-09T20:21:15.595Z
Learning: Applies to packages/shared/**/*.ts : Use the single Prisma client located at `packages/shared/src/utils/database/prismaClient.ts`; maintain schema in repo root at `prisma/schema.prisma`; run migrations from root using `npm run db:migrate`

Applied to files:

  • Dockerfile
📚 Learning: 2026-03-15T21:57:49.951Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T21:57:49.951Z
Learning: When making Prisma schema changes or migrations, use the `database-migration` ecosystem skill

Applied to files:

  • Dockerfile
📚 Learning: 2026-03-09T20:21:46.291Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/subagent-data.mdc:0-0
Timestamp: 2026-03-09T20:21:46.291Z
Learning: Use `npm run db:generate` command from repo root for Prisma code generation

Applied to files:

  • Dockerfile
📚 Learning: 2026-03-15T21:57:49.951Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T21:57:49.951Z
Learning: Build process: use `npm run build` for packages (shared → bot → backend) and `npm run build:frontend` for frontend; development with `npm run dev:bot`, `npm run dev:backend`, `npm run dev:frontend`

Applied to files:

  • Dockerfile
📚 Learning: 2026-03-09T20:21:08.612Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/lucky-project.mdc:0-0
Timestamp: 2026-03-09T20:21:08.612Z
Learning: Applies to package.json : Use `npm run dev:bot`, `npm run dev:backend`, and `npm run dev:frontend` for development, and `npm run db:*` commands for database operations

Applied to files:

  • Dockerfile
📚 Learning: 2026-03-09T20:21:31.459Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/quality.mdc:0-0
Timestamp: 2026-03-09T20:21:31.459Z
Learning: Applies to src/**/*.{ts,tsx,js,jsx} : Implement health/readiness endpoints in backend services

Applied to files:

  • Dockerfile
📚 Learning: 2026-03-09T20:21:08.612Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/lucky-project.mdc:0-0
Timestamp: 2026-03-09T20:21:08.612Z
Learning: Applies to package.json : Use `npm run build` for shared → bot → backend build order; use `npm run build:frontend` separately for frontend

Applied to files:

  • Dockerfile
🔇 Additional comments (1)
Dockerfile (1)

104-104: Good fix for the bot startup crash-loop.

Adding --config prisma/prisma.config.ts to prisma migrate deploy is the correct fix, and keeping && node ... preserves fail-fast startup behavior if migrations fail.


📝 Walkthrough

Walkthrough

The Dockerfile's production-bot container startup command was updated to explicitly specify a Prisma configuration file path when running migrations. The command now includes --config prisma/prisma.config.ts in the Prisma migrate invocation before starting the bot application.

Changes

Cohort / File(s) Summary
Docker Configuration
Dockerfile
Updated production-bot startup command to explicitly pass Prisma config file (--config prisma/prisma.config.ts) to npx prisma migrate deploy before launching the bot application.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Suggested labels

bot, infra, database, size/s

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(docker): pass --config to prisma migrate deploy in bot CMD' clearly and specifically summarizes the main change: adding the --config flag to the prisma migrate deploy command in the Dockerfile.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/dockerfile-prisma-config

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sonarqubecloud

sonarqubecloud Bot commented Apr 1, 2026

Copy link
Copy Markdown

@LucasSantana-Dev
LucasSantana-Dev merged commit 9ef276f into main Apr 1, 2026
12 checks passed
LucasSantana-Dev added a commit that referenced this pull request May 13, 2026
The bot CMD was missing --config prisma/prisma.config.ts, causing Prisma 7.x to fail finding the datasource URL. Matches the working pattern in package.json:db:deploy.
@LucasSantana-Dev
LucasSantana-Dev deleted the fix/dockerfile-prisma-config branch May 23, 2026 02:21

This branch was successfully deployed

1 active deployment
Preview — a895d677 Deployed Apr 1, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant