That's my very first docker project, and I've followed several articles on medium on how to use docker with an existing react + express node js project.
Important note to mention, I don't want to use the build command on the react (client) side of the project.
How can I solve this error and run this project properly?
Thanks in advance...
This error is thrown when I use the command docker-compose up:-
Creating waha_api_1 ... done
Creating waha_client_1 ... done
Attaching to waha_api_1, waha_client_1 api_1
| npm ERR! code ENOENT api_1
| npm ERR! syscall open api_1
| npm ERR! path /api/package.json api_1
| npm ERR! errno -2 api_1
| npm ERR! enoent ENOENT: no such file or directory, open '/api/package.json' api_1
| npm ERR! enoent This is related to npm not being able to find a file. api_1
| npm ERR! enoent api_1
| api_1
| npm ERR! A complete log of this run can be found in: api_1
| npm ERR! /root/.npm/_logs/2021-05-08T12_46_07_679Z-debug.log client_1
| npm ERR! code ENOENT client_1
| npm ERR! syscall open client_1
| npm ERR! path /client/package.json client_1
| npm ERR! errno -2 client_1
| npm ERR! enoent ENOENT: no such file or directory, open '/client/package.json' client_1
| npm ERR! enoent This is related to npm not being able to find a file. client_1
| npm ERR! enoent client_1
| client_1
| npm ERR! A complete log of this run can be found in: client_1
| npm ERR! /root/.npm/_logs/2021-05-08T12_47_03_120Z-debug.log client_1
| npm ERR! code ENOENT client_1
| npm ERR! syscall open client_1
| npm ERR! path /client/package.json client_1
| npm ERR! errno -2 client_1
| npm ERR! enoent ENOENT: no such file or directory, open '/client/package.json' client_1
| npm ERR! enoent This is related to npm not being able to find a file. client_1
| npm ERR! enoent client_1
| client_1
| npm ERR! A complete log of this run can be found in: client_1
| npm ERR! /root/.npm/_logs/2021-05-08T12_47_04_690Z-debug.log waha_client_1 exited with code 254 client_1
| npm ERR! code ENOENT client_1
| npm ERR! syscall open client_1
| npm ERR! path /client/package.json client_1
| npm ERR! errno -2 client_1
| npm ERR! enoent ENOENT: no such file or directory, open '/client/package.json' client_1
| npm ERR! enoent This is related to npm not being able to find a file. client_1
| npm ERR! enoent client_1
| client_1
| npm ERR! A complete log of this run can be found in: client_1
| npm ERR! /root/.npm/_logs/2021-05-08T12_47_06_078Z-debug.log waha_client_1 exited with code 254 client_1
| npm ERR! code ENOENT client_1
| npm ERR! syscall open client_1
| npm ERR! path /client/package.json client_1
| npm ERR! errno -2 client_1
| npm ERR! enoent ENOENT: no such file or directory, open '/client/package.json' client_1
| npm ERR! enoent This is related to npm not being able to find a file. client_1
| npm ERR! enoent client_1
| client_1
| npm ERR! A complete log of this run can be found in: client_1
| npm ERR! /root/.npm/_logs/2021-05-08T12_47_07_881Z-debug.log waha_client_1 exited with code 254 client_1
| npm ERR! code ENOENT client_1
| npm ERR! syscall open client_1
| npm ERR! path /client/package.json client_1
| npm ERR! errno -2 client_1
| npm ERR! enoent ENOENT: no such file or directory, open '/client/package.json' client_1
| npm ERR! enoent This is related to npm not being able to find a file. client_1
| npm ERR! enoent client_1
| client_1
| npm ERR! A complete log of this run can be found in: client_1
| npm ERR! /root/.npm/_logs/2021-05-08T12_47_09_661Z-debug.log waha_client_1 exited with code 254 client_1
| npm ERR! code ENOENT client_1
| npm ERR! syscall open client_1
| npm ERR! path /client/package.json client_1
| npm ERR! errno -2 client_1
| npm ERR! enoent ENOENT: no such file or directory, open '/client/package.json' client_1
| npm ERR! enoent This is related to npm not being able to find a file. client_1
| npm ERR! enoent client_1
| client_1
| npm ERR! A complete log of this run can be found in: client_1
| npm ERR! /root/.npm/_logs/2021-05-08T12_47_12_248Z-debug.log waha_client_1 exited with code 254 client_1
| npm ERR! code ENOENT client_1
| npm ERR! path /client/package.json client_1
| npm ERR! errno -2 client_1
| npm ERR! enoent ENOENT: no such file or directory, open '/client/package.json' client_1
| npm ERR! enoent This is related to npm not being able to find a file. client_1
| npm ERR! enoent client_1
| client_1
| npm ERR! A complete log of this run can be found in: client_1
| npm ERR! /root/.npm/_logs/2021-05-08T12_47_16_386Z-debug.log waha_client_1 exited with code 254 waha_api_1 exited with code 254
api dockerfile:-
# Use a lighter version of Node as a parent image
FROM node:12-alpine
# Set the working directory to /api
WORKDIR /api
# copy package.json into the container at /api
COPY package.json ./api
COPY package-lock.json ./api
# install dependencies
RUN npm install
# Copy the current directory contents into the container at /api
COPY . /api/
# Make port 80 available to the world outside this container
EXPOSE 80
# Run the app when the container launches
CMD ["npm", "start"]
client dockerfile:-
# Use a lighter version of Node as a parent image
FROM node:12-alpine
# Set the working directory to /client
WORKDIR /client
# copy package.json into the container at /client
COPY package.json ./client
COPY package-lock.json ./client
# install dependencies
RUN npm install
# Copy the current directory contents into the container at /client
COPY . /client/
# Make port 3000 available to the world outside this container
EXPOSE 3000
# Run the app when the container launches
CMD ["npm", "start"]
docker-compose.yml:-
version: "3"
services:
client:
build:
context: ./client
dockerfile: ./Dockerfile
image: client
restart: always
ports:
- "3000:3000"
volumes:
- ./client:/client
- /client/node_modules
links:
- api
networks:
- webappnetwork
api:
build:
context: ./api
dockerfile: ./Dockerfile
image: api
restart: always
ports:
- "9000:9000"
volumes:
- ./api:/api
- /api/node_modules
networks:
- webappnetwork
networks:
webappnetwork:
driver: bridge
my project structure:-