diff --git a/.env.example b/.env.example index 8256912..53e014b 100644 --- a/.env.example +++ b/.env.example @@ -1,38 +1,74 @@ #--------------------------# # Main Configuration # #--------------------------# -APP_ENV=fresh -ADDONS_TO_UPDATE= -ADDONS_TO_INSTALL= +# Project +PROJECT_NAME=odoocker +DOMAIN=erp.odoocker.test +SUPPORT_EMAIL=mail@example.com +CORS_ALLOWED_DOMAIN="'http://external-domain.test'" +# App +APP_ENV=fresh +DEV_MODE=reload,qweb + +# Odoo +ODOO_VERSION=14.0 +UPDATE= +INIT= +LOAD=base,web +WORKERS=1 + +# Enterprise +GITHUB_USER= +GITHUB_ACCESS_TOKEN= + +# Database +ADMIN_PASSWD=odoo +DB_HOST=postgres +DB_PORT=5432 DB_NAME=odoo DB_USER=odoo DB_PASSWORD=odoo +DB_SSLMODE=prefer +DB_MAXCONN=64 +DB_TEMPLATE=unaccent_template +UNACCENT=True +LIST_DB=True +DBFILTER=.* +LOAD_LANGUAGE= +# Logging LOG_LEVEL=info LOG_HANDLER="[':INFO']" +# PgAdmin +PGADMIN_DOMAIN=pgadmin.odoocker.test +PGADMIN_PASSWORD=odoo + +# Testing +TEST_ENABLE=False +TEST_TAGS= +ADDONS_TO_TEST= + +# Mail SMTP_SERVER= SMTP_PORT=25 SMTP_SSL= SMTP_USER= SMTP_PASSWORD= EMAIL_FROM= - -ADMIN_PASSWD=odoo -DOMAIN=erp.odoo.test -PGADMIN_DOMAIN=pgadmin.odoo.test -PGADMIN_PASSWORD=${DB_PASSWORD} -LOAD_LANGUAGE=en_US -DEV_MODE=False -DEBUG_MODE=False +FROM_FILTER= #------------------------------# # Project Configurations # #------------------------------# -PROJECT_NAME=odoocker +PROJECT_NAME=${PROJECT_NAME} DOMAIN=${DOMAIN} -SUPPORT_EMAIL=example@mail.com +SUPPORT_EMAIL=${SUPPORT_EMAIL} +ODOO_VERSION=${ODOO_VERSION} +GITHUB_USER=${GITHUB_USER} +GITHUB_ACCESS_TOKEN=${GITHUB_ACCESS_TOKEN} +ENTERPRISE_REPO=https://${GITHUB_USER}:${GITHUB_ACCESS_TOKEN}@github.com/odoo/enterprise.git #------------# # Odoo # @@ -46,33 +82,37 @@ REPORTGZ=False WEBSOCKET_KEEP_ALIVE_TIMEOUT=3600 WEBSOCKET_RATE_LIMIT_BURST=10 WEBSOCKET_RATE_LIMIT_DELAY=0.2 + # Custom paths COMMUNITY_ADDONS=${ROOT_PATH}/addons ENTERPRISE_ADDONS=${ROOT_PATH}/enterprise EXTRA_ADDONS=${ROOT_PATH}/extra-addons CUSTOM_ADDONS=${ROOT_PATH}/custom-addons +LOG_PATH=/var/log/odoo/odoo.log +DEBUG_PATH=/usr/bin/odoo # Server startup config ODOO_RC=/etc/odoo/odoo.conf SAVE=False -INIT=${ADDONS_TO_INSTALL} -UPDATE=${ADDONS_TO_UPDATE} +INIT=${INIT} +UPDATE=${UPDATE} DEMO=False WITHOUT_DEMO=all -IMPORT_PARTIAL= +IMPORT_PARTIAL=False PIDFILE= ADDONS_PATH=${COMMUNITY_ADDONS},${ENTERPRISE_ADDONS},${EXTRA_ADDONS},${CUSTOM_ADDONS} UPGRADE_PATH= -SERVER_WIDE_MODULES=base,web +SERVER_WIDE_MODULES=${LOAD} DATA_DIR=/var/lib/odoo # HTTP HTTP_INTERFACE=0.0.0.0 +XMLRPCS_INTERFACE=${HTTP_INTERFACE} +DEBUG_INTERFACE=${HTTP_INTERFACE} HTTP_PORT=8069 -XMLRPCS_INTERFACE=0.0.0.0 +DEBUG_PORT=8070 XMLRPCS_PORT=8071 -GEVENT_PORT=8072 -LONGPOLLING_PORT=0 +LONGPOLLING_PORT=8072 HTTP_ENABLE=True XMLRPCS=True PROXY_MODE=True @@ -80,22 +120,22 @@ X_SENDFILE=False # Testing TEST_FILE=False -TEST_ENABLE=False -TEST_TAGS=None +TEST_ENABLE=${TEST_ENABLE} +TEST_TAGS=${TEST_TAGS} SCREENCASTS=None SCREENSHOTS=/tmp/odoo_tests # Logging LOGFILE= SYSLOG=False -LOG_HANDLER="[':INFO']" +LOG_HANDLER=${LOG_HANDLER} LOG_DB=False LOG_DB_LEVEL=info -LOG_LEVEL=info +LOG_LEVEL=${LOG_LEVEL} # Email EMAIL_FROM=${EMAIL_FROM} -FROM_FILTER=False +FROM_FILTER=${FROM_FILTER} SMTP_SERVER=${SMTP_SERVER} SMTP_PORT=${SMTP_PORT} SMTP_SSL=${SMTP_SSL} @@ -109,11 +149,11 @@ DB_NAME=${DB_NAME} DB_USER=${DB_USER} DB_PASSWORD=${DB_PASSWORD} PG_PATH= -DB_HOST=postgres -DB_PORT=5432 -DB_SSLMODE=prefer -DB_MAXCONN=64 -DB_TEMPLATE=unaccent_template +DB_HOST=${DB_HOST} +DB_PORT=${DB_PORT} +DB_SSLMODE=${DB_SSLMODE} +DB_MAXCONN=${DB_MAXCONN} +DB_TEMPLATE=${DB_TEMPLATE} # Internationalisation options LOAD_LANGUAGE=${LOAD_LANGUAGE} LANGUAGE= @@ -122,30 +162,27 @@ TRANSLATE_IN= OVERWRITE_EXISTING_TRANSLATIONS=False TRANSLATE_MODULES="['all']" # Security -LIST_DB=True +LIST_DB=${LIST_DB} # WEB -DBFILTER=.* +DBFILTER=${DBFILTER} # Advanced options DEV_MODE=${DEV_MODE} -DEBUG_MODE=${DEBUG_MODE} SHELL_INTERFACE=ptpython STOP_AFTER_INIT=False OSV_MEMORY_COUNT_LIMIT=False TRANSIENT_AGE_LIMIT=1.0 MAX_CRON_THREADS=2 -UNACCENT=True +UNACCENT=${UNACCENT} GEOIP_DATABASE=/usr/share/GeoIP/GeoLite2-City.mmdb -WORKERS=0 +WORKERS=${WORKERS} LIMIT_MEMORY_SOFT=2147483648 LIMIT_MEMORY_HARD=2684354560 LIMIT_TIME_CPU=120 -LIMIT_TIME_REAL=240 +LIMIT_TIME_REAL=480 LIMIT_TIME_REAL_CRON=600 LIMIT_REQUEST=8192 -INSTALLED_MODULES= - #--------------# # Docker # #--------------# @@ -171,7 +208,7 @@ NGINX_DEFAULT_CONF=/etc/nginx/conf.d/default.conf VIRTUAL_HOST=${DOMAIN} LETSENCRYPT_HOST=${DOMAIN} LETSENCRYPT_EMAIL=${SUPPORT_EMAIL} -CORS_ALLOWED_DOMAIN="'https://sub.domain.com'" +CORS_ALLOWED_DOMAIN=${CORS_ALLOWED_DOMAIN} #-------------# # PgAdmin # @@ -197,4 +234,4 @@ CORS_ALLOWED_DOMAIN=${CORS_ALLOWED_DOMAIN} #----------------------# # ACME Companion # #----------------------# -DEFAULT_EMAIL=${SUPPORT_EMAIL} \ No newline at end of file +DEFAULT_EMAIL=${SUPPORT_EMAIL} diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index b328113..0749d0a 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,11 +1,22 @@ -## :rocket: Deployment -- `ADDONS_TO_INSTALL="my_custom_addon"` -- `ADDONS_TO_UPGRADE="contacts,sale"` +### :rocket: Deployment +- `INIT="my_custom_addon_1"` +- `ADDONS_TO_UPGRADE="my_custom_addon_2"` -## :memo: Changes +### :jigsaw: Odoo/Asana Tasks +- *Paste Task URL* + +### :memo: Changes **Change 1: *Title*** - In detail, explain what changes were made. -*Add links and screenshots* +*Add links, videos and screenshots here* -
\ No newline at end of file +
+ +### :white_check_mark: Code Review Checklist +- [ ] Comments are present where appropriate and provide useful information, **not just stating what the code is obviously doing**. +- [ ] No values have been hard-coded where they should be declared as constant. +- [ ] Successfully passed all tests when implemented. +- [ ] Install package(s) without additional **WARNINGS** or **ERRORS**. +- [ ] Update package(s) without additional **WARNINGS** or **ERRORS**. +- [ ] Uninstall package(s) without additional **WARNINGS** or **ERRORS**. diff --git a/.gitignore b/.gitignore index 75364dd..d65093e 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,7 @@ /.env # Ignores the docker compose local or production environment. -docker-compose.override.yml \ No newline at end of file +docker-compose.override.yml + +# Ignores any __pycache__ folder. +__pycache__ diff --git a/.vscode/launch.json b/.vscode/launch.json index 016310a..13caad0 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -2,27 +2,19 @@ "version": "0.2.0", "configurations": [ { - "name": "Odoocker Debug", + "name": "Odoocker Debugger", "type": "python", "request": "attach", "host": "localhost", "port": 8069, - "debugServer": 8071, + "debugServer": 8070, "justMyCode": false, "pathMappings": [ { - "localRoot": "${workspaceFolder}/odoo/custom-addons", - "remoteRoot": "/usr/lib/python3/dist-packages/odoo/custom-addons" - }, - { - "localRoot": "${workspaceFolder}/odoo/extra-addons", - "remoteRoot": "/usr/lib/python3/dist-packages/odoo/extra-addons" - }, - // { - // "localRoot": "${workspaceFolder}/core/odoo", - // "remoteRoot": "/usr/bin/odoo" - // } + "localRoot": "${workspaceFolder}/odoo", + "remoteRoot": "/usr/lib/python3/dist-packages/odoo" + } ] } ] -} \ No newline at end of file +} diff --git a/README.md b/README.md index d36089f..6112b9f 100644 --- a/README.md +++ b/README.md @@ -7,22 +7,20 @@ git clone git@github.com:yhaelopez/odoocker.git ``` cp .env.example .env && cp docker-compose.override.local.yml docker-compose.override.yml ``` -3. Manually add entry to your `hosts` file as below (Local) +3. Manually add entry to your `hosts` file as below ``` -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 +echo '127.0.0.1 erp.icomsa.test' | sudo tee -a /etc/hosts +echo '127.0.0.1 pgadmin.icomsa.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 +127.0.0.1 erp.icomsa.test +127.0.0.1 pgadmin.icomsa.test ``` In order to understand how each environment works, take a look at `odoo/entrypoint.sh`. -``` -Master Password: odoo -``` +**Default Master Password:** odoo ## Fresh Environment This environment will have no database created. @@ -30,7 +28,7 @@ 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 +docker-compose up -d --build && docker-compose logs -f odoo ``` 3. Navigate to the `DOMAIN` in your browser. 4. Create Database form will be displayed. @@ -41,9 +39,32 @@ docker-compose stop odoo ``` 7. Set [`Local`](https://github.com/yhaelopez/odoocker#local-environment) 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 -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: + +6. Run [`Staging`](https://github.com/yhaelopez/odoocker#staging-environment) environment. +7. Stop the Odoo container: +``` +docker-compose stop 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 database will all modules installed in production. +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 @@ -62,39 +83,16 @@ docker-compose stop odoo ``` 7. Set [`Local`](https://github.com/yhaelopez/odoocker#local-environment) 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 -``` -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: - -6. Set [`Staging`](https://github.com/yhaelopez/odoocker#staging-environment) environment. -7. Stop the Odoo container: -``` -docker-compose stop odoo -``` -8. Run the [`Production`](https://github.com/yhaelopez/odoocker#production-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 `ADDONS_TO_UPDATE=module1,module2,module3`. +3. Set `UPDATE=module1,module2,module3`. 4. Run: ``` -docker-compose up --build -d odoo && docker-compose logs -f odoo +docker-compose up -d --build && docker-compose logs -f odoo ``` 5. Navigate to the `DOMAIN` in your browser. 6. Start coding! @@ -102,15 +100,123 @@ docker-compose up --build -d odoo && docker-compose logs -f odoo ``` docker-compose restart odoo && docker-compose logs -f odoo ``` -- If you think your package is not being updated, run: +- If you need to change a .env variable, run: ``` -docker-compose up --build -d odoo && docker-compose logs -f odoo +docker-compose up -d --build && docker-compose logs -f odoo ``` -8. Any time you add a new addon to `ADDONS_TO_UPDATE` re-run last step -## Additional Local Help +## Debug Environment +This environment will bring up Odoo with `debugpy` library. +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. -### Creating new Odoo Addons +1. Make sure `APP_ENV=debug`. +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. Mark breakpoints through the code. +7. Start VSCode Debugger +8. Start debugging! +9. Continue coding as if you were in [`Local`](https://github.com/yhaelopez/odoocker#local-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 +``` + +## Staging Environment +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` +1. Set `APP_ENV=staging` +2. Set `DB_NAME` to the desired one. +3. Set `INIT` if there are any. +5. Run +``` +git pull && docker-compose down && docker-compose pull && docker-compose build --no-cache && docker-compose up -d && docker-compose logs -f odoo +``` +7. Check Odoo continues to work as expected. +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 +``` +9. Rebuild the containers +``` +docker-compose down && docker-compose up -d --build && docker-compose logs odoo +``` + +### Pro(d) Tips +The following tips will enhance your developing and production experience. + +#### Define the following aliases: +``` +alias odoo='cd odoo-icomsa' + +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 deploy='git pull && docker-compose down && docker-compose pull && docker-compose build && docker-compose up -d && 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' +``` + +#### NEVER run +``` +docker-compose down **-v** +``` +...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! + +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 +Add the following to `~/.bashrc` +``` +# Color git branches +function parse_git_branch () { + git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/' +} + +if [ "$color_prompt" = yes ]; then + #PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' + # Color git branches + PS1="${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w \[\033[01;31m\]\$(parse_git_branch)\[\033[00m\]\$ " +else + PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' +fi +unset color_prompt force_color_prompt +``` + +#### Creating new Odoo Addons 1. Log into the odoo container ``` docker-compose exec -u root odoo @@ -125,7 +231,7 @@ odoo scaffold ``` - The new addon will be available in the `odoo/custom_addons` folder in this project. -### Using Odoo Shell +#### Using Odoo Shell 1. Log into the odoo container ``` docker-compose exec odoo bash @@ -135,58 +241,26 @@ docker-compose exec odoo bash odoo shell --http-port=8071 ``` -5. Connect to database through any Postgres Database Manager using `localhost` and the `.env` credentials +# DB Connection +- Any other Postgres Database Manager con connect to the DB using `.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. +## PgAdmin Container +- 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 bring this up, simply run: ``` -cp docker-compose.override.testing.yml docker-compose.override.yml +docker-compose -f docker-compose.yml -f docker-compose.override.yml -f docker-compose.pgadmin.yml up -d --build ``` -2. Clone Production Database as `test_${DB_NAME}`. -3. Set `APP_ENV=testing`. -4. Set `DB_NAME=test_${DB_NAME}` or whatever db you set before. -5. Run: +And to turn down ``` -docker-compose down && docker-compose pull && docker-compose build --no-cache && docker-compose up -d && docker-compose logs -f odoo +docker-compose -f docker-compose.yml -f docker-compose.override.yml -f docker-compose.pgadmin.yml down ``` -## 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. -5. Run -``` -git pull && docker-compose down && docker-compose pull && docker-compose build --no-cache && docker-compose up -d && docker-compose logs -f odoo -``` -7. Check Odoo continues to work as expected. -8. Change environment immediatly after finish testing. +If your instance has pgAdmin, make sure you adapt this to your aliases. -**Do not bring down & up again unless you want to perform the whole update again.** +# Deployment Process +Note: the deployment process is easier & faster with aliases. -# 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 -``` -9. 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 ``` @@ -206,16 +280,19 @@ sudo apt update && sudo apt upgrade -y ``` 4. Go to the project folder in /home/ubuntu or (~) ``` -cd ~/odoocker +cd ~/odoo-icomsa +``` +or with alias: +``` +odoo ``` 5. Pull the latest `main` branch changes. ``` git pull origin main ``` -6. Set Staging environment -7. Make sure everything continues to work as expected. -8. Set `APP_ENV=production` -9. Take down the containers, pull the latest images from docker hub, and rebuild the containers. +6. Set [`Staging`](https://github.com/yhaelopez/odoocker#staging-environment) environment +7. Set `APP_ENV=production` +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 ``` -docker-compose down && docker-compose pull && docker-compose build --no-cache && docker-compose up -d && docker-compose logs -f odoo -``` \ No newline at end of file diff --git a/docker-compose.override.local.yml b/docker-compose.override.local.yml index 8b558c6..6c6c3d8 100644 --- a/docker-compose.override.local.yml +++ b/docker-compose.override.local.yml @@ -3,6 +3,7 @@ services: restart: 'no' ports: - 8069:8069 + - 8070:8070 - 8071:8071 - 8072:8072 @@ -18,19 +19,3 @@ services: restart: 'no' ports: - 80:80 - - pgadmin: - image: dpage/pgadmin4:7.1 - restart: unless-stopped - expose: - - 80 - volumes: - - pgadmin-data:${PGADMIN_DATA} - environment: - - PGADMIN_DEFAULT_EMAIL - - PGADMIN_DEFAULT_PASSWORD - - VIRTUAL_HOST=${PGADMIN_VIRTUAL_HOST} - - LETSENCRYPT_HOST=${PGADMIN_LETSENCRYPT_HOST} - - LETSENCRYPT_EMAIL - networks: - - internal \ No newline at end of file diff --git a/docker-compose.override.production.yml b/docker-compose.override.production.yml index d94a935..3eaaf88 100644 --- a/docker-compose.override.production.yml +++ b/docker-compose.override.production.yml @@ -7,10 +7,12 @@ services: - 127.0.0.1:8072:8072 postgres: + restart: unless-stopped ports: - 127.0.0.1:5432:5432 nginx-proxy: + restart: unless-stopped ports: - 80:80 - 443:443 @@ -33,4 +35,4 @@ services: volumes: acme: - certs: \ No newline at end of file + certs: diff --git a/docker-compose.pgadmin.yml b/docker-compose.pgadmin.yml new file mode 100644 index 0000000..26c995d --- /dev/null +++ b/docker-compose.pgadmin.yml @@ -0,0 +1,19 @@ +services: + pgadmin: + image: dpage/pgadmin4:7.4 + restart: unless-stopped + expose: + - 80 + volumes: + - pgadmin-data:${PGADMIN_DATA} + environment: + - PGADMIN_DEFAULT_EMAIL + - PGADMIN_DEFAULT_PASSWORD + - VIRTUAL_HOST=${PGADMIN_VIRTUAL_HOST} + - LETSENCRYPT_HOST=${PGADMIN_LETSENCRYPT_HOST} + - LETSENCRYPT_EMAIL + networks: + - internal + +volumes: + pgadmin-data: diff --git a/docker-compose.yml b/docker-compose.yml index 243e0d3..55595c9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,6 +3,15 @@ services: build: context: ./ dockerfile: ./odoo/Dockerfile + args: + - ODOO_VERSION + - ODOO_RC + - ROOT_PATH + - GITHUB_USER + - GITHUB_ACCESS_TOKEN + - ENTERPRISE_REPO + - ENTERPRISE_ADDONS + - LOG_PATH depends_on: - postgres tty: true @@ -35,7 +44,7 @@ services: - internal nginx: - image: nginx:1.24.0 + image: nginx:1.25.1 depends_on: - odoo restart: unless-stopped @@ -54,7 +63,7 @@ services: - internal nginx-proxy: - image: nginxproxy/nginx-proxy:1.3.0 + image: nginxproxy/nginx-proxy:1.3.1 depends_on: - nginx restart: unless-stopped @@ -78,8 +87,7 @@ volumes: certs: vhost: html: - pgadmin-data: networks: internal: - driver: bridge \ No newline at end of file + driver: bridge diff --git a/nginx-proxy/nginx.conf b/nginx-proxy/nginx.conf index 48862ca..08927f5 100644 --- a/nginx-proxy/nginx.conf +++ b/nginx-proxy/nginx.conf @@ -34,4 +34,4 @@ http { } -daemon off; \ No newline at end of file +daemon off; diff --git a/nginx/default.conf b/nginx/default.conf index 6ff5062..97f5929 100644 --- a/nginx/default.conf +++ b/nginx/default.conf @@ -54,4 +54,4 @@ server { proxy_set_header Host $host; proxy_pass http://odoo:8072; } -} \ No newline at end of file +} diff --git a/nginx/nginx.conf b/nginx/nginx.conf index 238f3c0..646f968 100644 --- a/nginx/nginx.conf +++ b/nginx/nginx.conf @@ -23,4 +23,4 @@ http { keepalive_timeout 900; include /etc/nginx/conf.d/*.conf; -} \ No newline at end of file +} diff --git a/odoo/Dockerfile b/odoo/Dockerfile index 47155f5..47d0788 100644 --- a/odoo/Dockerfile +++ b/odoo/Dockerfile @@ -1,74 +1,90 @@ -ARG ODOO_VERSION=16.0 - +#------------------------# +# Odoo Community # +#------------------------# +ARG ODOO_VERSION FROM odoo:${ODOO_VERSION} -# Switch back to root user +# Switch to root user USER root -# Update & Upgrade -RUN apt-get update && apt-get upgrade -y +# Receive ARGs from docker-compose.yml & convert them into ENVs +ARG ROOT_PATH +ARG LOG_PATH +ARG GITHUB_USER +ARG GITHUB_ACCESS_TOKEN +ARG ENTERPRISE_REPO +ARG ENTERPRISE_ADDONS +ARG ODOO_RC -# Upgrade pip -RUN pip3 install --upgrade pip - -# Set Odoo root path -ARG ROOT_PATH=/usr/lib/python3/dist-packages/odoo - -#---------------# -# Logging # -#---------------# -# Set Log variables -ARG LOGPATH=/var/log/odoo -ARG LOGFILE=${LOGPATH}/odoo.log - -# Create odoo.log file and give permissions. -RUN touch ${LOGFILE} && chown odoo:odoo -R ${LOGPATH} - -#-----------------------# -# Odoo Enterprise # -#-----------------------# -# Install git -RUN apt-get install git -y - -# Set Github Credentials -ARG GITHUB_USER=yhaelopez -ARG GITHUB_ACCESS_TOKEN=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 -ARG ENTERPRISE_REPO=https://${GITHUB_USER}:${GITHUB_ACCESS_TOKEN}@github.com/odoo/enterprise.git -ARG ENTERPRISE_PATH=${ROOT_PATH}/enterprise - -# Create Enterprise Path & give permissions -RUN mkdir -p ${ENTERPRISE_PATH} && chown odoo:odoo -R ${ENTERPRISE_PATH} - -# Clone Enterprise Repository -RUN git clone ${ENTERPRISE_REPO} ${ROOT_PATH}/enterprise --depth 1 --branch ${ODOO_VERSION} --single-branch --no-tags - -#--------------------------------# -# Fix Deprecation Warnings # -#--------------------------------# +ENV ODOO_VERSION=${ODOO_VERSION} \ + LOG_PATH=${LOG_PATH} \ + GITHUB_USER=${GITHUB_USER} \ + GITHUB_ACCESS_TOKEN=${GITHUB_ACCESS_TOKEN} \ + ENTERPRISE_REPO=${ENTERPRISE_REPO} \ + ENTERPRISE_ADDONS=${ENTERPRISE_ADDONS} \ + ODOO_RC=${ODOO_RC} #------------------------# # APT Dependencies # #------------------------# +RUN apt-get update && apt-get install -y \ + apt-utils \ + git \ + git-man \ + less \ + libcbor0 \ + libcurl3-gnutls \ + libedit2 \ + liberror-perl \ + libxmuu1 \ + openssh-client \ + patch \ + xauth \ + # Clean up the apt cache to reduce the image size + && rm -rf /var/lib/apt/lists/* #-----------------------# -# PIP Dependencies # +# Odoo Enterprise # #-----------------------# -# Copy PIP requirements -COPY ./odoo/requirements.txt /tmp/requirements.txt -# Install PIP requirements -RUN python3 -m pip install -r /tmp/requirements.txt -# RUN pip3 install debugpy +# Create Enterprise addons directory +RUN mkdir -p ${ENTERPRISE_ADDONS} && \ + chown odoo:odoo -R ${ENTERPRISE_ADDONS} + +# Clone Enterprise addons if user and token are present +RUN if [ -n "$GITHUB_USER" ] && [ -n "$GITHUB_ACCESS_TOKEN" ]; then \ + git clone ${ENTERPRISE_REPO} ${ENTERPRISE_ADDONS} --depth 1 --branch ${ODOO_VERSION} --single-branch --no-tags; \ + fi + +#---------------------# +# PIP Dependecies # +#---------------------# +# Upgrade pip +RUN pip3 install --upgrade pip + +# Copy & Install PIP requirements +COPY --chown=odoo:odoo ./odoo/requirements.txt /tmp/requirements.txt + +RUN python3 -m pip install --upgrade -r /tmp/requirements.txt && \ + rm /tmp/requirements.txt + +#---------------------# +# Logging # +#---------------------# + +# Create odoo.log file +RUN touch ${LOG_PATH} && chown odoo:odoo ${LOG_PATH} #-----------------------# # Odoo Conf # #-----------------------# -# Copy environment variables at / -COPY ./.env / -# Copy script to generate odoo.conf -COPY ./odoo/odoorc.sh / + +# Copy environment variables & script to generate odoo.conf +COPY --chown=odoo:odoo ./.env / +COPY --chown=odoo:odoo ./odoo/odoorc.sh / + # Generate odoo.conf RUN /odoorc.sh && chown odoo:odoo ${ODOO_RC} # Switch back to odoo user -USER odoo \ No newline at end of file +USER odoo diff --git a/odoo/custom-addons/.gitignore b/odoo/custom-addons/.gitignore deleted file mode 100644 index 75b6f9c..0000000 --- a/odoo/custom-addons/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# Ignores any __pycache__ folder. -__pycache__ \ No newline at end of file diff --git a/odoo/entrypoint.sh b/odoo/entrypoint.sh index 4a7c9e3..a343b17 100755 --- a/odoo/entrypoint.sh +++ b/odoo/entrypoint.sh @@ -12,50 +12,50 @@ case "$1" in wait-for-psql.py --db_host ${DB_HOST} --db_port ${DB_PORT} --db_user ${DB_USER} --db_password ${DB_PASSWORD} --timeout=30 if [ ${APP_ENV} = 'fresh' ] || [ ${APP_ENV} = 'restore' ]; then - echo odoo --config ${ODOO_RC} --database= --update= --init= --load=${SERVER_WIDE_MODULES} --workers=0 --log-handler=:INFO --log-level=info --max-cron-threads=2 --limit-time-cpu=3600 --limit-time-real=7200 --limit-time-real-cron=600 --limit-request=8192 --limit-memory-soft=2147483648 --limit-memory-hard=2684354560 --transient-age-limit=1.0 --load-language= --without-demo=True --import-partial=False --log-db= --dev=False + echo odoo --config ${ODOO_RC} --database= --init= --update= --load=${SERVER_WIDE_MODULES} --log-handler=${LOG_HANDLER} --log-level=${LOG_LEVEL} --load-language= --workers=0 --limit-time-cpu=3600 --limit-time-real=7200 - exec odoo --config ${ODOO_RC} --database= --update= --init= --load=${SERVER_WIDE_MODULES} --workers=0 --log-handler=:INFO --log-level=info --max-cron-threads=2 --limit-time-cpu=3600 --limit-time-real=7200 --limit-time-real-cron=600 --limit-request=8192 --limit-memory-soft=2147483648 --limit-memory-hard=2684354560 --transient-age-limit=1.0 --load-language= --without-demo=True --import-partial=False --log-db= --dev=False + exec odoo --config ${ODOO_RC} --database= --init= --update= --load=${SERVER_WIDE_MODULES} --log-handler=${LOG_HANDLER} --log-level=${LOG_LEVEL} --load-language= --workers=0 --limit-time-cpu=3600 --limit-time-real=7200 fi if [ ${APP_ENV} = 'full' ] ; then - echo odoo --config ${ODOO_RC} --database=${DB_NAME} --init=${INSTALLED_MODULES} --update= --load=${SERVER_WIDE_MODULES} --workers=0 --log-handler=:INFO --log-level=info --max-cron-threads=2 --limit-time-cpu=3600 --limit-time-real=7200 --limit-time-real-cron=600 --limit-request=8192 --limit-memory-soft=2147483648 --limit-memory-hard=2684354560 --transient-age-limit=1.0 --db-filter= --load-language=${LOAD_LANGUAGE} --without-demo=True --import-partial=False --log-db= --dev=False + 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 - exec odoo --config ${ODOO_RC} --database=${DB_NAME} --init=${INSTALLED_MODULES} --update= --load=${SERVER_WIDE_MODULES} --workers=0 --log-handler=:INFO --log-level=info --max-cron-threads=2 --limit-time-cpu=3600 --limit-time-real=7200 --limit-time-real-cron=600 --limit-request=8192 --limit-memory-soft=2147483648 --limit-memory-hard=2684354560 --transient-age-limit=1.0 --db-filter= --load-language=${LOAD_LANGUAGE} --without-demo=True --import-partial=False --log-db= --dev=False + 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 fi if [ ${APP_ENV} = 'local' ] ; then # Automagically update the addons you are currently working on. - echo odoo --config ${ODOO_RC} --database=${DB_NAME} --update=${UPDATE} --init=${INIT} --load=${SERVER_WIDE_MODULES} --dev=${DEV_MODE} + echo odoo --config ${ODOO_RC} --database=${DB_NAME} --init=${INIT} --update=${UPDATE} --load=${SERVER_WIDE_MODULES} --log-handler=${LOG_HANDLER} --log-level=${LOG_LEVEL} --workers=${WORKERS} --dev=${DEV_MODE} - exec odoo --config ${ODOO_RC} --database=${DB_NAME} --update=${UPDATE} --init=${INIT} --load=${SERVER_WIDE_MODULES} --dev=${DEV_MODE} + exec odoo --config ${ODOO_RC} --database=${DB_NAME} --init=${INIT} --update=${UPDATE} --load=${SERVER_WIDE_MODULES} --log-handler=${LOG_HANDLER} --log-level=${LOG_LEVEL} --workers=${WORKERS} --dev=${DEV_MODE} fi if [ ${APP_ENV} = 'debug' ] ; then # Automagically update the addons you are currently working on. - exec /usr/bin/python3 -m debugpy --listen 0.0.0.0:8888 /usr/bin/odoo --config ${ODOO_RC} --database=${DB_NAME} --update=${UPDATE} --init=${INIT} --load=${SERVER_WIDE_MODULES} --dev=${DEV_MODE} + echo /usr/bin/python3 -m debugpy --listen ${DEBUG_INTERFACE}:${DEBUG_PORT} ${DEBUG_PATH} --config ${ODOO_RC} --database=${DB_NAME} --init=${INIT} --update=${UPDATE} --load=${SERVER_WIDE_MODULES} --log-handler=${LOG_HANDLER} --log-level=${LOG_LEVEL} --workers=${WORKERS} --dev=${DEV_MODE} - exec /usr/bin/python3 -m debugpy --listen 0.0.0.0:8888 /usr/bin/odoo --config ${ODOO_RC} --database=${DB_NAME} --update=${UPDATE} --init=${INIT} --load=${SERVER_WIDE_MODULES} --dev=${DEV_MODE} + exec /usr/bin/python3 -m debugpy --listen ${DEBUG_INTERFACE}:${DEBUG_PORT} ${DEBUG_PATH} --config ${ODOO_RC} --database=${DB_NAME} --init=${INIT} --update=${UPDATE} --load=${SERVER_WIDE_MODULES} --log-handler=${LOG_HANDLER} --log-level=${LOG_LEVEL} --workers=${WORKERS} --dev=${DEV_MODE} fi if [ ${APP_ENV} = 'testing' ] ; then - # Work in progres... (DO NOT USE) - echo odoo --config ${ODOO_RC} --database=test_${DB_NAME} --db-filter=test_${DB_NAME} --test-enable --test-commit --log-handler=:DEBUG --log-level=debug --workers=0 --init= --update= + # Runs the tests in a 'test_*' database for the addons you are currently working on via test tags. + echo odoo --config ${ODOO_RC} --database=test_${DB_NAME} --test-enable --test-tags ${TEST_TAGS} --init=${ADDONS_TO_TEST} --update=${ADDONS_TO_TEST} --load=${SERVER_WIDE_MODULES} --log-handler=${LOG_HANDLER} --log-level=${LOG_LEVEL} --without-demo= --workers=0 --stop-after-init - exec odoo --config ${ODOO_RC} --database=test_${DB_NAME} --db-filter=test_${DB_NAME} --test-enable --test-commit --log-handler=:DEBUG --log-level=debug --workers=0 --init= --update= + exec odoo --config ${ODOO_RC} --database=test_${DB_NAME} --test-enable --test-tags ${TEST_TAGS} --init=${ADDONS_TO_TEST} --update=${ADDONS_TO_TEST} --load=${SERVER_WIDE_MODULES} --log-handler=${LOG_HANDLER} --log-level=${LOG_LEVEL} --without-demo= --workers=0 --stop-after-init fi if [ ${APP_ENV} = 'staging' ] ; then - # Automagically install/upgrade all addons - echo odoo --config ${ODOO_RC} --database=${DB_NAME} --init=${INIT} --update=all --load=${SERVER_WIDE_MODULES} --workers=0 --log-handler=:INFO --log-level=info --max-cron-threads=2 --limit-time-cpu=3600 --limit-time-real=7200 --limit-time-real-cron=600 --limit-request=8192 --limit-memory-soft=2147483648 --limit-memory-hard=2684354560 --transient-age-limit=1.0 --db-filter= --load-language=${LOAD_LANGUAGE} --without-demo=True --import-partial=False --log-db= --dev=False + # Automagically upgrade all addons and install new ones. + echo odoo --config ${ODOO_RC} --database=${DB_NAME} --init=${INIT} --update=all --load=${SERVER_WIDE_MODULES} --log-handler=${LOG_HANDLER} --log-level=${LOG_LEVEL} --load-language=${LOAD_LANGUAGE} --limit-time-cpu=3600 --limit-time-real=7200 --workers=0 --without-demo=all - exec odoo --config ${ODOO_RC} --database=${DB_NAME} --init=${INIT} --update=all --load=${SERVER_WIDE_MODULES} --workers=0 --log-handler=:INFO --log-level=info --max-cron-threads=2 --limit-time-cpu=3600 --limit-time-real=7200 --limit-time-real-cron=600 --limit-request=8192 --limit-memory-soft=2147483648 --limit-memory-hard=2684354560 --transient-age-limit=1.0 --db-filter= --load-language=${LOAD_LANGUAGE} --without-demo=True --import-partial=False --log-db= --dev=False + exec odoo --config ${ODOO_RC} --database=${DB_NAME} --init=${INIT} --update=all --load=${SERVER_WIDE_MODULES} --log-handler=${LOG_HANDLER} --log-level=${LOG_LEVEL} --load-language=${LOAD_LANGUAGE} --limit-time-cpu=3600 --limit-time-real=7200 --workers=0 --without-demo=all fi if [ ${APP_ENV} = 'production' ] ; then - # Bring up Odoo without any addons to install/update. - echo odoo --config ${ODOO_RC} --database= --init= --update= --load-language= --db-filter= --dev=False --import-partial=False --without-demo=True --log-handler=:INFO --log-level=info --log-db= --log-db-level=warning --workers=2 --max-cron-threads=2 --log-level=info --log-handler=:INFO --limit-time-cpu=120 --limit-time-real=240 --limit-request=8192 --limit-memory-soft=2147483648 --limit-memory-hard=2684354560 --transient-age-limit=1.0 --import-partial=False + # Bring up Odoo ready for production. + echo odoo --config ${ODOO_RC} --database= --init= --update= --load=${SERVER_WIDE_MODULES} --workers=${WORKERS} --log-handler=${LOG_HANDLER} --log-level=${LOG_LEVEL} --load-language= --without-demo=all --dev=False - exec odoo --config ${ODOO_RC} --database= --init= --update= --load-language= --db-filter= --dev=False --import-partial=False --without-demo=True --log-handler=:INFO --log-level=info --log-db= --log-db-level=warning --workers=2 --max-cron-threads=2 --log-level=info --log-handler=:INFO --limit-time-cpu=120 --limit-time-real=240 --limit-request=8192 --limit-memory-soft=2147483648 --limit-memory-hard=2684354560 --transient-age-limit=1.0 --import-partial=False + exec odoo --config ${ODOO_RC} --database= --init= --update= --load=${SERVER_WIDE_MODULES} --workers=${WORKERS} --log-handler=${LOG_HANDLER} --log-level=${LOG_LEVEL} --load-language= --without-demo=all --dev=False fi fi ;; @@ -72,4 +72,4 @@ case "$1" in exec "$@" esac -exit 1 \ No newline at end of file +exit 1 diff --git a/odoo/extra-addons/.gitignore b/odoo/extra-addons/.gitignore deleted file mode 100644 index 75b6f9c..0000000 --- a/odoo/extra-addons/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# Ignores any __pycache__ folder. -__pycache__ \ No newline at end of file diff --git a/odoo/odoo.example.conf b/odoo/odoo.example.conf index 6a1fb69..84e2820 100644 --- a/odoo/odoo.example.conf +++ b/odoo/odoo.example.conf @@ -3,249 +3,258 @@ ; Options not exposed on the command line. ; ;------------------------------------------; -admin_passwd=odoo -csv_internal_sep=, -publisher_warranty_url=http://services.openerp.com/publisher-warranty/ -root_path=/usr/lib/python3/dist-packages/odoo -reportgz=False -websocket_keep_alive_timeout=3600 -websocket_rate_limit_burst=10 -websocket_rate_limit_delay=0.2 +admin_passwd = {ADMIN_PASSWD} +csv_internal_sep = {CSV_INTERNAL_SEP} +publisher_warranty_url = {PUBLISHER_WARRANTY_URL} +root_path = {ROOT_PATH} +reportgz = {REPORTGZ} +websocket_keep_alive_timeout = {WEBSOCKET_KEEP_ALIVE_TIMEOUT} +websocket_rate_limit_burst = {WEBSOCKET_RATE_LIMIT_BURST} +websocket_rate_limit_delay = {WEBSOCKET_RATE_LIMIT_DELAY} ;-----------------------; ; Server startup config ; ;-----------------------; ; --config | -c -config=/etc/odoo/odoo.conf +config = {ODOO_RC} ; --save -save=False +save = {SAVE} ; --init | -i -init= +init = {INIT} ; --update | -u -update= +update = {UPDATE} ; --without-demo -demo=False -without_demo=all +demo = {DEMO} +without_demo = {WITHOUT_DEMO} ; --import-partial -import_partial= +import_partial = {IMPORT_PARTIAL} ; --pidfile -pidfile= +pidfile = {PIDFILE} ; --addons-path -addons_path=/usr/lib/python3/dist-packages/odoo/addons,/usr/lib/python3/dist-packages/odoo/enterprise,/usr/lib/python3/dist-packages/odoo/extra-addons,/usr/lib/python3/dist-packages/odoo/custom-addons +addons_path = {ADDONS_PATH} ; --upgrade-path -upgrade_path= +upgrade_path = {UPGRADE_PATH} ; --load -server_wide_modules=base,web +server_wide_modules = {SERVER_WIDE_MODULES} ; --data-dir -data_dir=/var/lib/odoo +data_dir = {DATA_DIR} ;------; ; HTTP ; ;------; ; --http-interface | --xmlrpc-interface -http_interface=0.0.0.0 +http_interface = {HTTP_INTERFACE} ; --http-port | -p | --xmlrpc-port -http_port=8069 +http_port = {HTTP_PORT} + +; --xmlrpcs-interface +xmlrpcs_interface = {XMLRPCS_INTERFACE} + +; --xmlrpcs-port +xmlrpcs_port = {XMLRPCS_PORT} ; --longpolling_port -longpolling_port=8072 +longpolling_port = {LONGPOLLING_PORT} ; --no-http | --no-xmlrpc -http_enable=True +http_enable = {HTTP_ENABLE} + +; --no-xmlrpcs +xmlrpcs = {XMLRPCS} ; --proxy-mode -proxy_mode=True +proxy_mode = {PROXY_MODE} ; --x-sendfile -x_sendfile =False +x_sendfile = {X_SENDFILE} ;---------------; ; Testing Group ; ;---------------; ; --test-file -test_file=False +test_file = {TEST_FILE} ; --test-enable -test_enable=False +test_enable = {TEST_ENABLE} ; --test-tags -test_tags=False +test_tags = {TEST_FILE} ; --screencasts -screencasts=None +screencasts = {SCREENCASTS} ; --screenshots -screenshots=/tmp/odoo_tests +screenshots = {SCREENSHOTS} ;---------------; ; Logging Group ; ;---------------; ; --logfile -logfile= +logfile = {LOGFILE} ; --syslog -syslog=False +syslog = {SYSLOG} ; --log-handler | --log-web (--log-handler=odoo.http:DEBUG) | --log-sql (--log-handler=odoo.sql_db:DEBUG) -log_handler=[':INFO'] +log_handler = {LOG_HANDLER} ; --log-db -log_db=False +log_db = {LOG_DB} ; --log-db-level -log_db_level=info +log_db_level = {LOG_DB_LEVEL} ; --log-level -log_level=info +log_level = {LOG_LEVEL} ;------------; ; SMTP Group ; ;------------; ; --email-from -email_from= +email_from = {EMAIL_FROM} ; --from-filter -from_filter=False +from_filter = {FROM_FILTER} ; --smtp -smtp_server= +smtp_server = {SMTP_SERVER} ; --smtp-port -smtp_port=25 +smtp_port = {SMTP_PORT} ; --smtp-ssl -smtp_ssl= +smtp_ssl = {SMTP_SSL} ; --smtp-user -smtp_user= +smtp_user = {SMTP_USER} ; --smtp-password -smtp_password= +smtp_password = {SMTP_PASSWORD} ; --smtp-ssl-certificate-filename -smtp_ssl_certificate_filename=False +smtp_ssl_certificate_filename = {SMTP_SSL_CERTIFICATE_FILENAME} ; --smtp-ssl-private-key-filename -smtp_ssl_private_key_filename=False +smtp_ssl_private_key_filename = {SMTP_SSL_PRIVATE_KEY_FILENAME} ;----------; ; DB Group ; ;----------; ; --database | -d -db_name=odoo +db_name = {DB_NAME} ; --db_user | -r -db_user=odoo +db_user = {DB_USER} ; --db_password | -w -db_password=odoo +db_password = {DB_PASSWORD} ; --pg_path -pg_path= +pg_path = {PG_PATH} ; --db_host -db_host=postgres +db_host = {DB_HOST} ; --db_port -db_port=5432 +db_port = {DB_PORT} ; --db_sslmode -db_sslmode=prefer +db_sslmode = {DB_SSLMODE} ; --db_maxconn -db_maxconn=64 +db_maxconn = {DB_MAXCONN} ; --db-template -db_template=unaccent_template +db_template = {DB_TEMPLATE} ;------------------------------; ; Internationalisation options ; ;------------------------------; ; --load-language -load_language=en_US +load_language = {LOAD_LANGUAGE} ; --language -language= +language = {LANGUAGE} ; --i18n-export -translate_out= +translate_out = {TRANSLATE_OUT} ; --i18n-import -translate_in= +translate_in = {TRANSLATE_IN} ; --i18n-overwrite -overwrite_existing_translations=False +overwrite_existing_translations = {OVERWRITE_EXISTING_TRANSLATIONS} ; --modules -translate_modules=['all'] +translate_modules = {TRANSLATE_MODULES} ;----------; ; Security ; ;----------; ; --no-database-list -list_db=True +list_db = {LIST_DB} ;-----; ; WEB ; ;-----; ; --db-filter -dbfilter=.* +dbfilter = {DBFILTER} ;------------------; ; Advanced options ; ;------------------; -; --dev -dev_mode=False +; --dev (all, reload, qweb, werkzeug, sql, shell, assets, tests) +dev_mode = {DEV_MODE} ; --shell-interface -shell_interface=ptpython +shell_interface = {SHELL_INTERFACE} ; --stop-after-init -stop_after_init=False +stop_after_init = {STOP_AFTER_INIT} ; --osv-memory-count-limit -osv_memory_count_limit=False +osv_memory_count_limit = {OSV_MEMORY_COUNT_LIMIT} -; --transient-age-limit (for deprecated --osv-memory-age-limit) -transient_age_limit=1.0 +; --transient-age-limit | --osv-memory-age-limit (deprecated) +transient_age_limit = {TRANSIENT_AGE_LIMIT} ; --max-cron-threads -max_cron_threads=2 +max_cron_threads = {MAX_CRON_THREADS} ; --unaccent -unaccent=True +unaccent = {UNACCENT} ; --geoip-db -geoip_database=/usr/share/GeoIP/GeoLite2-City.mmdb +geoip_database = {GEOIP_DATABASE} ; --workers -workers=0 +workers = {WORKERS} ; --limit-memory-soft -limit_memory_soft=2147483648 +limit_memory_soft = {LIMIT_MEMORY_SOFT} ; --limit-memory-hard -limit_memory_hard=2684354560 +limit_memory_hard = {LIMIT_MEMORY_HARD} ; --limit-time-cpu -limit_time_cpu=120 +limit_time_cpu = {LIMIT_TIME_CPU} ; --limit-time-real -limit_time_real=240 +limit_time_real = {LIMIT_TIME_REAL} ; --limit-time-real-cron -limit_time_real_cron=600 +limit_time_real_cron = {LIMIT_TIME_REAL_CRON} ; --limit-request -limit_request=8192 +limit_request = {LIMIT_REQUEST} diff --git a/odoo/odoorc.sh b/odoo/odoorc.sh index acbe0bd..9b841f2 100755 --- a/odoo/odoorc.sh +++ b/odoo/odoorc.sh @@ -35,7 +35,7 @@ defaults=( [HTTP_PORT]=${HTTP_PORT} [XMLRPCS_INTERFACE]=${XMLRPCS_INTERFACE} [XMLRPCS_PORT]=${XMLRPCS_PORT} - [GEVENT_PORT]=${GEVENT_PORT} + [LONGPOLLING_PORT]=${LONGPOLLING_PORT} [HTTP_ENABLE]=${HTTP_ENABLE} [XMLRPCS]=${XMLRPCS} [PROXY_MODE]=${PROXY_MODE} @@ -86,7 +86,6 @@ defaults=( [LIST_DB]=${LIST_DB} [DEV_MODE]=${DEV_MODE} - [DEBUG_MODE]=${DEBUG_MODE} [SHELL_INTERFACE]=${SHELL_INTERFACE} [STOP_AFTER_INIT]=${STOP_AFTER_INIT} [OSV_MEMORY_COUNT_LIMIT]=${OSV_MEMORY_COUNT_LIMIT} @@ -122,252 +121,248 @@ websocket_rate_limit_delay = {WEBSOCKET_RATE_LIMIT_DELAY} ;-----------------------; ; Server startup config ; ;-----------------------; -; `--config | -c` +; --config | -c config = {ODOO_RC} -; `--save` +; --save save = {SAVE} -; `--init | -i` +; --init | -i init = {INIT} -; `--update | -u` +; --update | -u update = {UPDATE} -; `--without-demo` +; --without-demo demo = {DEMO} without_demo = {WITHOUT_DEMO} -; `--import-partial` +; --import-partial import_partial = {IMPORT_PARTIAL} -; `--pidfile` +; --pidfile pidfile = {PIDFILE} -; `--addons-path` +; --addons-path addons_path = {ADDONS_PATH} -; `--upgrade-path` +; --upgrade-path upgrade_path = {UPGRADE_PATH} -; `--load` +; --load server_wide_modules = {SERVER_WIDE_MODULES} -; `--data-dir` +; --data-dir data_dir = {DATA_DIR} ;------; ; HTTP ; ;------; -; `--http-interface | --xmlrpc-interface` +; --http-interface | --xmlrpc-interface http_interface = {HTTP_INTERFACE} -; `--http-port | -p | --xmlrpc-port` +; --http-port | -p | --xmlrpc-port http_port = {HTTP_PORT} -; `--xmlrpcs-interface` +; --xmlrpcs-interface xmlrpcs_interface = {XMLRPCS_INTERFACE} -; `--xmlrpcs-port` +; --xmlrpcs-port xmlrpcs_port = {XMLRPCS_PORT} -; `--gevent-port | --longpolling_port` (deprecated) -gevent_port = {GEVENT_PORT} -longpolling_port = 0 +; --longpolling_port +longpolling_port = {LONGPOLLING_PORT} -; `--no-http | --no-xmlrpc` +; --no-http | --no-xmlrpc http_enable = {HTTP_ENABLE} -; `--no-xmlrpcs` +; --no-xmlrpcs xmlrpcs = {XMLRPCS} -; `--proxy-mode` +; --proxy-mode proxy_mode = {PROXY_MODE} -; `--x-sendfile` +; --x-sendfile x_sendfile = {X_SENDFILE} ;---------------; ; Testing Group ; ;---------------; -; `--test-file` +; --test-file test_file = {TEST_FILE} -; `--test-enable` +; --test-enable test_enable = {TEST_ENABLE} -; `--test-tags` +; --test-tags test_tags = {TEST_FILE} -; `--screencasts` +; --screencasts screencasts = {SCREENCASTS} -; `--screenshots` +; --screenshots screenshots = {SCREENSHOTS} ;---------------; ; Logging Group ; ;---------------; -; `--logfile` +; --logfile logfile = {LOGFILE} -; `--syslog` +; --syslog syslog = {SYSLOG} -; `--log-handler | --log-web (--log-handler=odoo.http:DEBUG) | --log-sql (--log-handler=odoo.sql_db:DEBUG)` +; --log-handler | --log-web (--log-handler=odoo.http:DEBUG) | --log-sql (--log-handler=odoo.sql_db:DEBUG) log_handler = {LOG_HANDLER} -; `--log-db` +; --log-db log_db = {LOG_DB} -; `--log-db-level` +; --log-db-level log_db_level = {LOG_DB_LEVEL} -; `--log-level` +; --log-level log_level = {LOG_LEVEL} ;------------; ; SMTP Group ; ;------------; -; `--email-from` +; --email-from email_from = {EMAIL_FROM} -; `--from-filter` +; --from-filter from_filter = {FROM_FILTER} -; `--smtp` +; --smtp smtp_server = {SMTP_SERVER} -; `--smtp-port` +; --smtp-port smtp_port = {SMTP_PORT} -; `--smtp-ssl` +; --smtp-ssl smtp_ssl = {SMTP_SSL} -; `--smtp-user` +; --smtp-user smtp_user = {SMTP_USER} -; `--smtp-password` +; --smtp-password smtp_password = {SMTP_PASSWORD} -; `--smtp-ssl-certificate-filename` +; --smtp-ssl-certificate-filename smtp_ssl_certificate_filename = {SMTP_SSL_CERTIFICATE_FILENAME} -; `--smtp-ssl-private-key-filename` +; --smtp-ssl-private-key-filename smtp_ssl_private_key_filename = {SMTP_SSL_PRIVATE_KEY_FILENAME} ;----------; ; DB Group ; ;----------; -; `--database | -d` +; --database | -d db_name = {DB_NAME} -; `--db_user | -r` +; --db_user | -r db_user = {DB_USER} -; `--db_password | -w` +; --db_password | -w db_password = {DB_PASSWORD} -; `--pg_path` +; --pg_path pg_path = {PG_PATH} -; `--db_host` +; --db_host db_host = {DB_HOST} -; `--db_port` +; --db_port db_port = {DB_PORT} -; `--db_sslmode` +; --db_sslmode db_sslmode = {DB_SSLMODE} -; `--db_maxconn` +; --db_maxconn db_maxconn = {DB_MAXCONN} -; `--db-template` +; --db-template db_template = {DB_TEMPLATE} ;------------------------------; ; Internationalisation options ; ;------------------------------; -; `--load-language` +; --load-language load_language = {LOAD_LANGUAGE} -; `--language` +; --language language = {LANGUAGE} -; `--i18n-export` +; --i18n-export translate_out = {TRANSLATE_OUT} -; `--i18n-import` +; --i18n-import translate_in = {TRANSLATE_IN} -; `--i18n-overwrite` +; --i18n-overwrite overwrite_existing_translations = {OVERWRITE_EXISTING_TRANSLATIONS} -; `--modules ` +; --modules translate_modules = {TRANSLATE_MODULES} ;----------; ; Security ; ;----------; -; `--no-database-list` +; --no-database-list list_db = {LIST_DB} ;-----; ; WEB ; ;-----; -; `--db-filter` +; --db-filter dbfilter = {DBFILTER} ;------------------; ; Advanced options ; ;------------------; -; `--dev` +; --dev dev_mode = {DEV_MODE} -; -debug_mode = {DEV_MODE} - -; `--shell-interface` +; --shell-interface shell_interface = {SHELL_INTERFACE} -; `--stop-after-init` +; --stop-after-init stop_after_init = {STOP_AFTER_INIT} -; `--osv-memory-count-limit` +; --osv-memory-count-limit osv_memory_count_limit = {OSV_MEMORY_COUNT_LIMIT} -; `--transient-age-limit | --osv-memory-age-limit` (deprecated) +; --transient-age-limit | --osv-memory-age-limit (deprecated) transient_age_limit = {TRANSIENT_AGE_LIMIT} -; `--max-cron-threads` +; --max-cron-threads max_cron_threads = {MAX_CRON_THREADS} -; `--unaccent` +; --unaccent unaccent = {UNACCENT} -; `--geoip-db` +; --geoip-db geoip_database = {GEOIP_DATABASE} -; `--workers` +; --workers workers = {WORKERS} -; `--limit-memory-soft` +; --limit-memory-soft limit_memory_soft = {LIMIT_MEMORY_SOFT} -; `--limit-memory-hard` +; --limit-memory-hard limit_memory_hard = {LIMIT_MEMORY_HARD} -; `--limit-time-cpu` +; --limit-time-cpu limit_time_cpu = {LIMIT_TIME_CPU} -; `--limit-time-real` +; --limit-time-real limit_time_real = {LIMIT_TIME_REAL} -; `--limit-time-real-cron` +; --limit-time-real-cron limit_time_real_cron = {LIMIT_TIME_REAL_CRON} -; `--limit-request` +; --limit-request limit_request = {LIMIT_REQUEST} EOF ) @@ -381,4 +376,4 @@ for key in "${!defaults[@]}"; do done # Store the result to the odoo.conf file -echo "$template" > ${ODOO_RC} \ No newline at end of file +echo "$template" > ${ODOO_RC} diff --git a/odoo/requirements.txt b/odoo/requirements.txt index 8ccada8..3054caa 100644 --- a/odoo/requirements.txt +++ b/odoo/requirements.txt @@ -1 +1,5 @@ -debugpy \ No newline at end of file +jinja2 +sortedcontainers +debugpy +websocket-client +pyOpenSSL diff --git a/postgres/Dockerfile b/postgres/Dockerfile index eb19eb8..bd59d7a 100644 --- a/postgres/Dockerfile +++ b/postgres/Dockerfile @@ -1,13 +1,14 @@ -FROM postgres:15.2 - -# Update apt packages -RUN apt-get update && apt-get upgrade -y +FROM postgres:15.3 #------------------------# # APT Dependencies # #------------------------# -# Unaccent extension dependencies -RUN apt-get install -y postgresql-contrib +# Update apt packages +RUN apt-get update && apt-get install -y \ + # Unaccent extension dependencies + postgresql-contrib \ + # Clean up the apt cache to reduce the image size + && rm -rf /var/lib/apt/lists/* # Copy the script to create the unaccent template -COPY ./entrypoint.sh /docker-entrypoint-initdb.d/entrypoint.sh \ No newline at end of file +COPY ./entrypoint.sh /docker-entrypoint-initdb.d/entrypoint.sh diff --git a/postgres/entrypoint.sh b/postgres/entrypoint.sh index d3511c5..de38ff1 100755 --- a/postgres/entrypoint.sh +++ b/postgres/entrypoint.sh @@ -1,3 +1,3 @@ psql -p 5432 -U odoo -d postgres -c "CREATE DATABASE unaccent_template WITH TEMPLATE = template0" psql -p 5432 -U odoo -d postgres -c "\\c unaccent_template" -psql -p 5432 -U odoo -d postgres -c "CREATE EXTENSION IF NOT EXISTS unaccent;" \ No newline at end of file +psql -p 5432 -U odoo -d postgres -c "CREATE EXTENSION IF NOT EXISTS unaccent;"