I'm trying to run json server with docker along with my application in react, but it's not working.
My dockerfile and compose settings:
FROM node:16-alpine
WORKDIR /app
COPY package*.json .
RUN npm install
COPY . .
EXPOSE 3000
CMD [ "npm", "run", "dev" ]
version: "3.7"
services:
react:
build: .
ports:
- 3000:3000
json-server:
build: .
ports:
- 4000:4000
command: npm run server
when I run the command docker-compose up, my react application works but the json server shows this in the terminal:
frontend@0.0.0 server
json-server --watch ./db/dados.json --port 4000
\{^_^}/ hi!
Loading ./db/dados.json
Done
Resources
http://localhost:4000/encomendas
Home
http://localhost:4000
Type s + enter at any time to create a snapshot of the database
Watching...
And nothing happens when I try to fetch the data.
console output