From f77f521bf3e45879876418739ce5c770190b4a0a Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Fri, 25 Apr 2025 15:30:07 -0400 Subject: [PATCH] [IMP] docker and nginx template for odoo 12, 14 and 16 --- docker/docker-compose_odoo_12.0.yml | 50 ++++++++++ docker/docker-compose_odoo_14.0.yml | 50 ++++++++++ docker/docker-compose_odoo_16.0.yml | 50 ++++++++++ ...ate_nginx => template_nginx_odoo_12.0.txt} | 30 +++--- script/nginx/template_nginx_odoo_14.0.txt | 93 +++++++++++++++++++ script/nginx/template_nginx_odoo_16.0.txt | 93 +++++++++++++++++++ 6 files changed, 351 insertions(+), 15 deletions(-) create mode 100644 docker/docker-compose_odoo_12.0.yml create mode 100644 docker/docker-compose_odoo_14.0.yml create mode 100644 docker/docker-compose_odoo_16.0.yml rename script/nginx/{template_nginx => template_nginx_odoo_12.0.txt} (70%) create mode 100644 script/nginx/template_nginx_odoo_14.0.txt create mode 100644 script/nginx/template_nginx_odoo_16.0.txt diff --git a/docker/docker-compose_odoo_12.0.yml b/docker/docker-compose_odoo_12.0.yml new file mode 100644 index 0000000..dcdaccb --- /dev/null +++ b/docker/docker-compose_odoo_12.0.yml @@ -0,0 +1,50 @@ +version: "3.3" +services: + ERPLibre: + image: technolibre/erplibre:1.5.0_1f40c56 + ports: + - 8069:8069 + - 8071:8071 + - 8072:8072 + environment: + HOST: db + PASSWORD: mysecretpassword + USER: odoo + POSTGRES_DB: postgres + STOP_BEFORE_INIT: "False" + DB_NAME: "" + UPDATE_ALL_DB: "False" + depends_on: + - db + # not behind a proxy + #command: odoo --workers 0 + # behind a proxy + #command: odoo --workers 2 --proxy-mode + # For production ready + #command: odoo --workers 2 --proxy-mode --no-database-list + command: odoo + volumes: + # See the volume section at the end of the file + - erplibre_data_dir:/home/odoo/.local/share/Odoo + - ./addons/addons:/ERPLibre/addons/addons + - erplibre_conf:/etc/odoo + restart: always + + db: + image: postgis/postgis:12-3.1-alpine + environment: + POSTGRES_PASSWORD: mysecretpassword + POSTGRES_USER: odoo + POSTGRES_DB: postgres + PGDATA: /var/lib/postgresql/data/pgdata + volumes: + - erplibre-db-data:/var/lib/postgresql/data/pgdata + restart: always + +# We configure volume without specific destination to let docker manage it. To configure it through docker use (read related documentation before continuing) : +# - docker volume --help +# - docker-compose down --help +volumes: + erplibre_data_dir: + erplibre_conf: + erplibre-db-data: diff --git a/docker/docker-compose_odoo_14.0.yml b/docker/docker-compose_odoo_14.0.yml new file mode 100644 index 0000000..aba13eb --- /dev/null +++ b/docker/docker-compose_odoo_14.0.yml @@ -0,0 +1,50 @@ +version: "3.3" +services: + ERPLibre: + image: technolibre/erplibre:1.5.0_odoo_14.0_29e1957 + ports: + - 8069:8069 + - 8071:8071 + - 8072:8072 + environment: + HOST: db + PASSWORD: mysecretpassword + USER: odoo + POSTGRES_DB: postgres + STOP_BEFORE_INIT: "False" + DB_NAME: "" + UPDATE_ALL_DB: "False" + depends_on: + - db + # not behind a proxy + #command: odoo --workers 0 + # behind a proxy + #command: odoo --workers 2 --proxy-mode + # For production ready + #command: odoo --workers 2 --proxy-mode --no-database-list + command: odoo + volumes: + # See the volume section at the end of the file + - erplibre_data_dir:/home/odoo/.local/share/Odoo + - ./addons/addons:/ERPLibre/addons/addons + - erplibre_conf:/etc/odoo + restart: always + + db: + image: postgis/postgis:12-3.1-alpine + environment: + POSTGRES_PASSWORD: mysecretpassword + POSTGRES_USER: odoo + POSTGRES_DB: postgres + PGDATA: /var/lib/postgresql/data/pgdata + volumes: + - erplibre-db-data:/var/lib/postgresql/data/pgdata + restart: always + +# We configure volume without specific destination to let docker manage it. To configure it through docker use (read related documentation before continuing) : +# - docker volume --help +# - docker-compose down --help +volumes: + erplibre_data_dir: + erplibre_conf: + erplibre-db-data: diff --git a/docker/docker-compose_odoo_16.0.yml b/docker/docker-compose_odoo_16.0.yml new file mode 100644 index 0000000..adf1c55 --- /dev/null +++ b/docker/docker-compose_odoo_16.0.yml @@ -0,0 +1,50 @@ +version: "3.3" +services: + ERPLibre: + image: technolibre/erplibre:1.5.0_odoo_16.0_91a7d1b + ports: + - 8069:8069 + - 8071:8071 + - 8072:8072 + environment: + HOST: db + PASSWORD: mysecretpassword + USER: odoo + POSTGRES_DB: postgres + STOP_BEFORE_INIT: "False" + DB_NAME: "" + UPDATE_ALL_DB: "False" + depends_on: + - db + # not behind a proxy + #command: odoo --workers 0 + # behind a proxy + #command: odoo --workers 2 --proxy-mode + # For production ready + #command: odoo --workers 2 --proxy-mode --no-database-list + command: odoo + volumes: + # See the volume section at the end of the file + - erplibre_data_dir:/home/odoo/.local/share/Odoo + - ./addons/addons:/ERPLibre/addons/addons + - erplibre_conf:/etc/odoo + restart: always + + db: + image: postgis/postgis:12-3.1-alpine + environment: + POSTGRES_PASSWORD: mysecretpassword + POSTGRES_USER: odoo + POSTGRES_DB: postgres + PGDATA: /var/lib/postgresql/data/pgdata + volumes: + - erplibre-db-data:/var/lib/postgresql/data/pgdata + restart: always + +# We configure volume without specific destination to let docker manage it. To configure it through docker use (read related documentation before continuing) : +# - docker volume --help +# - docker-compose down --help +volumes: + erplibre_data_dir: + erplibre_conf: + erplibre-db-data: diff --git a/script/nginx/template_nginx b/script/nginx/template_nginx_odoo_12.0.txt similarity index 70% rename from script/nginx/template_nginx rename to script/nginx/template_nginx_odoo_12.0.txt index 9f2fef9..df35507 100644 --- a/script/nginx/template_nginx +++ b/script/nginx/template_nginx_odoo_12.0.txt @@ -1,15 +1,15 @@ -# TODO replace test1 by your hostname and fix server_name and run certbot -upstream erplibretest1 { - server 127.0.0.1:10000; +# TODO replace CHANGEME by your hostname and fix server_name and run certbot +upstream erplibreCHANGEME { + server 127.0.0.1:8069; } -upstream erplibretest1chat { - server 127.0.0.1:10002; +upstream erplibreCHANGEMEchat { + server 127.0.0.1:8072; } server { listen 80; - server_name test1.ca; + server_name CHANGEME.ca; # Add Headers for erplibre proxy mode proxy_set_header X-Forwarded-Host $host; @@ -20,8 +20,8 @@ server { add_header X-XSS-Protection "1; mode=block"; # erplibre request log files - access_log /var/log/nginx/test1-access.log; - error_log /var/log/nginx/test1-error.log; + access_log /var/log/nginx/CHANGEME-access.log; + error_log /var/log/nginx/CHANGEME-error.log; # Increase proxy buffer size proxy_buffers 16 64k; @@ -51,21 +51,21 @@ server { client_max_body_size 1024M; location / { - proxy_pass http://erplibretest1; + proxy_pass http://erplibreCHANGEME; # by default, do not forward anything proxy_redirect off; } location /longpolling { - proxy_pass http://erplibretest1chat; + proxy_pass http://erplibreCHANGEMEchat; } # cache some static data in memory for 60mins. location ~ /[a-zA-Z0-9_-]*/static/ { - proxy_cache_valid 200 302 60m; - proxy_cache_valid 404 1m; - proxy_buffering on; - expires 864000; - proxy_pass http://erplibretest1; + proxy_cache_valid 200 302 60m; + proxy_cache_valid 404 1m; + proxy_buffering on; + expires 864000; + proxy_pass http://erplibreCHANGEME; } } diff --git a/script/nginx/template_nginx_odoo_14.0.txt b/script/nginx/template_nginx_odoo_14.0.txt new file mode 100644 index 0000000..a523a76 --- /dev/null +++ b/script/nginx/template_nginx_odoo_14.0.txt @@ -0,0 +1,93 @@ +# TODO replace CHANGEME by your hostname and fix server_name and run certbot +upstream erplibreCHANGEME { + server 127.0.0.1:8069; +} +upstream erplibreCHANGEMEchat { + server 127.0.0.1:8072; +} + +server { + listen 80; + + server_name CHANGEME.ca; + + # Add Headers for erplibre proxy mode + proxy_set_header X-Forwarded-Host $host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Real-IP $remote_addr; + add_header X-Frame-Options "SAMEORIGIN"; + add_header X-XSS-Protection "1; mode=block"; + + # erplibre request log files + access_log /var/log/nginx/CHANGEME-access.log; + error_log /var/log/nginx/CHANGEME-error.log; + + # Increase proxy buffer size + proxy_buffers 16 64k; + proxy_buffer_size 128k; + + proxy_read_timeout 720s; + proxy_connect_timeout 720s; + proxy_send_timeout 720s; + + # Force timeouts if the backend dies + proxy_next_upstream error timeout invalid_header http_500 http_502 + http_503; + + types { + text/less less; + text/scss scss; + } + + # Enable data compression + gzip on; + gzip_min_length 1100; + gzip_buffers 4 32k; + gzip_types text/css text/less text/plain text/xml application/xml application/json application/javascript application/pdf image/jpeg image/png; + gzip_vary on; + client_header_buffer_size 4k; + large_client_header_buffers 4 64k; + client_max_body_size 1024M; + + location / { + proxy_pass http://erplibreCHANGEME; + # by default, do not forward anything + proxy_redirect off; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_read_timeout 720s; + proxy_connect_timeout 720s; + proxy_send_timeout 720s; + # Add Headers for odoo proxy mode + proxy_set_header X-Forwarded-Host $host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Real-IP $remote_addr; + } + + location /websocket { + proxy_pass http://erplibreCHANGEMEchat; + proxy_read_timeout 720s; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_connect_timeout 720s; + proxy_send_timeout 720s; + # Add Headers for odoo proxy mode + proxy_set_header X-Forwarded-Host $host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Real-IP $remote_addr; + } + + # cache some static data in memory for 60mins. + location ~ /[a-zA-Z0-9_-]*/static/ { + proxy_cache_valid 200 302 60m; + proxy_cache_valid 404 1m; + proxy_buffering on; + expires 864000; + proxy_pass http://erplibreCHANGEME; + } +} diff --git a/script/nginx/template_nginx_odoo_16.0.txt b/script/nginx/template_nginx_odoo_16.0.txt new file mode 100644 index 0000000..a523a76 --- /dev/null +++ b/script/nginx/template_nginx_odoo_16.0.txt @@ -0,0 +1,93 @@ +# TODO replace CHANGEME by your hostname and fix server_name and run certbot +upstream erplibreCHANGEME { + server 127.0.0.1:8069; +} +upstream erplibreCHANGEMEchat { + server 127.0.0.1:8072; +} + +server { + listen 80; + + server_name CHANGEME.ca; + + # Add Headers for erplibre proxy mode + proxy_set_header X-Forwarded-Host $host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Real-IP $remote_addr; + add_header X-Frame-Options "SAMEORIGIN"; + add_header X-XSS-Protection "1; mode=block"; + + # erplibre request log files + access_log /var/log/nginx/CHANGEME-access.log; + error_log /var/log/nginx/CHANGEME-error.log; + + # Increase proxy buffer size + proxy_buffers 16 64k; + proxy_buffer_size 128k; + + proxy_read_timeout 720s; + proxy_connect_timeout 720s; + proxy_send_timeout 720s; + + # Force timeouts if the backend dies + proxy_next_upstream error timeout invalid_header http_500 http_502 + http_503; + + types { + text/less less; + text/scss scss; + } + + # Enable data compression + gzip on; + gzip_min_length 1100; + gzip_buffers 4 32k; + gzip_types text/css text/less text/plain text/xml application/xml application/json application/javascript application/pdf image/jpeg image/png; + gzip_vary on; + client_header_buffer_size 4k; + large_client_header_buffers 4 64k; + client_max_body_size 1024M; + + location / { + proxy_pass http://erplibreCHANGEME; + # by default, do not forward anything + proxy_redirect off; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_read_timeout 720s; + proxy_connect_timeout 720s; + proxy_send_timeout 720s; + # Add Headers for odoo proxy mode + proxy_set_header X-Forwarded-Host $host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Real-IP $remote_addr; + } + + location /websocket { + proxy_pass http://erplibreCHANGEMEchat; + proxy_read_timeout 720s; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_connect_timeout 720s; + proxy_send_timeout 720s; + # Add Headers for odoo proxy mode + proxy_set_header X-Forwarded-Host $host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Real-IP $remote_addr; + } + + # cache some static data in memory for 60mins. + location ~ /[a-zA-Z0-9_-]*/static/ { + proxy_cache_valid 200 302 60m; + proxy_cache_valid 404 1m; + proxy_buffering on; + expires 864000; + proxy_pass http://erplibreCHANGEME; + } +}