How to use Continuous Integration and Delivery with Django and AWS Code Pipeline
Before we get started let's have a brief understanding of Continuous Integration and Continuous Delivery
Continuous integration is a DevOps software development practice where developers regularly merge their code changes into a central repository, after which automated builds and tests are run.
Continuous integration most often refers to the build or integration stage of the software release process and entails both an automation component (e.g. a CI or build service) and a cultural component (e.g. learning to integrate frequently). The key goals of continuous integration are to find and address bugs quicker, improve software quality, and reduce the time it takes to validate and release new software updates.
Continuous Delivery is a DevOps software development practice where code changes are automatically built, tested, and prepared for a release to production. It expands upon continuous integration by deploying all code changes to a testing environment and/or a production environment after the build stage. When continuous delivery is implemented properly, developers will always have a deployment-ready build artifact that has passed through a standardized test process.
Continuous delivery lets developers automate testing beyond just unit tests so they can verify application updates across multiple dimensions before deploying to customers. These tests may include UI testing, load testing, integration testing, API reliability testing, etc. This helps developers more thoroughly validate updates and pre-emptively discover issues. With the cloud, it is easy and cost-effective to automate the creation and replication of multiple environments for testing, which was previously difficult to do on-premises.
To cut things short continuous integration is the build and unit testing stage of the software release process. Every revision committed triggers an automated build and test.
1. Improves Developer Productivity
2. Find and Address Bugs quicker
3. Deliver updates Faster
Here's a link to the repository for this course CI-CD-DJANGO-AWS
All this app does is to return a JSON response when you hit an endpoint.
What services will we use?
1.AWS Elastic Beanstalk (In order to keep deployment of our app as simple as possible we'll use Elastic Beanstalk which requires less configuration)
- AWS Codepipeline
AWS code pipeline is a fully managed CI delivery service that helps you automate your release pipelines for fast and reliable application and infrastructure updates. It automates builds, tests, and deploy phases of release processes every time there is a code change, based on the release model you define.
Enough talk 🥱! Let's get started.
PREPARING OUR APPLICATION
NB: All services we'll use can be used with the AWS Free Tier. You can register for the free tier hereAWS Free Tier
Login to your AWS console AWS CONSOLE
We'll then go ahead and create our application. Before we can upload our app we need to make it compatible with AWS.
a. To do that we'll create a folder in our Django project called
.ebextensions/.(The directory where manage.py is)
b. Create a file called
django.config and add the following:
As simple as that we can now go ahead and deploy our app. We just have
**NB: Immediately after deployment, we'll edit Django's configuration to add the domain name that Elastic Beanstalk will assign our application to Django's
ALLOWED_HOSTS in our
settings file. Then we'll redeploy your application. This is a Django security requirement, designed to prevent HTTP Host header attacks.In the second part we'll go through the process of configuring codepipeline for our Continuous Integration process.