mirror of
https://github.com/odoocker/odoocker
synced 2025-11-04 15:19:22 +01:00
readme updates
This commit is contained in:
261
README.md
261
README.md
@@ -1,4 +1,4 @@
|
|||||||
# Setup
|
## Setup
|
||||||
1. Clone the repository:
|
1. Clone the repository:
|
||||||
```
|
```
|
||||||
git clone git@github.com:yhaelopez/odoocker.git
|
git clone git@github.com:yhaelopez/odoocker.git
|
||||||
@@ -7,196 +7,123 @@ git clone git@github.com:yhaelopez/odoocker.git
|
|||||||
```
|
```
|
||||||
cp .env.example .env && cp docker-compose.override.local.yml docker-compose.override.yml
|
cp .env.example .env && cp docker-compose.override.local.yml docker-compose.override.yml
|
||||||
```
|
```
|
||||||
3. Manually add entry to your `hosts` file as below
|
3. Manually add these domains to your `hosts` file
|
||||||
```
|
```
|
||||||
echo '127.0.0.1 erp.odoocker.test' | sudo tee -a /etc/hosts
|
echo '127.0.0.1 erp.odoocker.test' | sudo tee -a /etc/hosts
|
||||||
echo '127.0.0.1 pgadmin.odoocker.test' | sudo tee -a /etc/hosts
|
echo '127.0.0.1 pgadmin.odoocker.test' | sudo tee -a /etc/hosts
|
||||||
```
|
```
|
||||||
- For Windows, go to `C:\Windows\System32\drivers\etc\`, and add this line:
|
- For Windows, go to `C:\Windows\System32\drivers\etc\`, and add:
|
||||||
```
|
```
|
||||||
127.0.0.1 erp.odoocker.test
|
127.0.0.1 erp.odoocker.test
|
||||||
127.0.0.1 pgadmin.odoocker.test
|
127.0.0.1 pgadmin.odoocker.test
|
||||||
```
|
```
|
||||||
|
|
||||||
In order to understand how each environment works, take a look at `odoo/entrypoint.sh`.
|
## The `.env` File
|
||||||
|
The environment variables located in [`.env`](https://github.com/yhaelopez/odoocker/blob/main/.env.example) provide dynamic configurations to Odoo and the project in general.
|
||||||
|
The [`odoo.conf`](https://github.com/yhaelopez/odoocker/blob/main/odoo/odoo.example.conf) file is generated by the [`odoorc.sh`](https://github.com/yhaelopez/odoocker/blob/main/odoo/odoorc.sh) script based on the environment variables.
|
||||||
|
|
||||||
**Default Master Password:** odoo
|
This file is divided in sections, you most likely are going to focus on the `Main Configuration` section. This provides quick access to project and `odoo.conf` variables. The rest of section are container specific variables for different container. (Note: you may find *repeated variables* like `SUPPORT_EMAIL=${SUPPORT_EMAIL}` which interacts with different containers. This is to explicitly denote in the `.env` file that this variable is being shared through those containers.
|
||||||
|
|
||||||
## Fresh Environment
|
Sample `.env` file:
|
||||||
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 -d --build && docker-compose logs -f odoo
|
# Odoo
|
||||||
```
|
ODOO_VERSION=16.0
|
||||||
3. Navigate to the `DOMAIN` in your browser.
|
UPDATE=custom_account_addon
|
||||||
4. Create Database form will be displayed.
|
INIT=
|
||||||
5. Create Fresh DB.
|
LOAD=base,web
|
||||||
6. Stop the Odoo container:
|
WORKERS=2
|
||||||
```
|
|
||||||
docker-compose stop odoo
|
|
||||||
```
|
|
||||||
7. Set [`Local`](https://github.com/yhaelopez/odoocker#local-environment) environment.
|
|
||||||
|
|
||||||
## Restore Environment
|
# Enterprise (GitHub User with access to [Odoo Enterprise](https://github.com/odoo/enterprise) Repo)
|
||||||
This environment will have no database created and it's ready to make an import on the production database.
|
GITHUB_USER=yhaelopez
|
||||||
1. Set `APP_ENV=restore`.
|
GITHUB_ACCESS_TOKEN=ghp_token
|
||||||
2. Run:
|
|
||||||
```
|
|
||||||
docker-compose up -d --build && docker-compose logs -f odoo
|
|
||||||
```
|
|
||||||
3. Navigate to the `DOMAIN` in your browser & Restore the production database
|
|
||||||
4. Stop the Odoo container:
|
|
||||||
```
|
|
||||||
docker-compose stop odoo
|
|
||||||
```
|
|
||||||
5. Set [`Local`](https://github.com/yhaelopez/odoocker#local-environment) environment.
|
|
||||||
|
|
||||||
#### If you are in a production server:
|
# Database
|
||||||
|
ADMIN_PASSWD=odoo
|
||||||
6. Run [`Staging`](https://github.com/yhaelopez/odoocker#staging-environment) environment.
|
DB_HOST=postgres (container or external host)
|
||||||
7. Stop the Odoo container:
|
DB_PORT=5432
|
||||||
```
|
DB_NAME=my-odoo-db
|
||||||
docker-compose stop odoo
|
DB_USER=odoo
|
||||||
```
|
DB_PASSWORD=odoo
|
||||||
8. Run the [`Production`](https://github.com/yhaelopez/odoocker#production-environment) environment.
|
...
|
||||||
|
|
||||||
## Full Environment
|
|
||||||
This environment will initialize a database with `DB_NAME` and install the `INSTALLED_MODULES`.
|
|
||||||
This allows us to have a fresh production database replica.
|
|
||||||
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
|
|
||||||
```
|
|
||||||
4. Navigate to the `DOMAIN` in your browser.
|
|
||||||
5. Log in using the default credentials
|
|
||||||
```
|
|
||||||
Email: admin
|
|
||||||
Password: admin
|
|
||||||
```
|
|
||||||
6. Stop the Odoo container:
|
|
||||||
```
|
|
||||||
docker-compose stop odoo
|
|
||||||
```
|
|
||||||
7. Set [`Local`](https://github.com/yhaelopez/odoocker#local-environment) 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`](https://github.com/yhaelopez/odoocker#fresh-environment), [`Full`](https://github.com/yhaelopez/odoocker#full-environment) or [`Restore`](https://github.com/yhaelopez/odoocker#fresh-environment) environments are run.
|
|
||||||
|
|
||||||
1. Make sure `APP_ENV=local`.
|
|
||||||
2. Make sure `DB_NAME` is set.
|
|
||||||
3. Set `UPDATE=module1,module2,module3`.
|
|
||||||
4. Run:
|
|
||||||
```
|
|
||||||
docker-compose up -d --build && docker-compose logs -f odoo
|
|
||||||
```
|
|
||||||
5. Navigate to the `DOMAIN` in your browser.
|
|
||||||
6. Start coding!
|
|
||||||
7. Any change you make to your packages, run:
|
|
||||||
```
|
|
||||||
docker-compose restart odoo && docker-compose logs -f odoo
|
|
||||||
```
|
|
||||||
- If you need to change a .env variable, run:
|
|
||||||
```
|
|
||||||
docker-compose up -d --build && docker-compose logs -f odoo
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Debug Environment
|
### Environment-based actions:
|
||||||
This environment will bring up Odoo with `debugpy` library.
|
[`odoo/entrypoint.sh`](https://github.com/yhaelopez/odoocker/blob/main/odoo/entrypoint.sh) file is the gateway for our Odoo container. Depending on the `APP_ENV` and the rest of the environment variables, it determines how to start the Odoo service (like local, testing, production, etc.) with different configurations.
|
||||||
It's recommended to use this environment after [`Fresh`](https://github.com/yhaelopez/odoocker#fresh-environment), [`Full`](https://github.com/yhaelopez/odoocker#full-environment) or [`Restore`](https://github.com/yhaelopez/odoocker#fresh-environment) environments are run.
|
|
||||||
It works the same exact way as [`Local`](https://github.com/yhaelopez/odoocker#local-environment), since it respects any change in `.env` file.
|
|
||||||
|
|
||||||
1. Make sure `APP_ENV=debug`.
|
All environments receive the whole `.env` file variables. However, some of them have fixed command-line variables specific for each environment. For example, some of them may have `--limit-time-cpu=3600` because some databases are so big that may require a huge amount of seconds. Setting 1 hour ensures any DB can be imported (this can change as needed in the specific project). These values in command line overwrite the ones in the `.env` file.
|
||||||
2. Make sure `DB_NAME` is set.
|
|
||||||
3. Set `UPDATE=module1,module2,module3`.
|
To bring up most of the following environments run `docker-compose down && docker-compose up -d --build && docker-compose logs odoo`. Here are the description of each of them.
|
||||||
4. Run:
|
|
||||||
```
|
#### *Fresh* or *Restore*
|
||||||
docker-compose up -d --build && docker-compose logs -f odoo
|
This environment (`APP_ENV=fresh` or `APP_ENV=restore`) will have no database created and it's perfect for setting up a fresh database instance or restoring a production database.
|
||||||
```
|
|
||||||
5. Navigate to the `DOMAIN` in your browser.
|
#### *Local*:
|
||||||
6. Mark breakpoints through the code.
|
- This environment will strictly follow the `.env` variables with no command-line overwrites. You most likely be using this regularly.
|
||||||
7. Start VSCode Debugger
|
- Use `DEV_MODE=reload,qweb` to activate hot reload when changing `python` and `xml` files.
|
||||||
8. Start debugging!
|
- If you prefer to update the packages everytime you restart Odoo container, you can set `UPDATE=module1,module2,module3`.
|
||||||
9. Continue coding as if you were in [`Local`](https://github.com/yhaelopez/odoocker#local-environment)
|
|
||||||
|
### *Debug*:
|
||||||
|
This environment works same way as local, but it starts Odoo using the `debugpy` library. Thanks to our [`.vscode/launch.json`](https://github.com/yhaelopez/odoocker/blob/main/.vscode/launch.json), if you are using Visual Studio Code, you start a Debugger session and the container will be aware of your breakpoints and stop wherever you need. This is my favorite environment to work since I use the debugger a lot while developing.
|
||||||
|
|
||||||
|
#### *Testing*:
|
||||||
|
- This environment is specific for running tests (and will be included in a CI/CD pipeline in a future version). - It help us test the modules we are developing to ensure a safe deployment.
|
||||||
|
- A `test_DB_NAME` database is automagically created
|
||||||
|
- The `ADDONS_TO_TEST=addon_1` are installed in that fresh DB.
|
||||||
|
- Use `TEST_TAGS=test_tag_1` to filter your tests.
|
||||||
|
|
||||||
|
*NOTE: Avoid running tests without tags*; this will trigger tests in all installed addons and we don't want this. For now let's assume Odoo Community & Enterprise tests passed and only focus on the things you need to test.
|
||||||
|
|
||||||
|
#### *Full*:
|
||||||
|
This environment (`APP_ENV=full`) will install the `INIT` modules in a new or existing `DB_NAME`. This allows us to have a fresh production database replica.
|
||||||
|
|
||||||
|
#### *Staging*:
|
||||||
|
This environment sets `UPDATE=all`; this allows us to *update* all installed addons at once.
|
||||||
|
It also allows to install new packages before the upgrade through `INIT`.
|
||||||
|
|
||||||
|
It's highly recommended to use this command to run this environment
|
||||||
|
|
||||||
## Testing Environment
|
|
||||||
This environment will help us test the modules we are developing to ensure a safe deployment.
|
|
||||||
A `test_*` database is automagically created, addons to test get installed, test are filtered and run by their tags.
|
|
||||||
Odoo will stop after running the tests.
|
|
||||||
1. Set `APP_ENV=testing`.
|
|
||||||
2. Set `ADDONS_TO_TEST=addon_1,addon_2`.
|
|
||||||
3. Set `TEST_TAGS=test_tag_1,test_tag_2` to fitler tests.
|
|
||||||
4. Run:
|
|
||||||
```
|
```
|
||||||
docker-compose down && docker-compose up -d --build && docker-compose logs -f odoo
|
docker-compose down && git pull && docker-compose pull && docker-compose build --no-cache && docker-compose up -d && docker-compose logs -f odoo
|
||||||
```
|
```
|
||||||
|
|
||||||
## Staging Environment
|
This will `pull` the latest *Odoo Community, Enterprise, Extra and Custom addons*, basically, ot upgrades the whole Odoo instance to the newest. Additionally, it will also pull the latest images of the other containers in this project.
|
||||||
This environment performs 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 `INIT`
|
**NOTE: Do not bring down & up again unless you want to perform a whole update again.**
|
||||||
1. Set `APP_ENV=staging`
|
|
||||||
2. Set `DB_NAME` to the desired one.
|
#### *Production*:
|
||||||
3. Set `INIT` if there are any.
|
This is the production environment (`APP_ENV=production`). It ensures no demo data is loaded and debugging is turned off. It also brings up the `Let's Encrypt` container, so you won't worry about `SSL Certificates` anymore! Some `.env` variables are overwritten in this setup.
|
||||||
5. Run
|
|
||||||
|
- Take down previous setup containers
|
||||||
```
|
```
|
||||||
git pull && docker-compose down && docker-compose pull && docker-compose build --no-cache && docker-compose up -d && docker-compose logs -f odoo
|
docker-compose down
|
||||||
```
|
```
|
||||||
7. Check Odoo continues to work as expected.
|
- Repace the `docker-compose.override.yml` with `docker-compose.override.production.yml` to bring `Let's Encrypt` container.
|
||||||
8. Change environment immediatly after finish testing.
|
|
||||||
|
|
||||||
**Do not bring down & up again unless you want to perform a whole update again.**
|
|
||||||
|
|
||||||
## Production Environment
|
|
||||||
This environment has a preset of settings to work in production. Some `.env` variables won't work because are overwritten in the odoo command.
|
|
||||||
|
|
||||||
Let's imagine we are migrating a database from another server.
|
|
||||||
|
|
||||||
1. Set `APP_ENV=production`
|
|
||||||
2. Set prod `DB_NAME`.
|
|
||||||
3. Set prod `DB_PASSWORD`.
|
|
||||||
4. Set prod `ADMIN_PASSWD`.
|
|
||||||
5. Set prod `DOMAIN` (make sure DNS are pointing to your instance).
|
|
||||||
6. Run [`Restore`](https://github.com/yhaelopez/odoocker#restore-environment) environment
|
|
||||||
7. Run [`Staging`](https://github.com/yhaelopez/odoocker#staging-environment) environment.
|
|
||||||
8. Repace the `docker-compose.override.yml` with `docker-compose.override.production.yml`.
|
|
||||||
This will bring Let's Encrypt (Nginx-Proxy/Acme-Companion) container
|
|
||||||
```
|
```
|
||||||
cp docker-compose.override.production.yml docker-compose.override.yml
|
cp docker-compose.override.production.yml docker-compose.override.yml
|
||||||
```
|
```
|
||||||
9. Rebuild the containers
|
- Rebuild the containers
|
||||||
```
|
```
|
||||||
docker-compose down && docker-compose up -d --build && docker-compose logs odoo
|
docker-compose up -d --build && docker-compose logs odoo
|
||||||
```
|
```
|
||||||
|
|
||||||
### Pro(d) Tips
|
## Pro(d) Tips
|
||||||
The following tips will enhance your developing and production experience.
|
The following tips will enhance your developing and production experience.
|
||||||
|
|
||||||
#### Define the following aliases:
|
#### Define the following aliases:
|
||||||
```
|
```
|
||||||
alias odoo='cd odoocker'
|
alias odoo='cd odoocker'
|
||||||
|
|
||||||
alias hard-deploy='git pull && docker-compose down && docker-compose pull && docker-compose build --no-cache && docker-compose up -d && docker-compose logs -f odoo'
|
alias hard-deploy='docker-compose down && git pull && docker-compose pull && docker-compose build --no-cache && docker-compose up -d && docker-compose logs -f odoo'
|
||||||
|
|
||||||
alias deploy='git pull && docker-compose down && docker-compose pull && docker-compose build && docker-compose up -d && docker-compose logs -f --tail 2000 odoo'
|
alias deploy='docker-compose down && git pull && docker-compose up -d --build && docker-compose logs -f --tail 2000 odoo'
|
||||||
|
|
||||||
alias soft-deploy='git pull && docker-compose down && docker-compose up -d --build && docker-compose logs -f --tail 2000 odoo'
|
|
||||||
|
|
||||||
alias logs='docker-compose logs -f --tail 2000 odoo'
|
alias logs='docker-compose logs -f --tail 2000 odoo'
|
||||||
```
|
```
|
||||||
|
|
||||||
#### NEVER run
|
#### NEVER run docker-compose down **-v** in Production
|
||||||
```
|
|
||||||
docker-compose down **-v**
|
|
||||||
```
|
|
||||||
...without having a tested backed up database
|
...without having a tested backed up database
|
||||||
|
|
||||||
Have in mind that dropping volumes will destroy DB data, Odoo Conf & Filestore, Let's Encrypt certificates, and more!
|
Have in mind that dropping volumes will destroy DB data, Odoo Conf & Filestore, *Let's Encrypt certificates, and more!*. If you execute this command several times in `prod` in a short period of time, you may reach the `Let's Encrypt` certificates limit and Odoocker won't be able to generate new ones after **several hours**.
|
||||||
|
|
||||||
Also, if you do this process several times in a short period of time, you may reach `Let's Encrypt` certificates limits and won't be able to generate new ones after **several hours**.
|
|
||||||
|
|
||||||
#### Colorize your branches
|
#### Colorize your branches
|
||||||
Add the following to `~/.bashrc`
|
Add the following to `~/.bashrc`
|
||||||
@@ -216,7 +143,17 @@ fi
|
|||||||
unset color_prompt force_color_prompt
|
unset color_prompt force_color_prompt
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Creating new Odoo Addons
|
#### Odoo Shell
|
||||||
|
1. Log into the odoo container
|
||||||
|
```
|
||||||
|
docker-compose exec odoo bash
|
||||||
|
```
|
||||||
|
2. Start Odoo shell running:
|
||||||
|
```
|
||||||
|
odoo shell --http-port=8071
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Odoo Scaffold
|
||||||
1. Log into the odoo container
|
1. Log into the odoo container
|
||||||
```
|
```
|
||||||
docker-compose exec -u root odoo
|
docker-compose exec -u root odoo
|
||||||
@@ -231,20 +168,10 @@ odoo scaffold <addon_name>
|
|||||||
```
|
```
|
||||||
- The new addon will be available in the `odoo/custom_addons` folder in this project.
|
- The new addon will be available in the `odoo/custom_addons` folder in this project.
|
||||||
|
|
||||||
#### Using Odoo Shell
|
## DB Connection
|
||||||
1. Log into the odoo container
|
|
||||||
```
|
|
||||||
docker-compose exec odoo bash
|
|
||||||
```
|
|
||||||
2. Start Odoo shell running:
|
|
||||||
```
|
|
||||||
odoo shell --http-port=8071
|
|
||||||
```
|
|
||||||
|
|
||||||
# DB Connection
|
|
||||||
- Any other Postgres Database Manager con connect to the DB using `.env` credentials.
|
- Any other Postgres Database Manager con connect to the DB using `.env` credentials.
|
||||||
|
|
||||||
## PgAdmin Container
|
#### PgAdmin Container
|
||||||
- This project comes with a PgAdmin container which is loaded only in `docker-compose.override.pgadmin.yml`.
|
- This project comes with a PgAdmin container which is loaded only in `docker-compose.override.pgadmin.yml`.
|
||||||
In order to manage DB we provide a pgAdmin container.
|
In order to manage DB we provide a pgAdmin container.
|
||||||
In order to bring this up, simply run:
|
In order to bring this up, simply run:
|
||||||
@@ -258,7 +185,7 @@ docker-compose -f docker-compose.yml -f docker-compose.override.yml -f docker-co
|
|||||||
|
|
||||||
If your instance has pgAdmin, make sure you adapt this to your aliases.
|
If your instance has pgAdmin, make sure you adapt this to your aliases.
|
||||||
|
|
||||||
# Deployment Process
|
## Deployment Process
|
||||||
Note: the deployment process is easier & faster with aliases.
|
Note: the deployment process is easier & faster with aliases.
|
||||||
|
|
||||||
1. Backup the production Databases from `/web/database/manager`.
|
1. Backup the production Databases from `/web/database/manager`.
|
||||||
@@ -290,9 +217,5 @@ odoo
|
|||||||
```
|
```
|
||||||
git pull origin main
|
git pull origin main
|
||||||
```
|
```
|
||||||
6. Set [`Staging`](https://github.com/yhaelopez/odoocker#staging-environment) environment
|
6. Set `Staging` environment
|
||||||
7. Set `APP_ENV=production`
|
7. Set `Production` environment
|
||||||
8. Take down the containers, pull the latest images from docker hub, and rebuild the containers.
|
|
||||||
```
|
|
||||||
docker-compose down && docker-compose up -d --build && docker-compose logs -f odoo
|
|
||||||
```
|
|
||||||
|
|||||||
@@ -18,9 +18,9 @@ case "$1" in
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ${APP_ENV} = 'full' ] ; then
|
if [ ${APP_ENV} = 'full' ] ; then
|
||||||
echo odoo --config ${ODOO_RC} --database=${DB_NAME} --init=${INSTALLED_MODULES} --update= --load=${SERVER_WIDE_MODULES} --log-handler=${LOG_HANDLER} --log-level=${LOG_LEVEL} --load-language=${LOAD_LANGUAGE} --max-cron-threads=${MAX_CRON_THREADS} --limit-time-cpu=3600 --limit-time-real=7200 --workers=0 --without-demo=all
|
echo odoo --config ${ODOO_RC} --database=${DB_NAME} --init=${INIT} --update= --load=${SERVER_WIDE_MODULES} --log-handler=${LOG_HANDLER} --log-level=${LOG_LEVEL} --load-language=${LOAD_LANGUAGE} --max-cron-threads=${MAX_CRON_THREADS} --limit-time-cpu=3600 --limit-time-real=7200 --workers=0 --without-demo=all
|
||||||
|
|
||||||
exec odoo --config ${ODOO_RC} --database=${DB_NAME} --init=${INSTALLED_MODULES} --update= --load=${SERVER_WIDE_MODULES} --log-handler=${LOG_HANDLER} --log-level=${LOG_LEVEL} --load-language=${LOAD_LANGUAGE} --max-cron-threads=${MAX_CRON_THREADS} --limit-time-cpu=3600 --limit-time-real=7200 --workers=0 --without-demo=all
|
exec odoo --config ${ODOO_RC} --database=${DB_NAME} --init=${INIT} --update= --load=${SERVER_WIDE_MODULES} --log-handler=${LOG_HANDLER} --log-level=${LOG_LEVEL} --load-language=${LOAD_LANGUAGE} --max-cron-threads=${MAX_CRON_THREADS} --limit-time-cpu=3600 --limit-time-real=7200 --workers=0 --without-demo=all
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ${APP_ENV} = 'local' ] ; then
|
if [ ${APP_ENV} = 'local' ] ; then
|
||||||
|
|||||||
Reference in New Issue
Block a user