Mudah Setup Odoo untuk Development dengan Docker
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
- 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.
- It should be possible to doing Docker compose up and down in a robust and flexible manner.
Cooking
-
Create directory to keep all ingredients in one place
$ mkdir odoo-docker
Go in to those directory.
-
Create file with name
docker-compose.yml
$ touch docker-compose.yml
-
Open file
docker-compose.yml
with your favorit text editor and fill in with recipe belowdocker-compose.yml1services:2 odoo:3 container_name: odoo4 image: odoo:17.05 env_file: .env6 volumes:7 - ./etc/odoo:/etc/odoo8 - ./extra-addons:/mnt/extra-addons9 - ./var/lib/odoo:/var/lib/odoo10 ports:11 - 8069:806912 depends_on:13 - postgres14 networks:15 - odoo-network16 postgres:17 container_name: odoo-postgres18 image: postgres:16.119 env_file: .env20 volumes:21 - ./var/lib/postgresql/data/pgdata:/var/lib/postgresql/data/pgdata22 networks:23 - odoo-network24networks:25 odoo-network:26 driver: bridge -
Please provide directories to store the Odoo data and PostgreSQL data
$ mkdir -p ./var/lib/odoo && mkdir -p ./var/lib/postgresql/data/pgdata
-
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 andodoo-network
network. -
Check all
odoo
andodoo-postgres
container status. It must beUp
$ 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
-
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.
-
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
- Odoo tutorials
https://www.odoo.com/slides/all/tag/odoo-tutorials-9
Diakses tanggal: 2024/06/13 - Define modue data
https://www.odoo.com/documentation/17.0/developer/tutorials/define_module_data.html
Diakses tanggal: 2024/06/13 - 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