Odoo is a framework and a suite of open source business applications including CRM, e-commerce, accounting, manufacturing, warehouse, and inventory management to name a few. It is fully customizable to every business need because its extensible architecture allows developers to modify existing applications and create new applications. I have ample experience solving business needs from small clients to larger enterprises using the Odoo framework. In this guide, I will share my personal development environment and help you create your own local development server for Odoo 16 utilizing Docker.
In this guide we will learn how to set up odoo 16 using postgres 15 in docker.
Prerequisites
To follow this guide, you will need:
- An OS with docker installed and running
- Docker compose installed
Installing Docker
To begin, we must first have Docker Engine and Docker Compose installed on our system. The installation will vary depending on what platform you’re on and detailed instructions for your platform can be found from the official Docker documentation. Here, I will share the installation process on Ubuntu 22.04:
Uninstall Old Docker Versions
To make sure your system has no conflicting versions installed, it is a good idea to first run this command to uninstall them:
|
|
Set Up Docker Repository
In order to get the latest Docker packages, we are using the official Docker repository.
Let’s first update the apt package index and install the prerequisite packages:
|
|
Next, we add the official Docker GPG key to ensure authenticity and security of our Docker packages:
|
|
Lastly, the following command will set up the repository:
|
|
Install Docker Engine
Now that the repository is all set up. We just need to update our package index and install the necessary Docker packages:
|
|
Start and enable Docker
|
|
Add the current user to docker group
|
|
Check if Docker is running:
|
|
Installing Docker Compose
If you are running ubuntu, use the following command to install docker-compose
.
|
|
Once installed, confirm that it is running as expected by checking the version:
|
|
Setting up odoo in Docker
Odoo requires a running PostgreSQL server.
Start a PostgreSQL server using this command:
|
|
Start an Odoo instance
|
|
Confirm that they are running with this command:
|
|
The alias of the container running Postgres must be postgres
for Odoo to be able to connect to the Postgres server.
Stop and restart an Odoo instance
|
|
A more robust way to run odoo and the Postgres and the Odoo server is using docker-compose
. Let us examine that in the following section. But first stop and remove the containers.
|
|
Running Odoo using docker-compose
To get started creating your Odoo and PostgreSQL containers, create a directory called odoo in your home directory to store the files that you will create in this tutorial. You’ll use this directory to store all the files that you need to run Odoo.
Run the following commands to create the directory and then cd into it:
|
|
Now open a new blank YAML file called docker-compose.yaml
using vim
or your preferred editor and add the following content:
|
|
The file defines two services. The first is called odoo
, which runs the Odoo application. The second is called postgres
, which is the PostgreSQL database container. Both services reference named volumes that they use to store data outside of the running container instances. Finally, the odoo
service exposes port 8069
on your server to the Odoo container that is running on the same port 8069
.
We also have some environment variables defined that dictate connection settings to the database. I am using odoo as the password but you should consider a strong password.
To generate a password for Odoo and PostgreSQL, use the openssl
command, which should be available on most Linux systems. Run the following command on your server to generate a random set of bytes and print a base64 encoded version that you can use as a password:
|
|
Save and exit the file when you are done editing it.
You’re now ready to start the odoo and postgres containers with the docker-compose command:
|
|
The up
sub-command tells docker-compose
to start the containers and the associated volumes and networks that are defined in the docker-compose.yaml
file. The -d
flag (which stands for daemonize
) tells docker-compose to run the containers in the background so the command doesn’t take over your terminal. docker-compose will print some brief output as it downloads the required Docker images and then starts the containers:
|
|
Confirm that the services are running
|
|
When that’s done, Odoo should be running. You can test that a webserver is running at 127.0.0.1:8069 by fetching the homepage using the curl command:
|
|
This will print out only the HTTP headers from the response:
|
|
The 303 SEE OTHER response means the Odoo server is up and running, but that you should visit another page to complete the installation. The highlighted http://localhost:8069/web Location header indicates where to visit the Odoo installer page in your browser.
Next we’ll set up Nginx to proxy public traffic to the Odoo container.
Setting up Nginx as a proxy server
Putting a web server such as Nginx in front of your Odoo server can improve performance by offloading caching, compression, and static file serving to a more efficient process. We’re going to install Nginx and configure it to reverse proxy requests to Odoo, meaning it will take care of handing requests from your users to Odoo and back again. Using a non-containerized Nginx process will also make it easier to add Let’s Encrypt TLS certificates in the next step.
First, refresh your package list, then install Nginx using apt:
|
|
Next, open up a new Nginx configuration file in the /etc/nginx/conf.d
directory. We’ll call ours odoo.conf
but you could use a different name:
|
|
Paste the following into the new configuration file, being sure to replace your_domain_here
with the domain that you’ve configured to point to your Odoo server. This should be something like odoo.citizix.com
, for instance:
|
|
This configuration is HTTP-only for now, as we’ll let Certbot take care of configuring TLS in the next step. The rest of the configuration file sets up logging locations and then passes all traffic, as well as some important proxy headers, along to http://localhost:8069
, the Odoo container that we started up in the previous step.
Save and close the file.
Use nginx -t to verify that the configuration file syntax is correct:
|
|
And finally, reload the nginx service with the new configuration:
|
|
Your Odoo site should now be available on plain HTTP. Load http://your_domain_here
(you may have to click through a security warning) and you will get odoo landing configuration page.
Now that you have your site up and running over HTTP, it’s time to secure the connection with Certbot and Let’s Encrypt certificates. You should do this before going through Odoo’s web-based setup procedure.
Setting up TLS with Certbot
Next, run certbot
in --nginx
mode, and specify the same domain that you used in the Nginx server_name
configuration directive:
|
|
You’ll be prompted to agree to the Let’s Encrypt terms of service, and to enter an email address.
Afterwards, you’ll be asked if you want to redirect all HTTP traffic to HTTPS. It’s up to you, but this is generally recommended and safe to do.
After that, Let’s Encrypt will confirm your request and Certbot will download your certificate.
Certbot will automatically reload Nginx with the new configuration and certificates. Reload your site in your browser and it should switch you over to HTTPS automatically if you chose the redirect option.
Your site is now secure and it’s safe to continue with the web-based setup steps.
Setting up
Back in your web browser, reload the page. You should now have Odoo’s database configuration page open via a secure https://
connection. Now you can enter usernames and passwords safely to complete the installation process.
The information that you fill in on this page will tell the Odoo application how to create its PostgreSQL database and details about the default administrative user.
Once you fill them you should be able to configure and use your odoo set up.
Conclusion
In this tutorial, you launched the Odoo ERP app and a PostgreSQL database using Docker Compose, then set up an Nginx reverse proxy and secured it using Let’s Encrypt TLS certificates.
You’re now ready to start building your ERP website using the supplied modules. For more information about using Odoo please see the official Odoo documentation.