![](https://github.com/Maiphuongthao/MaiPhuongThao_P13_2023/raw/master/static/assets/img/circleci-icon.svg)
Menu
- General informations
- Prerequisite list
- Installation
- Develop the site locally
- Admin
- Production
General informations
Orange County Lettings is a start-up real estate company in the US.
The but is to improve the base code from their github Python-OC-lettings_FR, then to the deployment.
For more information, check out Read The Docs
Basic demands:
Technical aspects
- Organise the project to 2 diffirents apps: lettings & profiles to improve the modular architecture
- Fill the new tables with informations of old tables by using Django migrations
- Organise correct templates files to correct apps
- Rename request html templates
- Clear all unecessary files from project folder
Reduce several diver problems
- Several reported linting errors need to be fixed. Do not change the information from setup.cfg
- Django admin shows error for Address model , plural version
- Create 404 and 500 pafe to ensure when there is needed
- Correct docstring comments
- Create tests for projects and apps with coverage >=80%
Monitoring and tracking errors with Sentry
- Build un monitoring system by using Sentry
- Build logging to project to survey the errors
Pipeline CI/CD wtih CircleCI and deploy the project to AWS EC2 instance
- Compilation: Test the linting and project tests
- Containerisation: Build and push image with Docker and Docker-compose
- Deployment: Deploy the site to AWS EC2
Prerequisite list
- Compte GitHub with reading access to this repository
- Git CLI
- SQLite3 CLI
- Python 3.6 or higher
- Django 3.0
- Docker 24.0
- Docker-compose 2.22.0
- AWS CE2
- Sentry
Installation
Clone the repository
git clone https://github.com/Maiphuongthao/MaiPhuongThao_P13_2023.git
cd MaiPhuongThao_P13_2023
Create variable environnement and install the requirements
- The programme uses multiples modules and libraries which are noted in requirements.txt to be installed.
- It's recommended to create the variable environnement to install any module
Windows :
python -m venv env
env\scripts\activate
pip install -r requirements.txt
MacOS et Linux :
python3 -m venv env
source env/bin/activate
pip install -r requirements.txt
Protect the secret informations
touch .env
to create an env file
- In side the .env file copy and add values to three variables that you found in .evn.example
Develop the site locally
cd MaiPhuongThao_P13_2023
source venv/bin/activate
launch the site
Without docker
python manage.py runserver
- Aller sur
http://localhost:8000
dans un navigateur.
With docker
Have a look at the tests and tests'scoverage
Linting
Database
sqlite3
to open sqlite3 shell
.open oc-lettings-site.sqlite3
to connect to database
.tables
to show tables in db
pragma table_info(profiles_profile);
to show profile's columns
select user_id, favorite_city from profiles_profile where favorite_city like 'B%';
to launch a request to profile table,
.quit
to quit the shell
Admin
- Connect to
http://localhost:8000/admin
page
- User
admin
, mot de passe Abc1234!
Production
- This project is made in production mode so there is alread .circleci folder and config.yml file
Setup AWS EC2
- Create an AWS account and an EC2 instance by following here
- Connect to instance then install docker and docker-compose here
- create access key id and secret key by following here
Setup CircleCI/CD
-
Create an account circleci then connect to this project via githup, following instruction here
-
Remember to use the circle folder and config.yml file of the project
-
Add environnement variables, following instruction here:
Key |
Value |
DOCKER_LOGIN |
Docker Hub Id |
DOCKER_PASSWORD |
Docker Hub password |
DEBUG |
False |
SECRET_KEY |
Django secret key |
SENTRY_DSN |
Sentry DSN |
AWS_ACCESS_KEY_ID |
AWS access key id |
AWS_SECRET_ACCESS_KEY |
AWS secret key of access key |
AWS_DEFAULT_REGION |
aws default region |
SG_ID |
sg of aws ec2 instance security group |
SSH_HOST |
aws ec2 instance IP public or DNS public |
SSH_USER |
aws ec2 instance user |
Deployment
This project is using Trunk-base development as a version control management practice: one master branch, one development branch & Circleci pipeline
- Testing: After each commit on addition branch ( developement or else), the tests will be executed automatically
- Build image: When the tests are passed and the branch is merged to master, docker contener and image will be created then sent to Docker Hub
- Deploy: aws cli will be installed with circleci, then it will add circleci ingress to security group to connect to aws ec2 instance, from there the docker which is installed in the instance will copy docker-compose file then search for latest image to deploy
Here we have the website fully deployed to an ip public.