Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build fails inside Docker #99

Open
faltawy opened this issue Jan 17, 2024 · 1 comment
Open

Build fails inside Docker #99

faltawy opened this issue Jan 17, 2024 · 1 comment

Comments

@faltawy
Copy link

faltawy commented Jan 17, 2024

Environment

v20.9.0

Reproduction

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

{
  "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": "[email protected]",
  "engines": {
    "node": ">=v16.20.2"
  },
  "dependencies": {
    "@prisma/client": "5.8.1",
    "prisma": "^5.8.1"
  }
}

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

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 }

Logs

------
 > [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
@itpropro
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants