forvas
forvas

Reputation: 10189

What is the best way to deploy Odoo with Docker?

I am deploying Odoo 15 with Docker, and I am using the docker-compose.yml recommended in https://hub.docker.com/_/odoo. As you can see, the following volumes are created for the web service:

volumes:
 - odoo-web-data:/var/lib/odoo
 - ./config:/etc/odoo
 - ./addons:/mnt/extra-addons

The conclusion here is that there is a volume named odoo-web-data for the Odoo core, and two binds, which I guess they are in order to modify easily the configuration file and the extra addons.

If I expect to add a lot of modules in the local directory addons, in order to add those modules to the container directory extra-addons, and therefore adding them to the Odoo running in the container, does it make sense to add them this way?

For example, I am going to add the whole Odoo Community Association l10n-spain repository from GitHub (with all their addons), among others. Obviously I will do git pull every now and again to update the repository.

As I am not an expert on Docker, do you think this structure is the best? What if I need to update the Odoo core in the named volume?

Upvotes: 3

Views: 3131

Answers (3)

Obay Abd-Algader
Obay Abd-Algader

Reputation: 1267

The community has developed many templates for doing this, here are some of them:

Upvotes: 0

Ahrimann Steiner
Ahrimann Steiner

Reputation: 1314

The DigitalOcean's guide explains in details how to deploy odoo with docker using nginx (on Ubuntu 20.04):

Step 1 — Installing Docker Compose

sudo apt update
sudo apt install docker-compose

Step 2 — Running Odoo and PostgreSQL with Docker Compose

nano docker-compose.yml

version: '3'
services:
  odoo:
    image: odoo:15.0
    env_file: .env
    depends_on:
      - postgres
    ports:
      - "127.0.0.1:8069:8069"
    volumes:
      - data:/var/lib/odoo
  postgres:
    image: postgres:13
    env_file: .env
    volumes:
      - db:/var/lib/postgresql/data/pgdata

volumes:
  data:
  db:

...
...

Step 3 — Installing and Configuring Nginx

...
...
sudo nano /etc/nginx/sites-available/odoo.conf

server {
    listen       80;
    listen       [::]:80;
    server_name  your_domain_here;

    access_log  /var/log/nginx/odoo.access.log;
    error_log   /var/log/nginx/odoo.error.log;

    location / {
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-Host $host;
      proxy_set_header X-Forwarded-Proto https;
      proxy_pass http://localhost:8069;
  }
}

Step 4 — Installing Certbot and Setting Up TLS Certificates

sudo apt install certbot python3-certbot-nginx
sudo certbot --nginx -d your_domain_here

Step 5 — Setting Up Odoo

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 (Database Name, Email, Password, Demo data...) ... ...

Full documentation here : https://www.digitalocean.com/community/tutorials/how-to-install-odoo-on-ubuntu-20-04-with-docker

Upvotes: 4

CZoellner
CZoellner

Reputation: 14768

There shouldn't be the core in volume odoo-web-data, only the filestore and sessions. The core itself is already installed in the docker image as you can see here

# Install Odoo
ENV ODOO_VERSION 15.0
ARG ODOO_RELEASE=20220718
ARG ODOO_SHA=dc4a5b8c5be8f873e751539117f5aa41d9f7b217
RUN curl -o odoo.deb -sSL http://nightly.odoo.com/${ODOO_VERSION}/nightly/deb/odoo_${ODOO_VERSION}.${ODOO_RELEASE}_all.deb \
    && echo "${ODOO_SHA} odoo.deb" | sha1sum -c - \
    && apt-get update \
    && apt-get -y install --no-install-recommends ./odoo.deb \
    && rm -rf /var/lib/apt/lists/* odoo.deb

So updating the core usually means: Build or pull the image (for example latest) and recreate the container(s). And sometimes you also have to make an update for all modules for your existing databases, because the core (code) has changed.

Upvotes: 1

Related Questions