1

How can I efficiently package and deploy multiple related applications (React frontend and Node.js backend) within a single container? Where containers are meant to be single-process deployments and common statement heard in topic of serving static files with Node.js are performance issues.My current approach involves separate Dockerfiles for each application, using NGINX for the frontend and Node.js for the backend.

2
  • 1
    You can run multiple services in a container if it fits your needs. Commented Sep 8, 2020 at 7:08
  • 1
    I'd compile the React app to static files and have something serve those; I'd prefer to have the Node back-end serve the static files than try to stuff multiple processes into one container. A multi-stage build doesn't help you get around Docker fundamentally running one process per container. Commented Sep 8, 2020 at 10:52

1 Answer 1

1

It's not worthly to worry about performance before application gets deployed at the first place, there is much unknowns in area for optimalization such as requests per second, bundle size, complexity of operations and so on.

By the problem presented in question I was really looking for serving out static content by Node.js server which reduces deployment to single container, and by such deployment and operational costs - it was optimal solution in budget where in fact application up to this day has not hit any performance bottlenecks that would make production not able to be used.

Key takes:

  • Containers are meant to be single-process deployments, which means they should not hold running Node.js API and Nginx in one container - for this purpose it's better to create two separate containers as it's easier to manage.
  • Serving static assets with Node.js was not a problem for the usecase I had trouble with, application at the production was roughly ~1 RPM (if so) and even if there are performance bottlenecks it's often not worthly to pay for two container deployments instead one that will serve front-end and back-end. (by "not worthly" I assume serving application on budget for ex. PaaS that will bill per container running)

Disclaimer

This answer was rewritten along the question to make it more informative for newcommers who may have similar problem. Previously I've come down to using Meteor.js which have seem to resolve my problem yet I did not understand the problem as a whole.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.