Odoo is an open source ERP and CRM software written in python. To install Odoo using docker, first install docker using
wget -qO- https://get.docker.com/ | sh
Odoo use PostgreSQL server to store database. Lets create a postgres docker container.
docker run -d -e POSTGRES_USER=odoo -e POSTGRES_PASSWORD=your-password-here -e POSTGRES_DB=postgres --name odoo-db postgres:10
In above command, replace your-password-here with a secure password.
Create a Odoo container with
docker run -d -p 127.0.0.1:8069:8069 -p 127.0.0.1:8072:8072 --name odoo --link odoo-db:db -t odoo
If container did not start on boot, enable start on boot with
docker update --restart=unless-stopped CONTAINER_ID
You can find CONTAINER_ID with docker ps or docker ps -a command.
Next we need to configure a domain to be used with Odoo. For this, we use nginx web server as reverse proxy. Lets install nginx web server with command
apt install nginx
Install LetsEncrypt with
wget https://raw.githubusercontent.com/serverok/server-setup/master/install/letsencrypt.sh bash ./letsencrypt.sh
Before getting SSL, we need to configure Nginx web server with a simple config file for our domain.
vi /etc/nginx/sites-enabled/odoo.conf
Add
server { listen 80; server_name YOUR-DOMAIN_HERE; root /var/www/html; }
Restart nginx
systemctl restart nginx
At this point, nginx will serve the web site from /var/www/html folder. Lets get an SSL certficate using certbot
certbot --authenticator webroot --webroot-path /var/www/html --installer nginx -d YOUR-DOMAIN_HERE
Once you have SSL, we need to replace the nginx config with proper nginx config
vi /etc/nginx/sites-enabled/odoo.conf
Replace everything in the file with following content.
upstream odoo { server 127.0.0.1:8069; } upstream odoo-chat { server 127.0.0.1:8072; } server { listen 80; server_name YOUR-DOMAIN-HERE; location ^~ /.well-known/acme-challenge/ { root /var/www/html; } location / { return 301 https://YOUR-DOMAIN-HERE$request_uri; } } server { listen 443 ssl http2; server_name YOUR-DOMAIN-HERE; ssl_certificate /etc/letsencrypt/live/YOUR-DOMAIN-HERE/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/YOUR-DOMAIN-HERE/privkey.pem; include /etc/letsencrypt/options-ssl-nginx.conf; ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; resolver 8.8.8.8 8.8.4.4; access_log /var/log/nginx/odoo-access.log; error_log /var/log/nginx/odoo-error.log; proxy_read_timeout 720s; proxy_connect_timeout 720s; proxy_send_timeout 720s; 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 / { proxy_redirect off; proxy_pass http://odoo; } location /longpolling { proxy_pass http://odoo-chat; } location ~* /web/static/ { proxy_cache_valid 200 90m; proxy_buffering on; expires 864000; proxy_pass http://odoo; } gzip_types text/css text/less text/plain text/xml application/xml application/json application/javascript; gzip on; }
Restart nginx
systemctl restart nginx
At this point, if you go to your web site, you will see Odoo install screen. All you need to do here is enter a database name and fill some information. You can select any database name, installer will create the database.
Leave a Reply