nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.56k stars 2.36k forks source link

NX cant run nestjs app on docker #12347

Closed duard closed 2 years ago

duard commented 2 years ago

Current Behavior

I cant run my nestjs app using docker The app works when using only nx serve

Expected Behavior

nx works with docker

Steps to Reproduce

git clone https://github.com/duard/nx-latest-docker docker-compose up

Failure Logs

    ~/github-me/ceorg  on   main  docker-compose --verbose up --build                                                  ✔  at 11:41:27  

[+] Building 4.5s (12/12) FINISHED                                                                                                                
 => [internal] load build definition from Dockerfile                                                                                         0.1s
 => => transferring dockerfile: 32B                                                                                                          0.0s
 => [internal] load .dockerignore                                                                                                            0.1s
 => => transferring context: 2B                                                                                                              0.0s
 => [internal] load metadata for docker.io/library/node:13-alpine                                                                            0.7s
 => [1/7] FROM docker.io/library/node:13-alpine@sha256:527c70f74817f6f6b5853588c28de33459178ab72421f1fb7b63a281ab670258                      0.0s
 => [internal] load build context                                                                                                            0.6s
 => => transferring context: 3.73MB                                                                                                          0.5s
 => CACHED [2/7] WORKDIR /app                                                                                                                0.0s
 => CACHED [3/7] COPY package.json package-lock.json ./                                                                                      0.0s
 => CACHED [4/7] COPY .env.dev ./                                                                                                            0.0s
 => CACHED [5/7] RUN npm install                                                                                                             0.0s
 => CACHED [6/7] RUN npm install -g nx                                                                                                       0.0s
 => [7/7] COPY . .                                                                                                                           2.0s
 => exporting to image                                                                                                                       1.0s
 => => exporting layers                                                                                                                      0.9s
 => => writing image sha256:585f7dfdb96ba5f695e5f60612815345fe4c9f3487d9d658b9cedf5c0ad5a5dd                                                 0.0s
 => => naming to docker.io/library/ceorg-api-testes                                                                                          0.0s
[+] Running 1/1
 ⠿ Container ceorg-api-testes-1  Recreated                                                                                                   1.2s
Attaching to ceorg-api-testes-1
ceorg-api-testes-1  | 
ceorg-api-testes-1  | > nx run api-testes:serve
ceorg-api-testes-1  | 
ceorg-api-testes-1  | 
ceorg-api-testes-1  |  >  NX   Only file and data URLs are supported by the default ESM loader
ceorg-api-testes-1  | 
ceorg-api-testes-1  |    Pass --verbose to see the stacktrace.
ceorg-api-testes-1  | 
ceorg-api-testes-1  | 
ceorg-api-testes-1  |  
ceorg-api-testes-1  | 
ceorg-api-testes-1  |  >  NX   Running target "api-testes:serve" failed
ceorg-api-testes-1  | 
ceorg-api-testes-1  |    Failed tasks:
ceorg-api-testes-1  |    
ceorg-api-testes-1  |    - api-testes:serve
ceorg-api-testes-1  |    
ceorg-api-testes-1  |    Hint: run the command with --verbose for more details.
ceorg-api-testes-1  | 
ceorg-api-testes-1  |    See Nx Cloud run details at https://cloud.nx.app/runs/UdGprNXTtGo
ceorg-api-testes-1  | 
ceorg-api-testes-1 exited with code 1

Environment


 >  NX   Report complete - copy this into the issue template

   Node : 14.20.0
   OS   : linux x64
   npm  : 6.14.17

   nx : 14.8.2
   @nrwl/angular : Not Found
   @nrwl/cypress : Not Found
   @nrwl/detox : Not Found
   @nrwl/devkit : 14.8.2
   @nrwl/esbuild : Not Found
   @nrwl/eslint-plugin-nx : 14.8.2
   @nrwl/expo : Not Found
   @nrwl/express : Not Found
   @nrwl/jest : 14.8.2
   @nrwl/js : 14.8.2
   @nrwl/linter : 14.8.2
   @nrwl/nest : 14.8.2
   @nrwl/next : Not Found
   @nrwl/node : 14.8.2
   @nrwl/nx-cloud : 14.7.0
   @nrwl/nx-plugin : Not Found
   @nrwl/react : Not Found
   @nrwl/react-native : Not Found
   @nrwl/rollup : Not Found
   @nrwl/schematics : Not Found
   @nrwl/storybook : Not Found
   @nrwl/web : Not Found
   @nrwl/webpack : 14.8.2
   @nrwl/workspace : 14.8.2
   typescript : 4.8.4
   ---------------------------------------
   Local workspace plugins:
   ---------------------------------------
   Community plugins:
skrtheboss commented 2 years ago

Should be related to https://github.com/nrwl/nx/issues/12338

nartc commented 2 years ago

@duard latest version of Nx, namely nrwl/webpack:webpack executor is using the latest version of webpack which isn't compatible with lower version of NodeJS (eg: your Docker image uses Node 13). Try bumping your Docker image to use node-16 instead. (https://nx.dev/workspace/nx-nodejs-typescript-version-matrix)

github-actions[bot] commented 1 year ago

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.