Sejak memasang "dark" theme, saya cenderung menjadi malas menulis. Untuk sementara, dark theme saya disable dulu yaa. Terima kasih (^_^) (bandithijo, 2024/09/15) ●

بسم الله الرحمن الرحيم

Pendahuluan

Catatan kali ini saya mendemonstrasikan proses pemasangan Odoo dengan Docker untuk proses development. Docker dipilih karena membuat proses pemasangan Odoo menjadi lebih praktis.

Latar Belakang Masalah

Memasang paket Odoo dari source code cukup membuat khawatir karena banyaknya paket dependensi yang mesti dipasang. Belum lagi kalau proses nya gagal dengan sebab yang bermacam-macam.

Developer experience memasang Odoo dari source code kurang begitu menyenangkan untuk saya.

Pemecahan Masalah

Oleh karena itu, saya memilih menggunakan pemasangan Odoo dengan Docker image.

Rules for My Development Tools

  1. Odoo data and PostgreSQL data should lay down on the host, not in the Docker volume. This ensures that I don’t need to worry about the data.
  2. It should be possible to doing Docker compose up and down in a robust and flexible manner.

Cooking

  1. Create directory to keep all ingredients in one place

    mkdir odoo-docker
    

    Go in to those directory.

  2. Create file with name docker-compose.yml

    touch docker-compose.yml
    
  3. Open file docker-compose.yml with your favorit text edior and fill in with recipe below

     services:
         odoo:
             container_name: odoo
             image: odoo:17.0
             env_file: .env
             volumes:
                 - ./etc/odoo:/etc/odoo
                 - ./extra-addons:/mnt/extra-addons
                 - ./var/lib/odoo:/var/lib/odoo
             ports:
                 - 8069:8069
             depends_on:
                 - postgres
             networks:
                 - odoo-network
         postgres:
             container_name: odoo-postgres
             image: postgres:16.1
             env_file: .env
             volumes:
                 - ./var/lib/postgresql/data/pgdata:/var/lib/postgresql/data/pgdata
             networks:
                 - odoo-network
     networks:
         odoo-network:
             driver: bridge
    
  4. Please provide directories to store the Odoo data and PostgreSQL data

    mkdir -p ./var/lib/odoo && mkdir -p ./var/lib/postgresql/data/pgdata
    
  5. Compose it up, to cook the recipe

    docker compose up -d
    
    [+] Running 3/3
     ✔ Network 20_odoo-network  Created                               0.1s
     ✔ Container odoo-postgres  Started                               0.6s
     ✔ Container odoo           Started                               0.9s
    

    As you can see, it will create odoo, odoo-postgres container and odoo-network network.

  6. Check all odoo and odoo-postgres container status. It must be Up

    docker ps -n 2
    
    CONTAINER ID   IMAGE           COMMAND                  CREATED         STATUS         PORTS                                                      NAMES
    a3d40f8d967b   odoo:17.0       "/entrypoint.sh odoo"    6 seconds ago   Up 4 seconds   0.0.0.0:8069->8069/tcp, :::8069->8069/tcp, 8071-8072/tcp   odoo
    ad76281699bd   postgres:16.1   "docker-entrypoint.s…"   6 seconds ago   Up 4 seconds   5432/tcp                                                   odoo-postgres
    
  7. Fix Odoo data var/lib/odoo directory permission *

    docker exec -u root odoo chown odoo:odoo -R /var/lib/odoo
    

    * Above command only run once on the first time. Next compose up, you don’t need to run this command again.

  8. Open your browser and access Odoo

    http://localhost:8069
    

    Done! You’re good to go!

Re-cooking

If you have done playing with Odoo, just run

docker compose down
[+] Running 3/3
 ✔ Container odoo           Removed                                 0.9s
 ✔ Container odoo-postgres  Removed                                 0.2s
 ✔ Network 20_odoo-network  Removed                                 0.1s

to taking down all the Odoo container things.

Don’t worry about your data. It safe on var/lib/odoo/.local/ and var/lib/postgresql/data/pgdata/.

And if you want to get Odoo again, just run

docker compose up -d

And you get your data back.

That’s it!

Pesan Penulis

Saya sudah membuatkan GitHub repository untuk mendokumentasikan Odoo docker-compose recipe racikan saya, yang bisa kamu akses di sini, BanditHijio’s Odoo Docker Compose.

Terima kasih sudah mampir yaa.

Referensi

  1. Odoo tutorials
    https://www.odoo.com/slides/all/tag/odoo-tutorials-9
    Diakses tanggal: 2024/06/13
  2. Define modue data
    https://www.odoo.com/documentation/17.0/developer/tutorials/define_module_data.html
    Diakses tanggal: 2024/06/13
  3. Coding guidelines (Module structure, XML files, Python, JavaScript, CSS, and SCSS)
    https://www.odoo.com/documentation/17.0/contributing/development/coding_guidelines.html
    Diakses tanggal: 2024/06/13


Penulis

bandithijo

My journey kicks off from reading textbooks as a former Medical Student to digging bugs as a Software Engineer – a delightful rollercoaster of career twists. Embracing failure with the grace of a Cat avoiding water, I've seamlessly transitioned from Stethoscope to Keyboard. Armed with ability for learning and adapting faster than a Heart Beat, I'm on a mission to turn Code into a Product.

- Rizqi Nur Assyaufi

944e8edeccab170ecee65673676b75514b2f62ed