docker - Dockerizing simple webbapp: how to pick what goes in which container? -


i have simple webapp. can think it's webpage input box sends user input backend, backend returns json , front end plugs json jinja2 template , serves html. that's it. (also there's mysql db on backend)

i want dockerize this. reason webapp happens have gotten traction , i've had before scares push something, website breaks, try , roll , it's still broken , end spending couple of hours sweating fix fast possible. i'm hoping docker solves this.

question: how should split whole thing different containers? given have planned future, backend have turned api frontend connects to. 2 independent containers. question how connect them. should api container expose http:80 endpoint, frontend container gets from? guess confusion comes fact have have 2 python processes running: 1 api obviously, , 1 nothing sending input api , rendering returned json jinja2 template. (and 1 container mysql db).

or should keep both renderer , api in same container, have 2 pages, example /search.html user knows , api /api.html "secret" need in future?

does picture make sense, or on complicating it?

there no hard , fast rules this, rule of thumb 1 process per container. allow reuse these containers across different applications. conversely, people finding useful create "fat containers" have single image whole app runs in 1 container.

you have think things like, "how affect deploy process?" , "do have sufficient test feedback loop allows me make these changes easily?". link seems useful: https://valdhaus.co/writings/docker-misconceptions/

if small application, , you're not operating in soa environment, 1 container want.


Comments