Skip to content

Odoo-react integration with feature branch deployments CI/CD pipeline

License

Notifications You must be signed in to change notification settings

fayezqandeel/odoo-react-cicd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Odoo React CI/CD Feature Branch Pipline

In this repo I'm tryin to implement feature branch deployment, along with odoo/react integration.

How-does-it-work-Future-Processing

Used applications

  • Odoo
  • ReactJS
  • React Redux Store
  • Jenkins
  • Postgres
  • Nginx Proxy
  • Docker
  • Amazon EC2

Installation steps

  1. Install Jenkins
  2. Install these plugins for jenkins [SSH2 Easy Plugin, SSH Agent, Github plugin]
  3. Add you Amazon EC2 credentials by going to jenkins -> credentials -> Stores scoped -> Add Credentials
  4. Kind of credentials should be SSH Username with private key

Screen Shot 2020-01-30 at 10 42 06 PM

  1. Create SSH remote hosts by going to jenkins configuration -> SSH remote hosts section

Screen Shot 2020-01-30 at 10 46 47 PM

  1. Create free style Jenkins Project
  2. Configure the project and connect it to your project repo and set Branches to build to /feature/

Screen Shot 2020-01-30 at 10 48 34 PM

  1. Add build step "Execute shell script on remote host using ssh"
  2. Paste the following bash script
branch=$(echo "$GIT_BRANCH" | sed 's/origin\///g')
tag=$(echo "$GIT_BRANCH" | sed 's/[^0-9]*//g')
echo "branch=$branch, tag=$tag"
git clone  https://[YOUR GITHUB AUTH]@github.com/[YOUR GITHUB REPO PATH URL] $tag
if [ $? -eq 0 ]; then
    cd $tag
    sudo touch .env
    sudo echo "tag=$tag" > .env
    cd frontend
    sudo touch .env
    sudo echo -e  "DANGEROUSLY_DISABLE_HOST_CHECK=true\nREACT_APP_TAG=$tag" > .env
    cd ..
    sudo docker container inspect proxy > /dev/null 2>&1 &&  sudo docker rm -f proxy
   [[ $(sudo docker ps -f "name=proxy" --format '{{.Names}}') == "proxy" ]] || sudo docker run --network='nginx-proxy' --name proxy -d -p 80:80 -v /var/run/docker.sock:/tmp/docker.sock:ro jwilder/nginx-proxy
   [[ $(sudo docker ps -f "name=db" --format '{{.Names}}') == "db" ]] || sudo docker run --network='nginx-proxy' --name db -d -e POSTGRES_PASSWORD=odoo -e POSTGRES_USER=odoo -e POSTGRES_DB=postgres postgres:10
    sudo docker-compose build
    sudo docker-compose up -d
else
    cd $tag
    git pull
    sudo docker-compose down
    sudo docker-compose build
    sudo docker container inspect proxy > /dev/null 2>&1 &&  sudo docker rm -f proxy
   [[ $(sudo docker ps -f "name=proxy" --format '{{.Names}}') == "proxy" ]] || sudo docker run --network='nginx-proxy' --name proxy -d -p 80:80 -v /var/run/docker.sock:/tmp/docker.sock:ro jwilder/nginx-proxy
   [[ $(sudo docker ps -f "name=db" --format '{{.Names}}') == "db" ]] || sudo docker run --network='nginx-proxy' --name db -d -e POSTGRES_PASSWORD=odoo -e POSTGRES_USER=odoo -e POSTGRES_DB=postgres postgres:10
    sudo docker-compose up -d
fi
  1. Save
  2. Login to your github repo settings -> webhooks-> add new webhook-> set hook Payload URL to http[s]://[JenkinsURL]/github-webhook/ and with preference Just the push event.

Screen Shot 2020-01-30 at 11 11 53 PM

  1. Login to your AWS EC2 instance
  2. install docker by running the following
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install docker-compose
  1. create default network for our apps to allow container to communicate
sudo docker network create nginx-proxy
  1. Create branch and push anything to it, please not that branch name should be in this pattern feature|hotfix|bugfix/[JIRA-TICKET-NUMBER] for example feature/LGR-675 or hotfix/LGR-754

  2. In you domain DNS management, create A record to forward all subdomains to AWS EC2 ip instance

now whenever you create new branch in github repo and push somthing it will create two subdomains

  1. Navigate to, [JIRE-TICKET-NUMBER].react.[YOUR DOMAIN] to see react interface, for example 432.react.mydomain.com
  2. Navigate to, [JIRE-TICKET-NUMBER].odoo.[YOUR DOMAIN] to see odoo interface, for example 432.odoo.mydomain.com
  3. create new database in odoo with name [TICKET-NUMBER], for example 432

About

Odoo-react integration with feature branch deployments CI/CD pipeline

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published