Continuous Integration/ Continuous Deployment for Odoo (Private hosting)
top of page
  • Writer's pictureTek Siong, Hock

Continuous Integration/ Continuous Deployment for Odoo (Private hosting)

Updated: Nov 24, 2023

By Muhammad Kashif


Odoo.sh has an excellent CI/CD platform and well liked by many Odoo developers. Much regrettably, there isn't much option out there, for private hosting of Odoo EE or Odoo CE.



The following is the typical "Wish-list" for private hosting CI/CO:

1. At least two odoo instances (Development and Production), which could be in the same server (different port) or in the different server. Some complex project may required additional instances for pre-production and so on.


2. To have something similar to odoo.sh that when we push codes to the Odoo Development branch from PyCharm, it will auto push the codes to the Odoo development instance, auto-build and restart the Odoo Development Instance. Developer only need to go to Odoo to upgrade the modules.


3. After merge the development branch to the production branch in the github, it will auto push the codes to the Odoo production instance, auto-build and restart the Odoo Production Instance. Developer only need to go to Odoo to upgrade the modules.



The following are the high level steps. At the bottom of the page, you may download the detailed steps in word document.


Step 1 : Server side public / private key 


The first step is to log in to the Ubuntu server and generate your public/private keys in order for github to access your server for pushing the code and restarting the service . We need the public key content in the .ssh folder of /root/authorized_keys and also in the github ssh keys section under github settings .

Once this is done we can now move to next stage where we will setup the github repo with required settings to work with CI/CD


Step 2 : Github setting 


Goto your github account and open your repository / create new repo 

Goto repository settings tab Setting of repo Secrets & Variables / Actions menu

Variable adding button

Define all the variable with values that will be used in workflow YML script

List of variables that will be used

     **the variables can be defined for each branch. Some variables would be common like ssh_host and ssh_user and ssh_private key etc.

However the working directory and branch name and service name would different for production instance

Next step in github is to add the server public key ( id_rsa.pub) content in the github ssh key section



Step 3 : Github Repo setup in server 


Login to server and goto your dev custom code directory e.g ( odoo_dev/custom/addons )

Make sure the git library installed in server for further operation

If git hub library not installed then enter the command to install it


                   sudo apt-get install git -y


After git install goto your work directory and enter the following command:


            git init


The goal is to attach the github dev branch with the server custom addons folder

Next type this command 


  • git config --global --add safe.directory  /odoo_dev/custom/addons

  • Git checkout -b dev


Get the repo ssh url from git


Then type this command in server custom addons folder


  • git remote add origin ssh_url

e.g

(git remote add origin git@github.com:*********/***.git)


  • Git remote -v

  • Git fetch

  • Git checkout dev

  • Git branch

  • Git pull

  • Now we have to push all the addons to git dev branch

  • Git add .

  • Git commit -m “Initial Upload”

  • Git push

  • You might have to run these 2 command to update server about your identity of git

  • git config --global user.email “name@*******.com

  •  git config --global user.name "Your Name"

Now the local addons content must be uploaded to git dev branch.



Download this for the detail step.

CI_CD Implementation Process
.docx
Download DOCX • 597KB


84 views0 comments
bottom of page