0

I tried to build docker and docker-compose files for an ant-design-pro project.
Dockerfile

FROM node:16-alpine
WORKDIR /fleet-management
COPY package.json ./
RUN yarn
COPY . .
CMD [ "npm", "start" ]

docker-compose.yml

version: '3.8'
services:
  app:
    build:
      context: .
    working_dir: /fleet-management
    volumes:
      - .:/fleet-management
    ports:
      - 8000:8000
    image: app:react
    container_name: react_container
    command: ['yarn', 'start']

However, I got this error in the console when running the page, and the page loads forever:

Uncaught (in promise) Error: Module "./$CWD$/node_modules/umi/node_modules/@umijs/runtime" does not exist in container.
while loading "./$CWD$/node_modules/umi/node_modules/@umijs/runtime" from webpack/container/reference/mf
Uncaught (in promise) Error: Module "./$CWD$/node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/defineProperty.js" does not exist in container.
while loading "./$CWD$/node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/defineProperty.js" from webpack/container/reference/mf
        at mf-va_remoteEntry.js:888:11

And 50+ other errors like that.
The node_modules is already in the docker as I checked.

  • Why are you mixing `yarn` and `npm`? – Phil May 31 '23 at 03:44
  • TL;DR for the duplicate - add an anonymous volume mount... `- /fleet-management/node_modules` – Phil May 31 '23 at 03:48
  • _"The node_modules is already in the docker as I checked"_... it might be in the image but when you run it via `docker compose`, your `volumes` mount overwrites it which is exactly why I said to add an anonymous mount in order to preserve what's already in the image – Phil May 31 '23 at 04:47

0 Answers0