Fix Docker production build: move tsx to dependencies, reinstall in production stage

The production Docker stage was copying pnpm symlinks between stages
which broke module resolution. Now does a fresh pnpm install --prod
in the production stage and runs from the server working directory.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-27 19:33:16 -04:00
parent 4881907c28
commit a061337d6f
3 changed files with 8 additions and 8 deletions
+4 -4
View File
@@ -18,12 +18,12 @@ RUN pnpm --filter @ai-tycoon/shared build && \
pnpm --filter @ai-tycoon/server typecheck pnpm --filter @ai-tycoon/server typecheck
FROM base AS production FROM base AS production
COPY --from=deps /app/node_modules ./node_modules COPY pnpm-lock.yaml pnpm-workspace.yaml package.json ./
COPY --from=deps /app/packages/shared/node_modules ./packages/shared/node_modules
COPY --from=deps /app/apps/server/node_modules ./apps/server/node_modules
COPY packages/shared ./packages/shared COPY packages/shared ./packages/shared
COPY packages/tsconfig ./packages/tsconfig COPY packages/tsconfig ./packages/tsconfig
COPY apps/server ./apps/server COPY apps/server ./apps/server
RUN pnpm install --frozen-lockfile --prod
ENV NODE_ENV=production ENV NODE_ENV=production
EXPOSE 3001 EXPOSE 3001
CMD ["node", "--import", "tsx", "apps/server/src/index.ts"] WORKDIR /app/apps/server
CMD ["node", "--import", "tsx", "src/index.ts"]
+1 -1
View File
@@ -19,13 +19,13 @@
"drizzle-orm": "^0.44.2", "drizzle-orm": "^0.44.2",
"hono": "^4.7.10", "hono": "^4.7.10",
"postgres": "^3.4.7", "postgres": "^3.4.7",
"tsx": "^4.19.4",
"uuid": "^11.1.0" "uuid": "^11.1.0"
}, },
"devDependencies": { "devDependencies": {
"@ai-tycoon/tsconfig": "workspace:*", "@ai-tycoon/tsconfig": "workspace:*",
"@types/node": "^25.6.0", "@types/node": "^25.6.0",
"drizzle-kit": "^0.31.1", "drizzle-kit": "^0.31.1",
"tsx": "^4.19.4",
"typescript": "^5.8.3" "typescript": "^5.8.3"
} }
} }
+3 -3
View File
@@ -38,6 +38,9 @@ importers:
postgres: postgres:
specifier: ^3.4.7 specifier: ^3.4.7
version: 3.4.9 version: 3.4.9
tsx:
specifier: ^4.19.4
version: 4.21.0
uuid: uuid:
specifier: ^11.1.0 specifier: ^11.1.0
version: 11.1.0 version: 11.1.0
@@ -51,9 +54,6 @@ importers:
drizzle-kit: drizzle-kit:
specifier: ^0.31.1 specifier: ^0.31.1
version: 0.31.10 version: 0.31.10
tsx:
specifier: ^4.19.4
version: 4.21.0
typescript: typescript:
specifier: ^5.8.3 specifier: ^5.8.3
version: 5.9.3 version: 5.9.3