Git Product home page Git Product logo

odoo-react-cicd's Introduction

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

odoo-react-cicd's People

Contributors

fayezqandeel avatar

Watchers

James Cloos avatar

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.