Skip to content

Instantly share code, notes, and snippets.

@eliyas5044
Last active September 6, 2022 10:21
Show Gist options
  • Save eliyas5044/e93cab07ef609d48a929d94011ff86e3 to your computer and use it in GitHub Desktop.
Save eliyas5044/e93cab07ef609d48a929d94011ff86e3 to your computer and use it in GitHub Desktop.
Run Odoo with Docker
server {
listen 80;
server_name ${ODOO_HOST} default_server;
location ~ /.well-known/acme-challenge {
allow all;
root /var/www/odoo;
}
}
server {
listen 80;
listen 443 ssl http2;
server_name ${ODOO_HOST} default_server;
if ( $scheme = "http" ) {
return 301 https://$host$request_uri;
}
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 /longpolling {
proxy_pass http://odoo:8072;
}
location / {
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_redirect off;
proxy_pass http://odoo:8069;
}
location ~ /.well-known/acme-challenge {
allow all;
root /var/www/odoo;
}
ssl_certificate /etc/letsencrypt/live/${ODOO_HOST}/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/${ODOO_HOST}/privkey.pem;
# common gzip
gzip_types text/css text/scss text/plain text/xml application/xml application/json application/javascript;
gzip on;
}
version: "3.9"
services:
odoo:
image: odoo:15.0
depends_on:
- db
ports:
- 8069:8069
- 8072:8072
volumes:
- odoo-data:/var/lib/odoo
- ./config:/etc/odoo
- ./addons:/mnt/extra-addons
environment:
- HOST=db
- USER=odoo
- PASSWORD=odoo
networks:
- odoo
db:
image: postgres:13
environment:
- POSTGRES_DB=postgres
- POSTGRES_PASSWORD=odoo
- POSTGRES_USER=odoo
- PGDATA=/var/lib/postgresql/data/pgdata
volumes:
- odoo-db:/var/lib/postgresql/data/pgdata
networks:
- odoo
nginx:
image: nginx:latest
volumes:
- ./nginx/templates:/etc/nginx/templates
- certbot-etc:/etc/letsencrypt
- certbot-var:/var/lib/letsencrypt
- web-root:/var/www/odoo
networks:
- oehealth
ports:
- 443:443
depends_on:
- nginx_cert
- odoo
environment:
- ODOO_HOST=example.com
nginx_cert:
image: nginx:latest
volumes:
- ./nginx/templates_http:/etc/nginx/templates
- certbot-etc:/etc/letsencrypt
- certbot-var:/var/lib/letsencrypt
- web-root:/var/www/odoo
networks:
- oehealth
ports:
- 80:80
depends_on:
- odoo
environment:
- ODOO_HOST=example.com
certbot:
image: certbot/certbot
volumes:
- certbot-etc:/etc/letsencrypt
- certbot-var:/var/lib/letsencrypt
- web-root:/var/www/odoo
depends_on:
- nginx_cert
command: certonly --webroot --email admin@example.com --agree-tos --no-eff-email -n -w /var/www/odoo --cert-name example.com -d example.com
volumes:
odoo-data:
driver: local
odoo-db:
driver: local
web-root:
driver: local
certbot-etc:
driver: local
certbot-var:
driver: local
networks:
odoo:
driver: bridge
[options]
; addons_path = /mnt/extra-addons
; data_dir = /var/lib/odoo
; admin_passwd = 4a1e354cee68ef4b850a81ab
; csv_internal_sep = ,
; db_maxconn = 64
; db_name = False
; db_template = template1
; dbfilter = .*
; debug_mode = True
; email_from = None
; limit_memory_hard = 2684354560
; limit_memory_soft = 2147483648
; limit_request = 8192
; limit_time_cpu = 60
; limit_time_real = 120
; list_db = True
; log_db = False
; log_handler = [':INFO']
; log_level = info
; logfile = None
; longpolling_port = 8072
; max_cron_threads = 2
; osv_memory_age_limit = 1.0
; osv_memory_count_limit = False
; smtp_password = False
; smtp_port = 25
; smtp_server = localhost
; smtp_ssl = False
; smtp_user = False
; workers = 0
; xmlrpc = True
; xmlrpc_interface =
; xmlrpc_port = 8069
; xmlrpcs = True
; xmlrpcs_interface =
; xmlrpcs_port = 8071
; proxy_mode = True

Let's assume, we're working on the home directory.

  • Create odoo directory
mkdir -p ~/odoo
  • Create docker-compose.yml in the odoo folder
  • Paste contents from docker-compose.yml file

Local Server

  • If we're trying to run in locally, just keep odoo and db services from the docker compose file.
  • Need to keep only odoo-data, odoo-db volumes

Production Server

  • If we're trying to run in the server, we need to keep all services.
  • Create a nginx directory in the odoo folder
  • Create a file default.conf.template inside ./nginx/templates_http folder
  • Paste contents from default_http.conf into ./nginx/templates_http/default.conf.template
  • Create a file default.conf.template inside ./nginx/templates_https folder
  • Paste contents from default_https.conf into ./nginx/templates_https/default.conf.template
  • You need to enable longpolling_port, workers and proxy_mode

Configure Odoo

  • If we need to configure odoo, create ./config/odoo.conf file into odoo folder
  • Paste contents from odoo.conf file

Docker commands

docker compose up -d

Access Odoo

For further information, please check Official Docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment