Yhael S a1afed2257 readme
2023-04-19 14:33:27 -05:00
2023-04-19 14:27:50 -05:00
2023-04-19 14:27:50 -05:00
2023-04-19 14:27:50 -05:00
2023-04-19 14:27:50 -05:00
2023-04-19 14:27:50 -05:00
2023-04-19 14:27:50 -05:00
2023-04-19 14:27:50 -05:00
2023-04-19 14:27:50 -05:00
2023-04-19 14:27:50 -05:00
2023-04-19 14:33:27 -05:00

Setup

  1. Clone the repository:
git clone git@github.com:yhaelopez/odoocker.git
  1. Copy the .env.example and docker-compose.override.local.yml
cp .env.example .env && cp docker-compose.override.local.yml docker-compose.override.yml
  1. Manually add entry to your hosts file 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.

  1. Make sure APP_ENV=fresh.
  2. Run
docker-compose up --build -d && docker-compose logs -f odoo
  1. Navigate to the DOMAIN in your browser.
  2. Create Database form will be displayed.
  3. Create Fresh DB.
  4. Stop the Odoo container:
docker-compose stop odoo
  1. Set Local environment.

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.

  1. Make sure APP_ENV=full.
  2. Make sure DB_NAME=odoo or whatever name you want.
  3. Run
docker-compose up -d --build && docker-compose logs -f odoo
  1. Navigate to the DOMAIN in your browser.
  2. Log in using the default credentials
Email: admin
Password: admin
  1. Stop the Odoo container:
docker-compose stop odoo
  1. Set Local environment.

Restore Environment

This environment will have no database created and it's ready to make an import on the production database.

  1. Set APP_ENV=restore.
  2. Run:
docker-compose up --build -d && docker-compose logs -f odoo
  1. Navigate to the DOMAIN in your browser & Restore the production database
  2. Stop the Odoo container:
docker-compose stop odoo
  1. Set Local environment.

--- If you are in a production server:

  1. Set Staging environment.
  2. Stop the Odoo container:
docker-compose stop odoo
  1. Run the Production environment.

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.

  1. Make sure APP_ENV=local.
  2. Make sure DB_NAME is set.
  3. Set ADDONS_TO_UPDATE=module1,module2,module3.
  4. Run:
docker-compose up --build -d odoo && docker-compose logs -f odoo
  1. Navigate to the DOMAIN in your browser.
  2. Start coding!
  3. 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
  1. Any time you add a new addon to ADDONS_TO_UPDATE re-run last step

Additional Local Help

Creating new Odoo Addons

  1. Log into the odoo container
docker-compose exec -u root odoo
  1. Navigate to custom addons folder inside the container
cd /usr/lib/python3/dist-packages/odoo/custom-addons
  1. Create new addons running:
odoo scaffold <addon_name>
  • The new addon will be available in the odoo/custom_addons folder in this project.

Using Odoo Shell

  1. Log into the odoo container
docker-compose exec odoo bash
  1. Start Odoo shell running:
odoo shell --http-port=8071
  1. Connect to database through any Postgres Database Manager using localhost and the .env credentials

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.

  1. Replace docker-compose.override.yml with docker-compose.override.testing.yml This 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
  1. Clone Production Database as test_${DB_NAME}.
  2. Set APP_ENV=testing.
  3. Set DB_NAME=test_${DB_NAME} or whatever db you set before.
  4. 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

  1. Set APP_ENV=staging
  2. Set DB_NAME to the desired one.
  3. Set ADDONS_TO_INSTALL if there are any.
  4. Run
git pull && docker-compose down && docker-compose pull && docker-compose build --no-cache && docker-compose up -d && docker-compose logs -f odoo
  1. Check Odoo continues to work as expected.
  2. Change environment immediatly after finish testing.

Do not bring down & up again unless you want to perform the whole update again.

Production

  1. Set APP_ENV=production
  2. Set prod DB_NAME.
  3. Set prod DB_PASSWORD.
  4. Set prod ADMIN_PASSWD.
  5. Set prod DOMAIN.
  6. Setup Fresh environment
  7. Setup Staging environment.
  8. Repace the docker-compose.override.yml with the production one. This will bring Let's Encrypt (Nginx-Proxy/Acme-Companion) container
cp docker-compose.override.production.yml docker-compose.override.yml
  1. Rebuild the containers
docker-compose down && docker-compose up -d --build && docker-compose logs odoo

Deployment

  1. Backup the production Databases from /web/database/manager.
  2. Run
sudo apt update && sudo apt upgrade -y
  • If packages are kept, install them
sudo apt install <kept packages>
  1. Restart the server
sudo reboot
  • Make sure there are no more upgrades or possible kept packages
sudo apt update && sudo apt upgrade -y
  1. Go to the project folder in /home/ubuntu or (~)
cd ~/odoocker
  1. Pull the latest main branch changes.
git pull origin main
  1. Set Staging environment
  2. Make sure everything continues to work as expected.
  3. Set APP_ENV=production
  4. 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
Description
No description provided
Readme 285 KiB
Languages
Shell 69.5%
Dockerfile 20%
Python 10.5%