Skip to content

Jliezed/oc_project_13_orange

Repository files navigation

oc-project django postgresql tests linting docker cicd circleci heroku sentry


OC - PROJECT N°13 - Django App Deployment - CI/CD Pipeline

Orange County Lettings is a small Django App deployed on Heroku and using a CI/CD Pipeline.

By Ian Dooley

Project Overview

Overview

(back to top)

Built With & Tools

  • Python
  • Django
  • Docker
  • CircleCI
  • Heroku
  • Sentry

(back to top)

Getting Started

Clone the repo

git clone https://github.com/Jliezed/oc_project_13_orange.git

Run the app:

-> with a virtual environment

Install venv library (if not yet in your computer)

pip install venv

Create a virtual environment

python -m venv env

Activate the virtual environment

source env/bin/activate

Install packages using requirements.txt

pip install -r requirements.txt

Access to the App by running the server

python manage.py runserver

Go to http://127.0.0.0:8000/ to access the app

Go to http://127.0.0.0:8000/admin/ to access the admin panel (user: admin, password: Abc1234!)

-> with Docker

Build the image

docker build -t oc_project_13_orange .

Run the container

 docker run -p 8000:8000 oc_project_13_orange

Go to http://localhost:8000/ to access the app

Go to http://localhost:8000/admin/ to access the admin panel (user: admin, password: Abc1234!)

(back to top)

Lintings & Tests

Run Flake8

flake8

Run Tests

python manage.py test

(back to top)

Deployment - CI/CD Pipeline

Define in the .circleci/config.yml file the steps to be executed by CircleCI when a new commit is pushed to the repository. CI/CD Pipeline

Step 1: Pip & Requirements

  • Install pip
  • Install requirements
  • If the installation fails, the build is stopped
  • If the installation passes, the build continues

Step 2: Linting

  • Run Flake8 to check the code quality
  • If Flake8 fails, the build is stopped
  • If Flake8 passes, the build continues

Step 3: Testing

  • Run tests
  • If tests fail, the build is stopped
  • If tests pass, the build continues
  • Tests results are saved in CircleCI

Step 4: Build Docker Image

  • Build the Docker image
  • If the build fails, the build is stopped
  • If the build passes, the build continues
  • The image is tagged with the commit SHA
  • The image is pushed to Docker Hub
  • Required:
    • Pip & Requirements passed
    • Linting passed
    • Testing passed
  • Only on branch: Master

Step 5: Deploy to Heroku

  • Deploy the Docker image to Heroku
  • If the deployment fails, the build is stopped
  • If the deployment passes, the build ends
  • Required:
    • Build Docker Image passed

(back to top)