Docker Community Forums

Share and learn in the Docker community.

Dockerizing react app for production with express backend doesn't seem to work

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"
    image: "srdjano1/reaction-server"
      - 5000:5000
      - ./.env

    image: "srdjano1/reaction-client-prod"
      - 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


COPY package.json .

RUN yarn install

COPY . .

RUN npm run build

FROM nginx:stable-alpine

COPY --from=build /app/build /usr/share/nginx/html


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?