Linux

Install Odoo 15 using Docker, Nginx on Ubuntu 22.04

Disclosure: This post may contain affiliate links, which means we may receive a commission if you click a link and purchase something that we recommended.

Install Odoo 15 using Docker Compose, Nginx, SSL on Ubuntu 22.04 . In this tutorial you are going to learn how to install and setup Odoo using Docker and Docker Compose and configure Nginx and Let’s Encrypt SSL and also install PostgreSQL. Installing Odoo using Docker Compose is the easiest way compared to install manually.

Odoo is a management self hosted software to run a business with a top notch user experience. The applications within Odoo are perfectly integrated with each other, allowing you to fully automate your business processes easily.

Prerequisites

  1. Install Docker on Ubuntu 22.04
  2. Install Docker Compose on Ubuntu 22.04.

Please make sure you have completed all the above mentioned steps

  • Domain pointed to your server IP address
  • Docker installed and configured
  • Docker Compose installed and configured

Step 1: Create a project directory

SSH to your server and start by creating a new project directory named odoo-project. You can also name it whatever you need.

mkdir odoo-project

Step 2: Create Docker Compose YAML file

Now navigate inside the project directory and create a new docker-compose.yml file with the following configuration.

cd odoo-project
nano docker-compose.yml

Paste the following configuration.

version: '3.9'
services:
    odoo:
        container_name: odoo
        image: odoo:15.0
        volumes:
            - ./addons-extra:/mnt/extra-addons
            - ./etc/odoo:/etc/odoo
            - odoo-web-data:/var/lib/odoo
        ports:
            - "8069:8069"
        depends_on:
            - postgres
    postgres:
        image: postgres:14
        environment:
            - POSTGRES_DB=postgres
            - POSTGRES_PASSWORD=odoo
            - POSTGRES_USER=odoo
            - PGDATA=/var/lib/postgresql/data/pgdata
        volumes:
            - odoo-db-data:/var/lib/postgresql/data/pgdata
    nginx:
        container_name: nginx
        image: nginx:latest
        restart: unless-stopped
        ports:
            - 80:80
            - 443:443
        volumes:
            - ./nginx/conf:/etc/nginx/conf.d
            - ./certbot/conf:/etc/nginx/ssl
            - ./certbot/data:/var/www/html
    certbot:
        container_name: certbot
        image: certbot/certbot:latest
        command: certonly --webroot --webroot-path=/var/www/html -- email [email protected] --agree-tos --no-eff-email -d domain.com -d www.domain.com
        volumes:
            - ./certbot/conf:/etc/letsencrypt
            - ./certbot/logs:/var/log/letsencrypt
            - ./certbot/data:/var/www/html
volumes:
    odoo-web-data:
    odoo-db-data:

Hit CTRL + X followed by Y and Enter to save the file and exit.

Here are the configuration details.

  • version: Compose file version which is compatible with the Docker Engine. You can check compatibility here.
  • services: here we have 4 services named odoo, postgresnginx and certbot.
  • image: We use latest Odoo 15, Postgres 14, Nginx and Certbot images available in Docker hub.
  • volumes:
    • nginx/conf: here we will place the Nginx configuration file to be synced with the default Nginx conf.d folder inside the container.
    • etc/odoo: here we will place the Odoo 15 database configuration.
    • cedtbot/conf: this is where we will receive the SSL certificate and this will be synced with the folder we wish to inside the container.
    • ports: configure the container to listen upon the listed ports.
    • command: the command used to receive the SSL certificate.

Step 3: Create Odoo Configuration

Now you can use custom Odoo configuration inside the directory as mentioned in the yml file in the Oddo service.

mkdir -p etc/odoo

Create a new file named odoo.conf

nano etc/odoo/odoo.conf

Replace the highlighted values corresponding to your PostgreSQL values.

[options]
; This is the password that allows database operations:
; admin_passwd = admin
db_host = postgres
db_user = odoo
db_password = odoo

Here we will use the hostname same as the PostgreSQL service name.

Step 4: Configure Nginx

Now you can create he default configuration file inside the directory as mentioned in the yml file in the Nginx service.

mkdir -p nginx/conf

Create a new file named default.conf

nano nginx/conf/default.conf

Paste the following configuration and replace the appropriate values with your domain name.

server {
    listen [::]:80;
    listen 80;

    location ~ /.well-known/acme-challenge {
        allow all;
        root /var/www/html;
    }

    location / {
        proxy_set_header X-Real-IP  $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Host $host;
        proxy_pass http://odoo:8069;
    }

    location ~* /web/static/ {
        proxy_set_header X-Real-IP  $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Host $host;
        proxy_pass http://odoo:8069;
    }
}

Step 5: Deploy Odoo with Docker

Now you can make the deployment using the following command.

Start the containers using the following command, you will receive the SSL certificates once the containers are started.

docker-compose up -d

Once all containers are started you will see additional directories for SSL will be created alongside your docker-compose.yml file.

The directory certbot holds all the files related to your SSL certificates.

To view the containers you can execute the following command.

docker-compose ps

Step 6: Configure SSL for Odoo in Docker

As you have received the Let’s Encrypt SSL certificate you can configure HTTPS and setup redirection to HTTPS.

Edit the default.conf and make the following changes.

sudo nano nginx/conf/default.conf
server {
    listen [::]:80;
    listen 80;

    server_name domain.com;

    return 301 https://www.domain.com$request_uri;
}

server {
    listen [::]:443 ssl http2;
    listen 443 ssl http2;

    server_name domain.com;

    ssl_certificate /etc/nginx/ssl/live/domain.com/fullchain.pem;
    ssl_certificate_key /etc/nginx/ssl/live/domain.com/privkey.pem;

    return 301 https://www.domain.com$request_uri;
}
server {
    listen [::]:443 ssl http2;
    listen 443 ssl http2;

    server_name domain.com;

    ssl_certificate /etc/nginx/ssl/live/domain.com/fullchain.pem;
    ssl_certificate_key /etc/nginx/ssl/live/domain.com/privkey.pem;

    location ~ /.well-known/acme-challenge {
        allow all;
        root /var/www/html;
    }

    location / {
        proxy_set_header X-Real-IP  $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Host $host;
        proxy_pass http://odoo:8069;
    }

    location ~* /web/static/ {
        proxy_set_header X-Real-IP  $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Host $host;
        proxy_pass http://odoo:8069;
    }
}

Now restart the Nginx service to load the new configurations.

docker-compose restart nginx

Step 7: Setup Odoo

Now you can visit your domain name on your web browser. You will see the page similar to the one below. Here you can create the database and admin user for your Odoo.

Odoo Installation

Fill in all appropriate values and click create database. Now Odoo will be ready to use.

Odoo 15 with Docker and Nginx

Conclusion

Learn a complete walk through of the Odoo Sales Application with tips on using advanced configurations.

Now you have learned how to install Odoo 15 on your Ubuntu 22.04 with Docker Compose, Nginx and secure it with Let’s Encrypt.

Thanks for your time. If you face any problem or any feedback, please leave a comment below.

Write A Comment

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.