I have three services starting up from my docker-compose.yml file. A React frontend, a node js backend and a mongodb service. It starts up and run absolutely fine on windows but it takes lots of time on mac that most of the time it throws http timeout error.
My docker-compose file -
version: "2"
services:
client:
build:
context: ./react-ui
args:
NPM_TOKEN: $NPM_TOKEN
environment:
- CHOKIDAR_USEPOLLING=true
- NPM_TOKEN=${NPM_TOKEN}
ports:
- "3001:3001"
volumes:
- /app/node_modules
- ./react-ui:/app
server:
command: yarn dev -- -L
build:
context: ./server
restart: always
environment:
- CHOKIDAR_USEPOLLING=true
- NODE_ENV=development
- MONGODB_URI=mongodb://mongodb:27017/react-node-project
ports:
- "3000:3000"
volumes:
- /app/node_modules
- ./server:/app
depends_on:
- mongodb
mongodb:
image: mongo
ports:
- "27017:27017"
My react dockerfile -
FROM node:alpine
ARG NPM_TOKEN
ENV NPM_TOKEN=${NPM_TOKEN}
WORKDIR "/app"
COPY ./package.json ./
COPY ./.npmrc .
RUN yarn install
COPY . .
CMD ["yarn", "start"]
My server dockerfile -
FROM node:8.11
EXPOSE 3000
ARG NODE_ENV
ENV NODE_ENV $NODE_ENV
WORKDIR /app
COPY ./package.json .
RUN yarn install
COPY . .
CMD ["yarn", "docker:start"]
docker:start script does nodemon ./src/index.js
I have made sure to add node_modules in my .dockerignore file. Also the client service specifically is taking lots of time for mac. Maybe I have written something incorrectly there which is taking so much time.
I have tried on 2-3 mac machines, the behaviour is same.