Odoo follows a multitier architecture, meaning that the presentation, the business logic, and the data storage are separated. More specifically, it uses a three-tier architecture. The presentation tier is a combination of HTML5, JavaScript, and CSS. The logic tier is exclusively written in Python, while the data tier only supports PostgreSQL as a database.

We’re going to set things up in layers to make it easier to meet our needs. The Odoo service will run in one container, and the PostgreSQL database will run in another. These containers will talk to each other through a private network. We’ll use a storage service to keep important data, like addons, logs, and of course the database.

In this first step, we’ll deploy Odoo with just the basic setup—no load balancer, no virtual network, no secrets in environment variables, and non-persistent storage. Let’s get started! The official Odoo repository offers the following commands to install the software using Docker containers.

#Start a PostgreSQL server on a container with persistent data
> docker run -d -p 5432:5432 -v odoo-db:/var/lib/postgresql/data -e POSTGRES_USER=odoo -e POSTGRES_PASSWORD=odoo -e POSTGRES_DB=postgres --name db postgres:15

#Start an Odoo server on a container with persistent data
> docker run -v odoo-data:/var/lib/odoo -d -p 8069:8069 --name odoo --link db:db -t odoo

As you can see, the installation is straightforward—just follow those commands, and you’ll have Odoo up and running on your local machine or a virtual machine using Docker. However, in this guide, we’re aiming to run Odoo using Azure Container Instances, so we’ll need to adjust the previous Docker commands to set up the containers on Azure.

#Create a new resource group
$ az group create --name <your-resource-group-name> --location <your-location>

#Create an Azure Container Registry
$ az acr create --resource-group <ResourceGroupName> --name <RegistryName> --sku Basic

We’ll start by downloading the official Odoo and Postgres Docker images, tagging them, and uploading them to our private Azure Container Registry. This is necessary because Azure currently has some issues pulling the official Odoo image from Docker Hub. Before we proceed, make sure you have Docker and the Azure CLI installed on your local machine so we can run the following commands.

#Login into Azure
> az login

#Login into Azure Registry
> az acr login --name <RegistryName>

#Pull Odoo and Postgres Images
> docker pull odoo:latest && docker pull postgres:15

#Tag your Docker image with the ACR login server name
> docker tag <ImageName>:<Tag> <RegistryName>.azurecr.io/<RepositoryName>:<Tag>

#Push the image to ACR
> docker push <RegistryName>.azurecr.io/<RepositoryName>:<Tag>

After uploading the images to your Azure Container Registry, be sure to enable the “Admin user” option in your Azure Registry Access Keys. This will allow you to access the images using credentials. It is time to create a YAML file with all the instructions needed to set up an Azure Container Group, to host the Odoo and Postgres containers.

name: OdooACG
apiVersion: '2021-10-01' 
location: <your-location> 
properties:
  osType: Linux
  ipAddress:
    type: Public #Public IP to access our deployment
    ports:
      - port: 8069 #Port that will be exposed on the public IP
  imageRegistryCredentials:
    - server: <RegistryName>.azurecr.io
      username: <RegistryUserName>
      password: <RegistryPassword>
  containers:
  - name: db #Postgres Container
    properties:
      image: <RegistryName>.azurecr.io/postgres:15
      resources:
        requests:
          cpu: 1
          memoryInGb: 1.5
      ports:
        - port: 5432 #Postgres port
      environmentVariables: #Default Odoo env variables and values
        - name: 'POSTGRES_DB'
          value: 'postgres'
        - name: 'POSTGRES_PASSWORD'
          value: 'odoo'
        - name: 'POSTGRES_USER'
          value: 'odoo'
  - name: odoo #Odoo Container 
    properties:
      image: <RegistryName>.azurecr.io/odoo:latest
      resources:
        requests:
          cpu: 1
          memoryInGb: 1.5
      ports:
        - port: 8069 #Odoo web port
      environmentVariables:
        - name: 'HOST'
          value: '0.0.0.0' #Reference to the Postgres container as a sidecar
        - name: 'PORT'
          value: '5432' #Postgres listening port
        - name: 'USER'
          value: 'odoo' #POSTGRES_USER value
        - name: 'PASSWORD' #POSTGRES_PASSWORD value
          value: 'odoo'

Finally, let’s deploy the containers using the “deploy-aci.yml” file that we just created. 🚀✨

#Login into Azure
> az login

#Deploy the containers
> az container create --resource-group <your-resource-group> --file deploy-aci.yml

Odoo Azure Container Instances

This brings us to the end of the first part of our guide on installing Odoo Community in Azure. In the upcoming sections, we’ll take this project to the next level by introducing persistent storage and implementing load balancing to ensure a more robust and scalable deployment. Stay tuned—exciting improvements are on the way!

Sources

Odoo. 2024. ReadMe. Retrieved from https://github.com/docker-library/docs/blob/master/odoo/README.md

Microsoft. 2024. YAML reference: Azure Container Instances. Retrieved from https://learn.microsoft.com/en-us/azure/ container-instances/container-instances-reference-yaml#environment variable-object

Microsoft. 2024. Tutorial: Configure a sidecar container for custom container in Azure App Service (preview). Retrieved from https://learn.microsoft.com/en-us/azure/app-service/tutorial-custom-container-sidecar

Rowan Lea. 2023. You Can Give a Static IP to Azure Containers?. Retrieved from https://www.youtube.com/watch?v=WaA5P27IxU4