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

NX Cannot find configuration for task web:serve in Docker container #23420

Open
1 of 4 tasks
Nazar-Brunarskyi opened this issue May 16, 2024 · 1 comment
Open
1 of 4 tasks
Assignees
Labels
scope: nextjs Issues related to NextJS support for Nx type: bug

Comments

@Nazar-Brunarskyi
Copy link

Current Behavior

I want to Dockerize my next js app for this I have created a docker file:

FROM node:18.18.2-alpine

WORKDIR /usr/src/apps

COPY package*.json ./
RUN npm install

COPY . .

EXPOSE 4200

CMD ["npm", "run", "web:serve:qa"]

to build an image i use $ docker build -f Dockerfile.web -t web . command.

The Image is built successfully.

when I try to run a container from that image i get an error:

> npx nx run web:serve:qa
 NX   Cannot find configuration for task web:serve
Pass --verbose to see the stacktrace.

Expected Behavior

I expect the container to start successfully and I would be able to open the app inside browser

GitHub Repo

No response

Steps to Reproduce

  1. install the last nx 19
  2. create a next project
  3. add docker file
FROM node:18.18.2-alpine

WORKDIR /usr/src/apps

COPY package*.json ./
RUN npm install

COPY . .

EXPOSE 4200

CMD ["npm", "run", "web:serve:qa"]
  1. Use $ docker build -f Dockerfile.web -t web . to build the image
  2. run the container from that image

Nx Report

report on my machine
Node   : 18.18.2
OS     : win32-x64
npm    : 9.8.1

nx                 : 19.0.2
@nx/js             : 19.0.2
@nx/jest           : 19.0.2
@nx/linter         : 19.0.2
@nx/eslint         : 19.0.2
@nx/workspace      : 19.0.2
@nx/devkit         : 19.0.2
@nx/eslint-plugin  : 19.0.2
@nx/nest           : 19.0.2
@nx/next           : 19.0.2
@nx/node           : 19.0.2
@nx/react          : 19.0.2
@nrwl/tao          : 19.0.2
@nx/web            : 19.0.2
@nx/webpack        : 19.0.2
typescript         : 5.4.5
---------------------------------------
Registered Plugins:
@nx/next/plugin
@nx/jest/plugin
@nx/eslint/plugin
@nx/webpack/plugin

report inside docker container
Node   : 18.18.2
OS     : linux-x64
npm    : 9.8.1
nx                 : 19.0.2
@nx/js             : 19.0.2
@nx/jest           : 19.0.2
@nx/linter         : 19.0.2
@nx/eslint         : 19.0.2
@nx/workspace      : 19.0.2
@nx/devkit         : 19.0.2
@nx/eslint-plugin  : 19.0.2
@nx/nest           : 19.0.2
@nx/next           : 19.0.2
@nx/node           : 19.0.2
@nx/react          : 19.0.2
@nrwl/tao          : 19.0.2
@nx/web            : 19.0.2
@nx/webpack        : 19.0.2
typescript         : 5.4.5
---------------------------------------
Registered Plugins:
@nx/next/plugin
@nx/jest/plugin
@nx/eslint/plugin
@nx/webpack/plugin

Failure Logs

> @project-name/source@0.0.0 web:serve:qa
> npx nx run web:serve:qa
 NX   Cannot find configuration for task web:serve
Pass --verbose to see the stacktrace.

Package Manager Version

9.8.1

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

No response

@Nazar-Brunarskyi
Copy link
Author

here is my project.json file

{
  "name": "web",
  "$schema": "../../node_modules/nx/schemas/project-schema.json",
  "sourceRoot": "apps/web",
  "projectType": "application",
  "tags": ["scope:web"],
  "targets": {
    "build": {
      "executor": "@nx/next:build",
      "outputs": ["{options.outputPath}"],
      "defaultConfiguration": "production",
      "options": {
        "outputPath": "dist/apps/web"
      },
      "configurations": {
        "development": {
          "outputPath": "apps/web"
        },
        "production": {},
        "qa": {}
      }
    },
    "serve": {
      "executor": "@nx/next:server",
      "defaultConfiguration": "development",
      "options": {
        "buildTarget": "apps/web:build",
        "dev": true,
        "port": 4200
      },
      "configurations": {
        "development": {
          "buildTarget": "web:build:development",
          "dev": true
        },
        "production": {
          "buildTarget": "web:build:production",
          "dev": false
        },
        "qa": {
          "buildTarget": "web:build:qa",
          "dev": false
        }
      }
    },
    "lint": {
      "executor": "@nx/linter:eslint",
      "outputs": ["{options.outputFile}"],
      "options": {
        "lintFilePatterns": ["apps/web/**/*.{ts,tsx,js,jsx}"]
      }
    }
  }
}

@FrozenPandaz FrozenPandaz added the scope: nextjs Issues related to NextJS support for Nx label May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: nextjs Issues related to NextJS support for Nx type: bug
Projects
None yet
Development

No branches or pull requests

3 participants