Author: David

  • How to deploy Odoo on levv cloud

    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?

  • Deploy your WordPress site easily on levv cloud

    Deploy your WordPress site easily on levv cloud

    WordPress is the world leading Content Management System (CMS), based on PHP and MySQL.

    In this tutorial, I will show you how to deploy your WordPress site on levv cloud, the lightweight and eco-responsible cloud platform. We will also deploy a persistent database for storing your content, using MySQL backed by a persistent volume.

    Let’s dive in!

    levv cloud storage

    Prerequisites to deploy your WordPress site

    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 will need to 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 WordPress application (ours is named "wordpress-project").

    Dockerizing WordPress

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

    At levv, we love Alpine Linux for our containers, as it is very light and easy to use. For this tutorial, we will use the official WordPress image running PHP 8.4 on Alpine Linux.

    Creating persistent storage

    By default, container data is lost after a crash or restart. To persist the WordPress database, we will create a persistent volume.

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

    $ levv volumes create --size 2 wordpress-data

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

    Deploying the 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 levv-wordpress.yaml.

    services:
      db:
        image: mysql:8.0
        environment:
          MYSQL_DATABASE: wordpress
          MYSQL_ROOT_PASSWORD: myR00tPassw0rd4567$$$
          MYSQL_USER: wordpress
          MYSQL_PASSWORD: wordpress
        labels:
          io.levv.size: "small"
        volumes:
          - wordpress-data:/var/lib/mysql
        ports:
          - 3306:3306  # Make db accessible to the wordpress service
      wordpress:
        image: wordpress:php8.4-fpm-alpine
        deploy:
          replicas: 1
        environment:
          WORDPRESS_DB_USER: wordpress
          WORDPRESS_DB_PASSWORD: wordpress
          WORDPRESS_DB_NAME: wordpress
        labels:
          io.levv.public: "true"    
        ports:
          - 80:8080
    
    volumes:
      wordpress-data:

    This is the simplest, albeit not secure, way to deploy WordPress, so do not use this example 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 levv-wordpress.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 (wordpress-project).
    Getting project volumes    successful
    Applying specification    successful
    
    SERVICE    PROJECT  REPLICAS  SIZE  PUBLIC URL                                STATUS    
    db         test     1/1       small <none>                                    DEPLOYED  
    wordpress  test     1/1       nano  https://wordpress-test-c0a0.svc.levv.io   DEPLOYED  
    

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

    Exposing your application to the internet

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

    To expose our WordPress site to the internet, we added the io.levv.public label to the wordpress service in the compose file. As you can notice, the wordpress service does have a public URL, while the db service does not.

    Our WordPress site will be served using HTTPS, using 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:
      wordpress:    
        labels:
          io.levv.public: "true"
        domainname: blog.mydomain.be

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

    Conclusion

    In this tutorial, we deployed a WordPress blog to levv cloud with a single compose file.

    Here’s a recap of what we did to deploy our WordPress site :

    • Create a levv compose file to define a WordPress service and a MySQL service
    • Create a persistent volume for the database service
    • Expose our WordPress service to the world using labels and custom domain names

    As you can see, deploying applications 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?