How to Deploy Odoo on a Linux Server Using Docker: A Step-by-Step Guide

When I was first introduced to Odoo, I downloaded the book <<Odoo 15 Development Essentials – Fifth Edition>> by Daniel Reis to learn how to develop for Odoo. This book has fifty chapters and I must be ready to work in Odoo in less than two weeks. My mentor ask me to only read the first four chapters to have the key concepts of Odoo and it would be suitable for the work and guess what, he was right. For the eleven remaining chapters, I must read them only when having a specific task to accomplish.

The second essential skill I must acquire quickly on Odoo was to deploy Odoo CE in production on a Linux server and set up an SSL certificate. The tutorial from Linuxize helped me a lot; even today, I used it when deploying Odoo on a Linux server.

Why am I writing this tutorial?

When deploying Odoo with Docker behind a reverse proxy in some of my servers, the Linuxize tutorial doesn’t cover my needs. I searched a lot on the internet to be able to deploy Odoo well with Docker so I decided to write a simple tutorial to explain the process I used to figure it out.

Prerequisite

To follow me along with this tutorial, you need to have access to a Linux server with Docker and docker-compose installed. I have written a tutorial on how to install Docker and docker-compose on a Ubuntu server.

You can practice this tutorial on DigitalOcean Droplet with 200$ free credits for 60 days. All you need to do is to create a small droplet(Linux Server) there and you are ready. Now let’s focus on the tutorial.

1. Odoo without a domain name

Login to your Linux server and create a new directory called odoo for our new Odoo installation. Inside that folder, create a file called docker-compose.yml and paste in the following content:

This docker-compose file has two services and two volumes and is organized as follows:

1.1. The odoo service

In this service,

  • we indicate the version of Odoo we want to use. Note that every year, a new version of Odoo is released during Odoo Experience Event roughly in November.
  • We bind the host volume extra-addons to /mnt/extra-addons inside the container. The extra-addons folder is where we will put all our custom modules. Don’t forget to create that folder in the same directory where we have our docker-compose.yml file, in our case the directory odoo.
  • We create the folder etc/odoo inside the same folder as the docker-compose.yml file and bind that folder to the directory /etc/odoo inside the container. The etc/odoo in the host machine is where we’ll store all the odoo configuration files like odoo.conf.
  • Finally, for this service, we bind the name volume odoo-web-data to /var/lib/odoo to store the data of this odoo instance.

In the folder /etc/odoo we created earlier, create a new file inside and paste the following content:

The content of this file is used to configure our odoo installation.

  • addons_path is the same path we put in our docker-compose.yml file. It tells the odoo system where to find custom add-ons. If you have multiple places where you store your custom add-ons, you can list them here and separate them with a comma(“,“)
  • admin_passwd is the master password of the odoo installation. Keep it secure and secret. It’s used to perform various operations like creating a new database and deleting or backup databases.
  • db_host, db_user, and db_password are the same information available in the Postgres service and tell the odoo system how to connect to the database.

1.2. The Postgres service

As you know, Odoo only supports Postgres as RDBMS. Here you can choose the version of Postgres you want to use. The remaining elements are trivial.

1.3. Launch Odoo

At this step, we’re good to launch our odoo instance. Just run the command:

docker compose up

And navigate to http://<YOUR_IP_ADDRESS>:8069 to create a new database.


The first launch of Odoo

You know how to deploy Odoo in a Linux server using docker. But that is not all. Of course, in a serious business, you can’t work with the IP address or send an IP to your employees to access your ERP. You need a custom and secure domain name for your Odoo instance and that is the point of the next section.

2. Secure your Odoo instance with a domain name and SSL certificate

As far as I am concerned, the easiest and best way is to run Odoo behind a reverse proxy server like Traefik, caddyserver, nginx-proxy manager, and Nginx-proxy. For this tutorial, I would use Nginx-proxy. as the reverse proxy.

2.1. Installation of Nginx-proxy and acme-compagnon

Nginx proxy is a container running Nginx and docker-gen which is a service that generates reverse proxy configs for Nginx and reloads Nginx when containers are started or stopped.

This container is mounted on a docker socket to capture all events created by docker to be able to proxied any container with an env variable VIRTUAL_HOST defined. All containers that want to be proxied by Nginx-proxy must be connected to the same network. To know more about Nginx-proxy, visit the GitHub of the project.

ACME-compagnon is a compagnon for Nginx-proxy responsible to automate the creation, renewal, and use of SSL certificates for proxied Docker containers through ACME protocol. For more information about acme-compagnon, visit the GitHub of the project.

I have a ready-to-use template for Nginx-proxy in my Gitlab repository. You need to clone and run it. This configuration is well-suited for a production environment. Just type the following command in your terminal to make it run in less than a minute.

cd ~
git clone https://gitlab.com/tderick/nginx-proxy-conf.git 
docker network create nginx-proxy
cd nginx-proxy-conf
docker compose up --build -d

For the following part, you need to have a domain name pointing to your server. In this tutorial, I’ll use the subdomain odoo.temfack.com.

2.2. New configs

The new config files are the following.

In the docker-compose file, we have added an Nginx service. The purpose of Nginx here is to serve static content. The important thing to notice in this service is where we bind the Nginx configuration file. You should create the folder nginx/conf in the same folder as the docker-compose.yml file and inside that folder create a file called default.conf and paste in the content of default.conf found in the above gist.

As we used Nginx-proxy, specify your domain name in the environment and the email that would be used to issue your free SSL certificate from Let’s Encrypt. Don’t forget to add proxy_mode=True in the odoo.conf because we have to deploy odoo now behind a reverse proxy.

Run the command:

docker compose up --build --force-recreate 

and open your domain name to look at the result.

odoo view
The final result

3. Enable Multi-processing

Odoo operates in multithreading mode as a default setting, but for optimal system stability and resource utilization, it is advisable to switch to the multiprocessing server during production deployments. To activate multiprocessing, it is necessary to adjust the Odoo configuration and specify the number of worker processes as a non-zero value. The number of workers is determined by the available CPU cores and RAM of the system. To learn more about the value to add to the odoo.conf, check the official documentation.

Wrap up

In this tutorial, I tried my best to share with you my experience concerning the deployment of Odoo in production with docker. If at some point in time, my explanation seems to not be clear to you, just leave a comment and I would correct that place.

I’m a newbie Odoo developer and I would share many contents and tips about it during my learning journey. Consider subscribing to my newsletter to not miss anything from me. Thanks for reading.

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top
porn by force indianhub.me indian girls fuck photos
kannada auntys sex videos ounoun.com indian local sex videos com
kolkata teen sex indianporncave.mobi telugu xxx .com
gotporn redwap3.com indian men naked
m taxi 69 hotindiantube.net incent porn
indian awesome sex tryporn.net xnll
gand porn analpornstars.info xnxx jabardasti
dj-punjab.in xxxvideohd.info mp3 hindi mp3
home sex malayalam pornstarsporn.info indian sex vid
download indian girl sex video indiapornfilm.pro desi xvedios
ndiansex babezporn.com unexpected sex
xvideo plumber xxx-tube-list.net kannada real sex
sexy video rap arabpornsamples.com poonam pandey xvideo
softcore 69 tryporno.net fuck.sc
shemalexnxx screwmyindianwife.info desi choda video