I know that there has been others who have asked this question on here before, however, I have gone through them and have tried the suggestions. I believe that its a complex issue because everyone's files look different and varies from the other based on placements and paths, which I am not familiar yet in Docker. Now, when I run on docker-compose build, the program tells me that
Building server
Traceback (most recent call last): File "compose/cli/main.py", line 67, in main File "compose/cli/main.py", line 126, in perform_command File "compose/cli/main.py", line 302, in build File "compose/project.py", line 468, in build File "compose/project.py", line 450, in build_service File "compose/service.py", line 1147, in build compose.service.BuildError: (<Service: server>, {'message': 'Cannot locate specified Dockerfile: ./client/Dockerfile'})
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "docker-compose", line 3, in File "compose/cli/main.py", line 78, in main TypeError: can only concatenate str (not "dict") to str [34923] Failed to execute script docker-compose
I have tried placing the Dockerfile from the client to the same directory as the docker-compose.yml file to eliminate path discrepencies, however, it still says the same thing. Please let me know if you have any suggestions. Thanks!
Here is my docker-compose.yml file
version: "3.7"
services:
server:
build:
context: ./server
dockerfile: ./client/Dockerfile
image: myapp-server
container_name: myapp-node-server
command: /usr/src/app/node_modules/.bin/nodemon server.js
volumes:
- ./server/:/usr/src/app
- /usr/src/app/node_modules
ports:
- "5050:5050"
depends_on:
- mongo
env_file: ./server/.env
environment:
- NODE_ENV=development
networks:
- app-network
mongo:
image: mongo
volumes:
- data-volume:/data/db
ports:
- "27017:27017"
networks:
- app-network
client:
build:
context: ./client
dockerfile: Dockerfile
image: myapp-client
container_name: myapp-react-client
command: npm start
volumes:
- ./client/:/usr/app
- /usr/app/node_modules
depends_on:
- server
ports:
- "3000:3000"
networks:
- app-network
networks:
app-network:
driver: bridge
volumes:
data-volume:
node_modules:
web-root:
driver: local
Here is the Dockerfile in the client folder
FROM node:10.16-alpine
WORKDIR /usr/src/app
COPY package.json ./
RUN npm install
COPY . .
EXPOSE 3000
CMD ["npm", "start"]
Here is the Dockerfile in the server folder
FROM node:10.16-alpine
# Create App Directory
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
# Install Dependencies
COPY package*.json ./
RUN npm install --silent
# Copy app source code
COPY . .
# Exports
EXPOSE 5050
CMD ["npm","start"]