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

[Bug] agora-api fails to build Docker image after migrating to pnpm #2773

Closed
3 tasks done
tschaffter opened this issue Aug 27, 2024 · 1 comment · Fixed by #2774
Closed
3 tasks done

[Bug] agora-api fails to build Docker image after migrating to pnpm #2773

tschaffter opened this issue Aug 27, 2024 · 1 comment · Fixed by #2774
Labels
bug Something isn't working

Comments

@tschaffter
Copy link
Member

Is there an existing issue for this?

  • I have searched the existing issues

What product(s) are you seeing the problem on?

Agora

Current behavior

$ nx build-image agora-api

...
#10 [6/8] COPY dist/apps/agora/api /app
      #10 CACHED
      
      #11 [7/8] RUN npm install
      #11 1.987 npm notice 
      #11 1.987 npm notice New minor version of npm available! 10.5.0 -> 10.8.2
      #11 1.987 npm notice Changelog: <https://github.com/npm/cli/releases/tag/v10.8.2>
      #11 1.988 npm notice Run `npm install -g [email protected]` to update!
      #11 1.988 npm notice 
      #11 1.991 npm ERR! code ERESOLVE
      #11 1.997 npm ERR! ERESOLVE unable to resolve dependency tree
      #11 1.998 npm ERR! 
      #11 1.998 npm ERR! While resolving: [email protected]
      #11 1.998 npm ERR! Found: [email protected]
      #11 1.998 npm ERR! node_modules/zone.js
      #11 1.998 npm ERR!   zone.js@"0.14.4" from the root project
      #11 1.998 npm ERR! 
      #11 1.998 npm ERR! Could not resolve dependency:
      #11 1.998 npm ERR! peer zone.js@"~0.11.4" from @angular/[email protected]
      #11 1.998 npm ERR! node_modules/@angular/core
      #11 1.998 npm ERR!   @angular/core@"13.4.0" from the root project
      #11 1.998 npm ERR!   peer @angular/core@"13.4.0" from @angular/[email protected]
      #11 1.998 npm ERR!   node_modules/@angular/common
      #11 1.998 npm ERR!     @angular/common@"13.4.0" from the root project
      #11 1.998 npm ERR! 
      #11 1.998 npm ERR! Fix the upstream dependency conflict, or retry
      #11 1.998 npm ERR! this command with --force or --legacy-peer-deps
      #11 1.998 npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
      #11 2.002 npm ERR! 
      #11 2.002 npm ERR! 
      #11 2.002 npm ERR! For a full report see:
      #11 2.002 npm ERR! /root/.npm/_logs/2024-08-27T17_23_50_709Z-eresolve-report.txt
      #11 2.003 
      #11 2.003 npm ERR! A complete log of this run can be found in: /root/.npm/_logs/2024-08-27T17_23_50_709Z-debug-0.log
      #11 ERROR: process "/bin/sh -c npm install" did not complete successfully: exit code: 1
      ------
       > [7/8] RUN npm install:
      1.998 npm ERR! 
      1.998 npm ERR! Fix the upstream dependency conflict, or retry
      1.998 npm ERR! this command with --force or --legacy-peer-deps
      1.998 npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
      2.002 npm ERR! 
      2.002 npm ERR! 
      2.002 npm ERR! For a full report see:
      2.002 npm ERR! /root/.npm/_logs/2024-08-27T17_23_50_709Z-eresolve-report.txt
      2.003 
      2.003 npm ERR! A complete log of this run can be found in: /root/.npm/_logs/2024-08-27T17_23_50_709Z-debug-0.log
      ------
      Dockerfile:13
      --------------------
        11 |     WORKDIR ${APP_DIR}
        12 |     COPY dist/apps/agora/api ${APP_DIR}
        13 | >>> RUN npm install
        14 |     
        15 |     HEALTHCHECK --interval=2s --timeout=3s --retries=20 --start-period=5s \
      --------------------
      ERROR: failed to solve: process "/bin/sh -c npm install" did not complete successfully: exit code: 1
      
      >  Removing temp folder /tmp/docker-build-push-6UQq1q 
      
      
       NX   buildx failed with: ERROR: failed to solve: process "/bin/sh -c npm install" did not complete successfully: exit code: 1
      
      Pass --verbose to see the stacktrace.
      
      
   ✔  nx run agora-app:server:production (11s)
   ✔  nx run agora-app:build-image (3s)

——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

 NX   Ran target build-image for 6 projects and 6 tasks they depend on (33s)

Expected behavior

The image should build fine.

Anything else?

The issue seems to be a conflicts between peer dependencies, which may have resulted from the generation of a new lock file while migrating to pnpm.

Commit ID

No response

Are you developing inside the dev container?

  • I am using the dev container

Code of Conduct

  • I agree to follow this project's Code of Conduct
@tschaffter tschaffter added the bug Something isn't working label Aug 27, 2024
@tschaffter
Copy link
Member Author

tschaffter commented Aug 27, 2024

We should not install the npm packages when building the Docker image because the output app could be different from the one built and tested. Instead, the app should be bundled with its dependencies like the Angular apps and we should just have to copy these files to the Docker images.

Meanwhile, here is the error thrown by the agora-api app when not installing the dependencies in the Dockerfile.

$ nx serve-detach agora-api

...
Node.js v18.20.2
node:internal/modules/cjs/loader:1143
  throw err;
  ^

Error: Cannot find module 'tslib'
Require stack:
- /app/main.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1140:15)
    at Module._load (node:internal/modules/cjs/loader:981:27)
    at Module.require (node:internal/modules/cjs/loader:1231:19)
    at require (node:internal/modules/helpers:177:18)
    at Array.<anonymous> (/app/main.js:8:18)
    at __webpack_require__ (/app/main.js:140:41)
    at /app/main.js:158:17
    at /app/main.js:173:3
    at Object.<anonymous> (/app/main.js:178:12)
    at Module._compile (node:internal/modules/cjs/loader:1364:14) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/app/main.js' ]
}

Node.js v18.20.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant