Skip to content
DantePereyra edited this page Apr 11, 2025 · 7 revisions

Odoo Installation with Docker

Install Docker Compose

First, you have to install docker-compose, this will install docker.

sudo apt install docker-compose

Create the Main Folder

mkdir dockerdoo
cd dockerdoo

Clone Production or Test Instance

We use this version, as is configured to our needs and creates an odoo image from scratch (you'll see the diference later)

git clone -b $Version https://github.com/solvosci/dockerdoo $instance-prod

Replace $Version with the Odoo version (e.g., 17.0). $instance usually is the company name, followed by -prod or -test, depending on the environment.

Edit the .env File

Before running the compose you should evaluate the .env file, which sets most variables used in this project.

nano .env

Update the following variables:

WORKERS=4
ADMIN_PASSWORD=$new_password
DBFILTER=^$instance.*$

Keep in mind, that next variable, only should be updated when Nginx is fully configurated as we do it here.

PROXY_MODE=True

Recommended Ports

Environment HTTP Gevent PostgreSQL
Production 8169 8172 54321
Test 8269 8272 54322

Build Docker Image and Start Container

sudo docker-compose up -d

If you encounter dependency issues related with wheel, edit the Dockerfile and add the following at line 116 and run previous command again:

RUN pip install --upgrade pip setuptools wheel

Check Installation

Visit your server's $IP_or_VMName on port 8169 in a browser. If the database creation screen shows up, it worked.

Database Setup

  • Master password: as in .env
  • Database name: $instance
  • Email: admin
  • Password: $new_password

Optional: Install Webmin

We'll use Webmin as it makes our work easier by having visual files and the capability to edit Nginx archives on the fly.

Switch to Root

sudo -i

Install Webmin

wget -qO- http://www.webmin.com/jcameron-key.asc | gpg --dearmor -o /usr/share/keyrings/webmin.gpg
nano /etc/apt/sources.list.d/webmin.list

Add:

deb [signed-by=/usr/share/keyrings/webmin.gpg] http://download.webmin.com/download/repository sarge contrib
apt update
apt install webmin

Access Webmin

From browser:

To acces Webmin the user/password are the same of the machine's user.

https://localhost:10000

To use Webmin from another machine previously, you have to configure like this (SSH tunnel):

ssh -L 10000:$ip_or_vm:10000 -N $user

Clone Custom Modules

Now it's the moment to clone repositories, we usually use web_responsive that it's an addon from OCA, so your first repo should be /OCA/web. Remember that you have to be root to acces /var/lib/docker/

cd /var/lib/docker/volumes/${instance}_odoo_modules/_data
git clone -b $version https://github.com/$OWNER/$REPO
exit

Restart Odoo

Check if all repos and addons you need are visible on Odoo by restarting it and Update Addon List

sudo docker-compose down
sudo docker-compose up -d

Install & Configure Nginx

Here we'll do a basic Nginx configuration, to use Port 80

Install Nginx

sudo -i
apt install nginx

Create Site Config

First, remove de default archive (with Webmin or by command), and create one called odoo-80

rm /etc/nginx/sites-available/default
nano /etc/nginx/sites-available/odoo

Paste the following (you must change server name with the ip or VM name):

# odoo server
upstream odoo {
    server 127.0.0.1:8169;
}
upstream odoochat {
    server 127.0.0.1:8172;
}
map $http_upgrade $connection_upgrade {
    default upgrade;
    ''      close;
}

server {
    listen 80;
    server_name $ip_or_vm;
    proxy_read_timeout 720s;
    proxy_connect_timeout 720s;
    proxy_send_timeout 720s;
    client_max_body_size 128M;
    large_client_header_buffers 16 32k;

    access_log /var/log/nginx/odoo.access.log;
    error_log /var/log/nginx/odoo.error.log;

    location /websocket {
        proxy_pass http://odoochat;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
        proxy_set_header X-Forwarded-Host $http_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 Strict-Transport-Security "max-age=31536000; includeSubDomains";
    }

    location / {
        proxy_set_header X-Forwarded-Host $http_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;
        proxy_redirect off;
        proxy_pass http://odoo;

        add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
    }

    gzip_types text/css text/scss text/plain text/xml application/xml application/json application/javascript;
    gzip on;
}

Enable the Site

Again, remove the default archive and create a symbolic link with the one created before

rm /etc/nginx/sites-enabled/default
ln -s /etc/nginx/sites-available/odoo-80 /etc/nginx/sites-enabled/odoo-80

Set Proxy Mode

Now, it's moment to end .env configuration we talked before.

nano .env
PROXY_MODE=True

Restart Odoo and Nginx

sudo docker-compose down
sudo docker-compose up -d
systemctl restart nginx.service

If Nginx fails, check:

systemctl status nginx.service

Note: If you follow Odoo's configuration system and cookie_flags fails, check first if Nginx version is 1.18 and remove next lines (requires Nginx 1.19+).

proxy_cookie_flags session_id samesite=lax secure;  # requires nginx 1.19.8

Allow Port 80 (UFW)

After all configuration, it's time to check if it works on port 80 by putting the server name on your search browser and see if Odoo is active, if it doesn´t, check ufw and allow 80/tcp

sudo ufw status
sudo ufw allow 80/tcp

Final Steps

  • Configure languages in Odoo
  • Install required modules
  • Customize environment as needed

Dockerfile vs Image

Using Dockerfile (Recommended)

services:
  odoo:
    # image: iterativodo/dockerdoo:${ODOO_VERSION}
    build:
      context: .
      dockerfile: Dockerfile
    env_file: .env
  • Full control of image
  • Add dependencies
  • Recommended for consistent environments

Using Prebuilt Image

services:
  odoo:
    image: iterativodo/dockerdoo:${ODOO_VERSION}
    # build:
    #   context: .
    #   dockerfile: Dockerfile
    env_file: .env

Use when:

  • Having internet restricted/limited
  • Quick demo needed

Recommendation

Use Dockerfile unless in restricted environments or demos. Toggle in docker-compose.yml by commenting/uncommenting the relevant lines.

TODO List

  • External Nginx setup (here are the basis)
  • Let's Encrypt integration
  • Future log management improvements

Clone this wiki locally