Long story short, I have 2 images. One is for the client and the other one is for the server. I am using docker-compose and when I was running everything in development mode everything was working as expected and I could access my app.
I had this line "proxy": "http://server:5000"
in package-json and it was working as expected.
I didn’t change anything in my docker-compose file which is here:
version: "3.8"
services:
server:
image: "srdjano1/reaction-server"
ports:
- 5000:5000
env_file:
- ./.env
client:
image: "srdjano1/reaction-client-prod"
ports:
- 80:80
However, when I want to launch my React app in production mode and add nginx
, now requests are no longer received by server.
Here is the new Dockerfile:
FROM node:14-alpine as build
WORKDIR /app
COPY package.json .
RUN yarn install
COPY . .
RUN npm run build
FROM nginx:stable-alpine
COPY --from=build /app/build /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
Now, when I run docker-compose up
I can see the UI but no requests are received by the server. If I need to configure nginx.conf
file, I am not sure how to do that.
Does someone know the reason for this?