Setup
- Clone the repository:
git clone git@github.com:yhaelopez/odoocker.git
- Copy the
.env.exampleanddocker-compose.override.local.yml
cp .env.example .env && cp docker-compose.override.local.yml docker-compose.override.yml
- Manually add entry to your
hostsfile as below (Local)
echo '127.0.0.1 erp.odoo.test' | sudo tee -a /etc/hosts
echo '127.0.0.1 pgadmin.odoo.test' | sudo tee -a /etc/hosts
- For Windows, go to
C:\Windows\System32\drivers\etc\, and add this line:
127.0.0.1 erp.odoo.test
127.0.0.1 pgadmin.odoo.test
In order to understand how each environment works, take a look at odoo/entrypoint.sh.
Master Password: odoo
Fresh Environment
This environment will have no database created.
The env.example is ready for this stage, no modifications are needed on .env.
- Make sure
APP_ENV=fresh. - Run
docker-compose up --build -d && docker-compose logs -f odoo
- Navigate to the
DOMAINin your browser. - Create Database form will be displayed.
- Create Fresh DB.
- Stop the Odoo container:
docker-compose stop odoo
- Set
Localenvironment.
Full Environment
This environment will initialize a database with DB_NAME and install the INSTALLED_MODULES.
This allows us to have a fresh database will all modules installed in production.
- Make sure
APP_ENV=full. - Make sure
DB_NAME=odooor whatever name you want. - Run
docker-compose up -d --build && docker-compose logs -f odoo
- Navigate to the
DOMAINin your browser. - Log in using the default credentials
Email: admin
Password: admin
- Stop the Odoo container:
docker-compose stop odoo
- Set
Localenvironment.
Restore Environment
This environment will have no database created and it's ready to make an import on the production database.
- Set
APP_ENV=restore. - Run:
docker-compose up --build -d && docker-compose logs -f odoo
- Navigate to the
DOMAINin your browser & Restore the production database - Stop the Odoo container:
docker-compose stop odoo
- Set
Localenvironment.
--- If you are in a production server:
- Set
Stagingenvironment. - Stop the Odoo container:
docker-compose stop odoo
- Run the
Productionenvironment.
Local Environment
This environment will help us install / update the specific modules we are working on.
It's recommended to use this environment after Fresh, Full or Restore environments are run.
- Make sure
APP_ENV=local. - Make sure
DB_NAMEis set. - Set
ADDONS_TO_UPDATE=module1,module2,module3. - Run:
docker-compose up --build -d odoo && docker-compose logs -f odoo
- Navigate to the
DOMAINin your browser. - Start coding!
- Any change you make to your packages, run:
docker-compose restart odoo && docker-compose logs -f odoo
- If you think your package is not being updated, run:
docker-compose up --build -d odoo && docker-compose logs -f odoo
- Any time you add a new addon to
ADDONS_TO_UPDATEre-run last step
Additional Local Help
Creating new Odoo Addons
- Log into the odoo container
docker-compose exec -u root odoo
- Navigate to custom addons folder inside the container
cd /usr/lib/python3/dist-packages/odoo/custom-addons
- Create new addons running:
odoo scaffold <addon_name>
- The new addon will be available in the
odoo/custom_addonsfolder in this project.
Using Odoo Shell
- Log into the odoo container
docker-compose exec odoo bash
- Start Odoo shell running:
odoo shell --http-port=8071
- Connect to database through any Postgres Database Manager using
localhostand the.envcredentials
Testing Environment (Work in progress...) DO NOT USE
This environment will help us test all modules to ensure a safe deployment. It's recommneded to use this environment after importing production database in a Fresh environment.
- Replace
docker-compose.override.ymlwithdocker-compose.override.testing.ymlThis will set up the Odoo container will all the packages installed needed to run the tests.
cp docker-compose.override.testing.yml docker-compose.override.yml
- Clone Production Database as
test_${DB_NAME}. - Set
APP_ENV=testing. - Set
DB_NAME=test_${DB_NAME}or whatever db you set before. - Run:
docker-compose down && docker-compose pull && docker-compose build --no-cache && docker-compose up -d && docker-compose logs -f odoo
Staging
This environment allows us to perfom a full update on all installed modules to test if they all can be upgraded at once.
This also allows to install new packages through ADDONS_TO_INSTALL
- Set
APP_ENV=staging - Set
DB_NAMEto the desired one. - Set
ADDONS_TO_INSTALLif there are any. - Run
git pull && docker-compose down && docker-compose pull && docker-compose build --no-cache && docker-compose up -d && docker-compose logs -f odoo
- Check Odoo continues to work as expected.
- Change environment immediatly after finish testing.
Do not bring down & up again unless you want to perform the whole update again.
Production
- Set
APP_ENV=production - Set prod
DB_NAME. - Set prod
DB_PASSWORD. - Set prod
ADMIN_PASSWD. - Set prod
DOMAIN. - Setup
Freshenvironment - Setup
Stagingenvironment. - Repace the
docker-compose.override.ymlwith the production one. This will bring Let's Encrypt (Nginx-Proxy/Acme-Companion) container
cp docker-compose.override.production.yml docker-compose.override.yml
- Rebuild the containers
docker-compose down && docker-compose up -d --build && docker-compose logs odoo
Deployment
- Backup the production Databases from
/web/database/manager. - Run
sudo apt update && sudo apt upgrade -y
- If packages are kept, install them
sudo apt install <kept packages>
- Restart the server
sudo reboot
- Make sure there are no more upgrades or possible kept packages
sudo apt update && sudo apt upgrade -y
- Go to the project folder in /home/ubuntu or (~)
cd ~/odoocker
- Pull the latest
mainbranch changes.
git pull origin main
- Set Staging environment
- Make sure everything continues to work as expected.
- Set
APP_ENV=production - Take down the containers, pull the latest images from docker hub, and rebuild the containers.
docker-compose down && docker-compose pull && docker-compose build --no-cache && docker-compose up -d && docker-compose logs -f odoo