This blog post illustrate development cycle using django app container. I assume readers are already somewhat familar with docker and docker-compose. Although I used django for app development, it is language-agnostic since the post is about containerized application deployment.
Walkthough is devided into three parts consisting three different environemt respectively. First part, describes the architecture of the app(api and async worker) and how they are deployed on local
enviroment. Second part is how to deploy the docker containers on cloud using single ec2 instance with on staging
environment. Third part, illustrate how to convert traditional ec2 deployment into ECS using fargate with github actions on prod
environment.
local
- run docker containers on desktop/laptop with sqlite and redis server using docker-compose
stating
- run docker containers on single ec2 instance with mysql RDS and ElasticCache
prod
- convert stagning setup to ECS Fargate
If you are already familiar with development with docker containers you can skip this post.
How to deploy django app to ECS Fargate part2
How to deploy django app to ECS Fargate part3
First we need to prepare application which is development ready.
This application consist 3 docker containers
nginx
- web serverapp
- Api serverworker
- Async workerapp
and worker
share same base images, main difference is that app
serves http request behind nginx
web server using gunicorn and wsgi. Throughout this walkthough nginx
and app
container will share a common lifecycle.
worker
runs asyncronously using redis queue as broker using Django-RQ.
Refer to github repo for the source. I won't get into the detail of how app is structured.