It works in a LINUX environment, but not in a WINDOWS environment.
this is my dockerfile
# Stage 1: Base with pnpm installed
FROM node:lts-alpine as base
RUN npm install -g pnpm
# Stage 2: Dependencies
FROM base as dependencies
WORKDIR /usr/src/app
COPY package.json pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile
# Stage 3: Build application
FROM dependencies as builder
COPY . .
RUN pnpm run build
# Stage 4: Production image
FROM base as production
WORKDIR /usr/src/app
COPY --from=builder /usr/src/app/node_modules ./node_modules
RUN chown -R node:node ./node_modules
USER node
EXPOSE 3000/tcp
CMD ["pnpm", "run", "start"]
# Optionally, add HEALTHCHECK as needed
and here is my docker-compose.yml file
services:
admin-front:
build:
context: .
dockerfile: Dockerfile
container_name: admin-front
working_dir: /usr/src/app
ports:
- "3000:3000"
volumes:
- ./:/usr/src/app
- /usr/src/app/node_modules
environment:
NODE_ENV: development
command: pnpm run dev
and this is my error
PS C:devadmin> docker compose up --build -d
...
------
> [admin-front builder 2/2] RUN pnpm run build:
0.687
0.687 > [email protected] build /usr/src/app
0.687 > next build
0.687
0.722 node:internal/modules/cjs/loader:1148
0.722 throw err;
0.722 ^
0.722
0.722 Error: Cannot find module '/usr/src/app/node_modules/next/dist/bin/next'
0.722 at Module._resolveFilename (node:internal/modules/cjs/loader:1145:15)
0.722 at Module._load (node:internal/modules/cjs/loader:986:27)
0.722 at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12)
0.722 at node:internal/main/run_main_module:28:49 {
0.722 code: 'MODULE_NOT_FOUND',
0.722 requireStack: []
0.722 }
0.722
0.722 Node.js v20.13.1
0.728 ELIFECYCLE Command failed with exit code 1.
------
failed to solve: process "/bin/sh -c pnpm run build" did not complete successfully: exit code: 1
It works fine when run in the context of using MAC and WSL2.
However, it did not work in windows11 environment.
I can’t figure out where the problem is at all