Install Odoo 19 with PostgreSQL 18 on Ubuntu 24 with SMTP Relay for Outgoing E-mails

Odoo installation using Docker

Odoo installation

The article uses Docker for installing Odoo as it is the easiest way to set up Odoo without worrying about dependencies. So, follow the official docker installation instructions before proceeding further.

After installing Docker, create a directory named odoo. Switch to this directory and create a new file named compose.yml. This file contains instructions for Docker to start different services. There are multiple configuration parameters and we will explore these as we set up our services.

Docker compose file for installing Odoo + PostgreSQL + Nginx-proxy + Acme-companion

To install Odoo 19 alongside PostgreSQL 18.2 as its database, we will use a docker compose file. Additionally, we will use nginx-proxy and acme-companion to set up SSL certificates for our domain. If you are running Odoo on a local development server, follow the instructions in comments. For running on a development server without a domain, you won't be able to set up outgoing e-mail service.

services:
  # Comment nginx-proxy for testing on a development server
  nginx-proxy:
    image: jwilder/nginx-proxy
    container_name: nginx-proxy
    ports:
      - "80:80"
      - "443:443"
    networks:
      - proxy
    volumes:
      - /var/run/docker.sock:/tmp/docker.sock:ro
      - ./certs:/etc/nginx/certs:rw
      - ./vhost.d:/etc/nginx/vhost.d
      - ./html:/usr/share/nginx/html
    restart: always

  # Comment letsencypt-companion for testing on a development server
  letsencrypt-companion:
    image: nginxproxy/acme-companion
    container_name: letsencrypt-companion
    environment:
      - NGINX_PROXY_CONTAINER=nginx-proxy
    networks:
      - proxy
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - ./certs:/etc/nginx/certs:rw
      - ./vhost.d:/etc/nginx/vhost.d
      - ./html:/usr/share/nginx/html
    restart: always
  
  odoo:
    image: odoo:19.0
    container_name: odoo
    depends_on:
      - postgres
    # Uncomments ports for testing on a development server
    # ports:
    #  - "8069:8069"
    environment:
      - HOST=postgres
      - USER=demo_user
      - PASSWORD=demo_password
    # Comment virtual host, virtual port, let's encrypt host and email for testing on a development server
      - VIRTUAL_HOST=demo.example.com
      - VIRTUAL_PORT=8069
      - LETSENCRYPT_HOST=demo.example.com
      - LETSENCRYPT_EMAIL=demo@example.com
    networks:
      - proxy
    volumes:
      - ./data/odoo:/var/lib/odoo
    restart: always
  
  postgres:
    image: postgres:18.2
    container_name: postgres
    environment:
      - POSTGRES_USER=demo_user
      - POSTGRES_PASSWORD=demo_password
      - POSTGRES_DB=demo_database
    networks:
      - proxy
    # For some older versions of PostgreSQL, you will have to use /var/lib/postgresql/data as the mount point
    volumes:
      - ./data/postgres:/var/lib/postgresql
    restart: always

networks:
  proxy:
    name: proxy
    driver: bridge
    

To start the docker container, open a terminal in current working directory and execute the following command.

# Start the docker container in detached mode
docker compose up -d
    

Set correct ownerships and permission for host volumes

The compose file uses host volumes for Docker installation as it makes it easy to backup and migrate to a different machine. After starting the container, check the UID and GID of Odoo container and update the ownership and permissions for Odoo host volume.

# Check UID and GID of a container
docker exec -it odoo id
# Change ownership of Odoo data folder. Assuming the container UID=100 and GID=101
chown -R 100:101 ./data/odoo
# Give Odoo permission to modify contents in folder
chmod -R 755 ./data/odoo

Use a SMTP relay for E-mails

We will use Brevo SMTP relay service for e-mails as it offers a free plan with 300 outgoing e-mails per day. This is more than sufficient for a small-scale business.

Author

Anurag Gupta is an M.S. graduate in Electrical and Computer Engineering from Cornell University. He also holds an M.Tech degree in Systems and Control Engineering and a B.Tech degree in Electrical Engineering from the Indian Institute of Technology, Bombay.


Comment

* Required information
1000
Drag & drop images (max 3)
Captcha Image
Powered by Commentics

Past Comments

No comments yet. Be the first!

Similar content