How to deploy Odoo on levv cloud

Odoo is the world leading Open-Source ERP and CRM system, made in Belgium 😎

In this tutorial, I will show you how to deploy an instance of Odoo 17 on levv cloud, the lightweight and eco-responsible cloud platform. Odoo uses PostgreSQL to store it’s data, so we will also deploy a PostgreSQL service backed by a persistent volume.

Let’s dive in!

Prerequisites to deploy Odoo on levv cloud

First of all, make sure you have the latest version of the levv CLI installed and available in your $PATH. You can download and install the levv CLI here.

If you don’t have one already, you can create an account on levv cloud, and authenticate using the levv auth login command.

You will also be prompted to create a default project, which we can use to deploy our Odoo application (ours is simply named "odoo").

Dockerizing Odoo

Levv cloud services are based on containers, which are lightweight and portable units of software.

For this example, we will simply use the official Odoo 17 image from DockerHub.

Creating persistent storage

By default, container data is lost after a crash or restart. To persist Odoo’s PostgreSQL database, we will create a persistent volume.

Run the following command to create a volume of 10Gb inside your levv project.

$ levv volumes create --size 10 odoo-db-data

Volumes can also be defined inside the compose file. If the specified volume does not exist yet, levv will create it for you.

Deploying the Odoo application

To deploy containers, our personal favorite is the compose format because of it’s simplicity and ease of use.

Levv cloud uses a compose-compliant specification very similar to Docker Compose to define it’s components, so if you are familiar with Docker you should find your way around pretty quickly.

Let’s create the following YAML file and save it as odoo-levv.yaml.

services:
  web:
    image: odoo:17.0
    ports:
      - "80:8069"
    labels:
      io.levv.public: true
      io.levv.size: mini

  db:
    image: postgres:15
    ports:
      - "5432:5432"
    environment:
      - POSTGRES_DB=postgres
      - POSTGRES_PASSWORD=odoo
      - POSTGRES_USER=odoo
    volumes:
      - odoo-db-data:/var/lib/postgresql/data

volumes:
  odoo-db-data:

This is the simplest, albeit not secure, way to deploy Odoo, so be careful before deploying in production.

Note: when using the ports key, there are two key differences compared to running your compose file on your local machine:

  1. By default, and for security reasons, services are not reachable by other services at all. If you want another service within the same service to access it, you need to define the ports key.
  2. Using the ports key does not make your service available to the outside world. You need to use a label for that, as explained in the section below.

Next, we will deploy our compose file to levv cloud :

$ levv apply -f odoo-levv.yaml

Once our services have been deployed, we will see the following output in the terminal:

No project name has been specified, your default project will be used (odoo).
Getting project volumes    successful
Applying specification    successful

SERVICE    PROJECT  REPLICAS  SIZE  PUBLIC URL                                STATUS    
db         odoo     1/1       nano  <none>                                    DEPLOYED  
web        odoo     1/1       mini  https://web-odoo-f0b0.svc.levv.io         DEPLOYED  

For more information about the levv compose specification, click here.

Exposing our application to the internet

By default, services deployed on levv cloud are not publicly accessible.

To expose our Odoo application to the internet, we added the io.levv.public label to the webservice in the compose file. As you can notice, the web service does have a public URL, while the database db service does not.

By default, our web service will be served using HTTPS, using automatically generated SSL certificates from Let’s Encrypt.

Note: levv takes care of SSL termination. So even if you expose port 80 on the container, the service will be accessible on port 443 via it’s public URL.

We can also link our service to a custom domain name, using the domainname attribute in the compose file.

For example:

service:
  web:    
    labels:
      io.levv.public: "true"
    domainname: odoo.mydomain.be

We then need to add a CNAME record to our Domain Name Servers pointing towards the public URL of our Odoo web service.

Conclusion

In this tutorial, we deployed Odoo 17 to levv cloud with a single compose file.

Here’s a recap of what we did to deploy your Odoo app :

  • Create a levv compose file to define a web service (Odoo) and a db service (PostgreSQL)
  • Create a persistent volume for the database service’s data
  • Expose our Odoo web service to the world using labels and custom domain names

As you can see, deploying application on levv is very easy and secure by design.

If you find this article helpful, or if you have any questions related to deploying your applications on levv cloud, feel free to drop me a line in the comments below!

Want to know more about levv’s cloud? Check our article explaining why choose an eco-friendly cloud solution like levv?

Comments

Leave a Reply

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