I have project that uses Go and postgresql
What is the optimal solution for creating a DockerFile?
use os[for example ubuntu] in docker and install go and postgresql? or use those separately[use go and postgresql and connection between them]?
Docker suggest one container for one task, you could refers to Multi container apps:
We have been working with single container apps. But, we now want to add MySQL to the application stack. The following question often arises - “Where will MySQL run? Install it in the same container or run it separately?” In general, each container should do one thing and do it well. A few reasons:
- There’s a good chance you’d have to scale APIs and front-ends differently than databases
- Separate containers let you version and update versions in isolation
- While you may use a container for the database locally, you may want to use a managed service for the database in production. You don’t want to ship your database engine with your app then.
- Running multiple processes will require a process manager (the container only starts one process), which adds complexity to container startup/shutdown
And there are more reasons. So, we will update our application to work like this:
So, for you, you should choose use go and postgresql in different containers and connection between them.