Open faltawy opened 8 months ago
v20.9.0
This is my Dockerfile
FROM node:alpine as BUILD WORKDIR /build COPY package.json pnpm-lock.yaml ./ RUN corepack enable COPY ./ ./ RUN pnpm install RUN pnpm build FROM node:alpine WORKDIR /app EXPOSE 3000 COPY --from=BUILD /build/.output /app CMD ["node", "./server/index.mjs"]
and this is my package.json
package.json
{ "name": "backend", "private": true, "scripts": { "build": "nitro build", "dev": "nitro dev", "lint": "eslint --ext .ts . && prettier -c .", "lint:fix": "eslint --fix --ext .ts . && prettier -w -c .", "prepare": "nitro prepare", "readme": "jiti scripts/update-readme.ts", "start": "node .output/server/index.mjs", "test": "pnpm lint", "test:deployment": "jiti ./scripts/test-deployments.ts", "db:gen": "pnpm prisma generate", "db:migrate": "pnpm prisma migrate dev --name init", "postinstall": "pnpm run db:migrate && pnpm run db:gen" }, "devDependencies": { "@actions/core": "^1.10.1", "esbuild": "^0.19.11", "eslint-config-unjs": "^0.2.1", "jiti": "^1.21.0", "nitropack": "npm:nitropack-nightly@latest", "prettier": "^3.1.1" }, "packageManager": "pnpm@8.14.1", "engines": { "node": ">=v16.20.2" }, "dependencies": { "@prisma/client": "5.8.1", "prisma": "^5.8.1" } }
the application works very well outiside docker but when i tried to dockerize it for production it fails
i got this error when i try to build the application inside Docker
1.531 Error: Cannot find module '/build/node_modules/nitropack/dist/cli/index.mjs' 1.531 at Module._resolveFilename (node:internal/modules/cjs/loader:1149:15) 1.531 at Module._load (node:internal/modules/cjs/loader:990:27) 1.531 at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:142:12) 1.531 at node:internal/main/run_main_module:28:49 { 1.531 code: 'MODULE_NOT_FOUND', 1.531 requireStack: [] 1.531 }
------ > [backend build 7/7] RUN pnpm build: 1.393 1.393 > nitro-deploys@ build /build 1.393 > nitro build 1.393 1.531 node:internal/modules/cjs/loader:1152 1.531 throw err; 1.531 ^ 1.531 1.531 Error: Cannot find module '/build/node_modules/nitropack/dist/cli/index.mjs' 1.531 at Module._resolveFilename (node:internal/modules/cjs/loader:1149:15) 1.531 at Module._load (node:internal/modules/cjs/loader:990:27) 1.531 at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:142:12) 1.531 at node:internal/main/run_main_module:28:49 { 1.531 code: 'MODULE_NOT_FOUND', 1.531 requireStack: [] 1.531 } 1.531 1.531 Node.js v21.6.0 1.540 ELIFECYCLE Command failed with exit code 1. ------ failed to solve: process "/bin/sh -c pnpm build" did not complete successfully: exit code: 1
Hey, can you provide a reproduction repro? I have multiple deployments running with dockerization of Nuxt and Nitro and didn't experience that so far. Would like to look into your deployment when you have a repo.
Environment
v20.9.0
Reproduction
This is my Dockerfile
and this is my
package.json
Describe the bug
the application works very well outiside docker but when i tried to dockerize it for production it fails
Additional context
i got this error when i try to build the application inside Docker
Logs