Coder Social home page Coder Social logo

joelwembo / django-ecs-ecr-terraform Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 1.0 155 KB

Using Terraform to provision Amazon’s ECR and ECS to deploy Django Web App Container

Home Page: https://medium.com/@joelotepawembo

Dockerfile 4.60% Makefile 14.41% Python 33.54% Shell 5.26% HCL 42.20%
aws aws-cloudformation terraform

django-ecs-ecr-terraform's Introduction

django-ecs-ecr-terraform

image

Deploying a large scale django application to aws can be a bit challenging. You can use your Amazon ECR private repositories to host container images and artifacts that your Amazon ECS tasks may pull from.

In this article, we are going to illustrate how to Use Terraform to provision AWS #ecs and ECR to deploy a containerized django Web App.

✅ Article: http://surl.li/rdddq ✅ Source Code: http://surl.li/rdddw

we also created a CI/CD pipeline using Github Actions to deploy the #dockerized django application to ECS. The pipeline will be triggered on every push to the main branch. The pipeline will update newly terraform added resources, build the docker image, push it to #ECR, and update the ECS service with the new image. #docker #aws #terraform #ecr #ecs #loadbalancing #github #terraformcertified #awscloud #awsdevops #django #djangodeveloper

Local test

docker build -t django-ecs-ecr-terraform .

OR

docker-compose down docker-compose build --no-cache docker-compose up

Screenshot 2024-03-02 012830

Deployment to ECR /ECS

After the terraform resources are deployed

Make sure that you have the latest version of the AWS CLI and Docker installed. For more information, see Getting Started with Amazon ECR . Use the following steps to authenticate and push an image to your repository. For additional registry authentication methods, including the Amazon ECR credential helper, see Registry Authentication . Retrieve an authentication token and authenticate your Docker client to your registry. Use the AWS CLI:

aws ecr get-login-password --region ap-southeast-1 | docker login --username AWS --password-stdin xxxxxxxxxxxxxx.dkr.ecr.ap-southeast-1.amazonaws.com Note: If you receive an error using the AWS CLI, make sure that you have the latest version of the AWS CLI and Docker installed. Build your Docker image using the following command. For information on building a Docker file from scratch see the instructions here . You can skip this step if your image is already built:

docker build -t demo-app-ecr-repo-2 . After the build completes, tag your image so you can push the image to this repository:

docker tag demo-app-ecr-repo-2:latest xxxxxxxxxxxxxx.dkr.ecr.ap-southeast-1.amazonaws.com/demo-app-ecr-repo-2:latest Run the following command to push this image to your newly created AWS repository:

docker push xxxxxxxxxxxxxx.dkr.ecr.ap-southeast-1.amazonaws.com/demo-app-ecr-repo-2:latest

  1. Authentificate to ECR

aws ecr get-login-password --region ap-southeast-1 --profile default | docker login --username AWS --password-stdin xxxxxxxxxxxxxx.dkr.ecr.ap-southeast-1.amazonaws.com

  1. build the image

docker build -t django-app-ecr-repo .

  1. tag the image

docker tag django-app-ecr-repo:latest xxxxxxxxxxxxxx.dkr.ecr.ap-southeast-1.amazonaws.com/django-app-ecr-repo:latest

  1. push the image

docker push xxxxxxxxxxxxxx.dkr.ecr.ap-southeast-1.amazonaws.com/django-app-ecr-repo:latest

  1. test locally first

django-ecs-ecr-terraform's People

Contributors

joelwembo avatar

Stargazers

Sourabh Jana avatar

Watchers

 avatar  avatar

Forkers

iam-jerry22

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.