Repository navigation
fix: resolved issue building docker - #146
Conversation
There was a problem hiding this comment.
Pull request overview
This PR attempts to fix Docker build issues by moving the husky package from devDependencies to dependencies and adjusting the Dockerfile build process. However, the changes introduce semantic and functional issues that should be addressed.
Key Changes
- Moved
huskyfromdevDependenciestodependenciesinpackage.json(with correspondingpnpm-lock.yamlupdates) - Changed
ENV CI=truetoENV HUSKY="0"in Dockerfile - Modified runner stage to copy
prisma/schema directory instead of copying pre-built.prismafiles from builder stage
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| package.json | Moves husky from devDependencies to dependencies, which is semantically incorrect for a dev-only Git hooks tool |
| pnpm-lock.yaml | Updates lock file to reflect husky's new location in the dependency tree |
| Dockerfile | Changes environment variable from CI to HUSKY and restructures production stage to copy prisma schema instead of built artifacts, which may cause build failures |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "zlib-sync": "^0.1.10", | ||
| "husky": "^9.1.7" |
There was a problem hiding this comment.
Moving husky from devDependencies to dependencies is semantically incorrect and unnecessarily increases the production bundle size. Husky is a development tool for Git hooks and should not be in production dependencies.
The root issue is that the prepare script runs husky during pnpm install --prod in the runner stage (line 53), but husky isn't available when it's in devDependencies.
Better solutions:
- Use
pnpm install --prod --frozen-lockfile --ignore-scriptsin the runner stage and copy the built.prismafrom builder - Or update the
preparescript to check forHUSKYenvironment variable:"prepare": "node -e \"if(process.env.HUSKY !== '0') require('husky').install()\""(though husky v9 should already handle HUSKY=0)
| COPY --chown=node:node prisma/ prisma/ | ||
|
|
||
| RUN pnpm install --prod --frozen-lockfile |
There was a problem hiding this comment.
The runner stage now copies the prisma/ schema directory and runs pnpm install --prod --frozen-lockfile, which will trigger Prisma Client generation via @prisma/client's postinstall script. However, the prisma CLI (required for generation) is in devDependencies and won't be installed with --prod. This will likely cause the production build to fail.
The previous approach of copying the pre-built .prisma directory from the builder stage was more efficient and correct. Consider reverting to:
RUN pnpm install --prod --frozen-lockfile
# Patch .prisma with the built files
COPY --chown=node:node --from=builder /usr/src/app/node_modules/.prisma node_modules/.prisma| COPY --chown=node:node prisma/ prisma/ | |
| RUN pnpm install --prod --frozen-lockfile | |
| # Copy pre-built Prisma Client from builder stage | |
| RUN pnpm install --prod --frozen-lockfile | |
| COPY --chown=node:node --from=builder /usr/src/app/node_modules/.prisma node_modules/.prisma |
No description provided.