AWS ECS Production Docker Deployment

风格不统一 提交于 2021-02-07 21:47:15

问题


I've recently started using Docker for my own personal website. So the design my website is basically

Nginx -> Frontend -> Backend -> Database

Currently, the database is hosted using AWS RDS. So we can leave that out for now.

So here's my questions

  1. I currently have my application separated into different repository. Frontend and Backend respectively.

    • Where should I store my 'root' docker-compose.yml file. I can't decide to store it in either the frontend/backend repository.
  2. In a docker-compose.yml file, Can the nginx serve mount a volume from my frontend service without any ports and serve that directory?

  3. I have been trying for so many days but I can't seem to deploy a proper production with Docker with my 3 tier application in ECS Cluster. Is there any good example nginx.conf that I can refer to?

  4. How do I auto-SSL my domain?

Thank you guys!


回答1:


Where should I store my 'root' docker-compose.yml file.

Many orgs use a top level repo which is used for storing infrastructure related metadata such as CloudFormation templates, and docker-compose.yml files. So it would be something like. So devs clone the top level repo first, and that repo ideally contains either submodules or tooling for pulling down the sub repos for each sub component or microservice.

In a docker-compose.yml file, Can the nginx serve mount a volume from my frontend service without any ports and serve that directory?

Yes you could do this but it would be dangerous and the disk would be a bottleneck. If your intention is to get content from the frontend service, and have it served by Nginx then you should link your frontend service via a port to your Nginx server, and setup your Nginx as a reverse proxy in front of your application container. You can also configure Nginx to cache the content from your frontend server to a disk volume (if it is too much content to fit in memory). This will be a safer way instead of using the disk as the communication link. Here is an example of how to configure such a reverse proxy on AWS ECS: https://github.com/awslabs/ecs-nginx-reverse-proxy/tree/master/reverse-proxy

I can't seem to deploy a proper production with Docker with my 3 tier application in ECS Cluster. Is there any good example nginx.conf that I can refer to?

The link in my last answer contains a sample nginx.conf that should be helpful, as well as a sample task definition for deploying an application container as well as a nginx container, linked to each other, on Amazon ECS.

How do I auto-SSL my domain?

If you are on AWS the best way to get SSL is to use the built in SSL termination capabilities of the Application Load Balancer (ALB). AWS ECS integrates with ALB as a way to get web traffic to your containers. ALB also integrates with Amazon certificate manager (https://aws.amazon.com/certificate-manager/) This service will give you a free SSL certificate which automatically updates. This way you don't have to worry about your SSL certificate expiring ever again, because its just automatically renewed and updated in your ALB.



来源:https://stackoverflow.com/questions/45296590/aws-ecs-production-docker-deployment

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!