Deploy React app throught kubernetes with Docker Deploy React app throught kubernetes with Docker kubernetes kubernetes

Deploy React app throught kubernetes with Docker


-i and -t are specific options to docker run; they correspond to the stdin_open: true and tty: true Kubernetes pod settings. You don't need to repeat them in args:.

The Kubernetes args: setting actually replaces the CMD in your Dockerfile (somewhat confusingly, Kubernetes command: replaces Docker ENTRYPOINT), so when you provide args: ['-it'] you're actually overwriting the command the container's trying to run. You should see the same error you get if you incorrectly put the -it option after the image name instead of before it in the docker run command.

stdin: true  # docker run -itty: true    # docker run -t# args: ...  # docker run <image-name> arg1 arg2


look my Dockerfile production:

That way, I use the node to build and then nginx to serve html, css and static javascript. Which is the result of the react build:

# Stage 0, "build-stage", based on Node.js, to build and compile the frontendFROM node:12 as build-stageWORKDIR /appCOPY package*.json /app/RUN npm installCOPY ./ /app/RUN npm run build# Stage 1, based on Nginx, to have only the compiled app, ready for production with NginxFROM nginx:1.15COPY --from=build-stage /app/build/ /usr/share/nginx/html# Copy the default nginx.conf provided by tiangolo/node-frontend#COPY --from=build-stage /nginx.conf /etc/nginx/conf.d/default.conf


I am not sure if you are doing this as a test. But the way you are deploying the front end is not best practice. Usually to deploy a react app you build it first, then you can serve those static files with a server such as nginx. This way you don't have to run any commands in the container.What you would do instead is copy the built files into the nginx container, where it can then serve them.The main reason for this is the built app is much more performant, and you avoid having the whole development tool chain unnecessarily running.Here is more information:https://create-react-app.dev/docs/production-build/