Professional Documents
Culture Documents
GitHub - Ieski - Doodba - Base Image For Making The Creation of Customized Odoo Environments A Piece of Cake
GitHub - Ieski - Doodba - Base Image For Making The Creation of Customized Odoo Environments A Piece of Cake
GitHub - Ieski - Doodba - Base Image For Making The Creation of Customized Odoo Environments A Piece of Cake
ieski / doodba
forked from Tecnativa/doodba
Base image for making the creation of customized Odoo environments a piece of cake
Apache-2.0 License
0
stars
186
forks
Star
Notifications
master
Go to file
Contribute
Fetch upstream
joao-p-marques … on 11 Mar
View code
Doodba
ci passing
version latest
0B 43 layers
commit 8abe01…
license Apache-2.0
Doodba stands for Docker Odoo Base, and it is a highly opinionated image
ready to put
Odoo inside it, but without Odoo.
What?
Yes, the purpose of this is to serve as a base for you to build your own Odoo project,
because most of them end up requiring a big amount of custom patches, merges,
repositories, etc. With this image, you have a collection of good practices and tools to
enable your team to have a standard Odoo project structure.
https://github.com/ieski/doodba 1/16
18/06/2021 GitHub - ieski/doodba: Base image for making the creation of customized Odoo environments a piece of cake
Why?
Because developing Odoo is hard. You need lots of customizations, dependencies, and if
you want to move from one version to another, it's a pain.
Also because nobody wants Odoo as it comes from upstream, you most likely will need to
add custom patches and addons, at least, so we need a way to put all together and make
it
work anywhere quickly.
How?
You can start working with this straight away with our template.
Image usage
/opt/odoo/custom : The important one
/opt/odoo/custom/entrypoint.d
/opt/odoo/custom/build.d
/opt/odoo/custom/conf.d
/opt/odoo/custom/ssh
/opt/odoo/custom/src
/opt/odoo/custom/src/odoo
/opt/odoo/custom/src/private
/opt/odoo/custom/src/repos.yaml
Automatic download of repos
/opt/odoo/custom/src/addons.yaml
/opt/odoo/custom/dependencies/*.txt
/opt/odoo/auto/odoo.conf
The Dockerfile
Bundled tools
addons
nano
log
pot
psql
inotify
debugpy
https://github.com/ieski/doodba 2/16
18/06/2021 GitHub - ieski/doodba: Base image for making the creation of customized Odoo environments a piece of cake
pudb
git-aggregator
autoaggregate
Example repos.yaml file
odoo
Subproject template
FAQ
Will there be not retrocompatible changes on the image?
README.md
This project is too opinionated, but can I question any of those opinions?
What's this hooks folder here?
How can I pin an image version?
How can I help?
Related Projects
Image usage
Basically, every directory you have to worry about is found inside /opt/odoo . This is
its
structure:
custom/
entrypoint.d/
build.d/
conf.d/
ssh/
config
known_hosts
id_rsa
id_rsa.pub
dependencies/
apt_build.txt
apt.txt
gem.txt
npm.txt
pip.txt
src/
private/
odoo/
addons.yaml
repos.yaml
common/
entrypoint.sh
build.sh
entrypoint.d/
build.d/
conf.d/
auto
https://github.com/ieski/doodba 3/16
18/06/2021 GitHub - ieski/doodba: Base image for making the creation of customized Odoo environments a piece of cake
addons/
odoo.conf
/opt/odoo/custom/entrypoint.d
Any executables found here will be run when you launch your container, before running
the
command you ask.
/opt/odoo/custom/build.d
The resulting set of executables will then be sorted alphabetically (ascending) and then
subsequently run.
/opt/odoo/custom/conf.d
/opt/odoo/custom/ssh
It must follow the same structure as a standard ~/.ssh directory, including config
and
known_hosts files. In fact, it is completely equivalent to ~root/.ssh .
The config file can contain IdentityFile keys to represent the private key that
should be
used for that host. Unless specified otherwise, this defaults to
identity[.pub] ,
id_rsa[.pub] or id_dsa[.pub] files found in this same directory.
This is very useful to use deployment keys that grant git access to your private
repositories.
Example - a private key file in the ssh folder named my_private_key for the host
repo.example.com would have a config entry similar to the below:
Host repo.example.com
IdentityFile ~/.ssh/my_private_key
Or you could just drop the key in id_rsa and id_rsa.pub files and it should work by
default without the need of adding a config file.
https://github.com/ieski/doodba 4/16
18/06/2021 GitHub - ieski/doodba: Base image for making the creation of customized Odoo environments a piece of cake
Host key checking is enabled by default, which means that you also need to provide a
known_hosts file for any repos that you wish to access via SSH.
In order to disable host key checks for a repo, your config would look something like
this:
Host repo.example.com
StrictHostKeyChecking no
For additional information regarding this directory, take a look at this Digital Ocean
Article.
/opt/odoo/custom/src
Here you will put the actual source code for your project.
Recommendation: use repos.yaml for everything except for private , and ignore
in your
.gitignore and .dockerignore files every folder here except private ,
with rules like
these:
odoo/custom/src/*
!odoo/custom/src/private
!odoo/custom/src/*.*
/opt/odoo/custom/src/odoo
You can choose your Odoo version, and even merge PRs from many of them using
repos.yaml . Some versions you might consider:
OCB (Odoo Community Backports), by OCA. The original + some features - some
stability strictness.
/opt/odoo/custom/src/private
/opt/odoo/custom/src/repos.yaml
https://github.com/ieski/doodba 5/16
18/06/2021 GitHub - ieski/doodba: Base image for making the creation of customized Odoo environments a piece of cake
odoo:
defaults:
depth: $DEPTH_MERGE
remotes:
origin: https://github.com/OCA/OCB.git
odoo: https://github.com/odoo/odoo.git
openupgrade: https://github.com/OCA/OpenUpgrade.git
merges:
- origin $ODOO_VERSION
web:
defaults:
depth: $DEPTH_MERGE
remotes:
origin: https://github.com/OCA/web.git
tecnativa: https://github.com/Tecnativa/partner-contact.git
merges:
- origin $ODOO_VERSION
Doodba is smart enough to download automatically git repositories even if they are
missing
in repos.yaml . It will happen if it is used in addons.yaml , except for
the special private
repo. This will help you keep your deployment definitions DRY.
You can configure this behavior with these environment variables (default values shown):
DEFAULT_REPO_PATTERN="https://github.com/OCA/{}.git"
DEFAULT_REPO_PATTERN_ODOO="https://github.com/OCA/OCB.git"
https://github.com/ieski/doodba 6/16
18/06/2021 GitHub - ieski/doodba: Base image for making the creation of customized Odoo environments a piece of cake
# [...]
services:
odoo:
build:
args:
DEFAULT_REPO_PATTERN_ODOO: *origin
# [...]
So, for example, if your repos.yaml file is empty and your addons.yaml
contains this:
server-tools:
- module_auto_update
A /opt/odoo/auto/repos.yaml file with this will be generated and used to download git
code:
/opt/odoo/custom/src/odoo:
defaults:
depth: $DEPTH_DEFAULT
remotes:
origin: https://github.com/OCA/OCB.git
merges:
- origin $ODOO_VERSION
/opt/odoo/custom/src/server-tools:
defaults:
depth: $DEPTH_DEFAULT
remotes:
origin: https://github.com/OCA/server-tools.git
merges:
- origin $ODOO_VERSION
All of this means that, you only need to define the git aggregator spec in
repos.yaml if
anything diverges from the standard:
/opt/odoo/custom/src/addons.yaml
One entry per repo and addon you want to activate in your project. Like this:
https://github.com/ieski/doodba 7/16
18/06/2021 GitHub - ieski/doodba: Base image for making the creation of customized Odoo environments a piece of cake
website:
- website_cookie_notice
- website_legal_page
web:
- web_responsive
Advanced features:
You can bundle several YAML documents if you want to logically group your addons
and some repos are repeated among groups, by separating each document with --- .
Addons under private and odoo/addons are linked automatically unless you specify
them.
You can use ONLY to supply a dictionary of environment variables and a list of
possible
values to enable that document in the matching environments.
DEFAULT_REPO_PATTERN
DEFAULT_REPO_PATTERN_ODOO
DEPTH_DEFAULT
If an addon is found in several places at the same time, it will get linked according
to
this priority table:
i. Addons in private .
ii. Addons in other repositories (in case one is matched in several, it will be random,
BEWARE!). Better have no duplicated names if possible.
iii. Core Odoo addons from odoo/addons .
# Spanish Localization
l10n-spain:
server-tools:
- auditlog
web:
https://github.com/ieski/doodba 8/16
18/06/2021 GitHub - ieski/doodba: Base image for making the creation of customized Odoo environments a piece of cake
---
website:
- website_blog_excertp_img
# different document
- html_image_url_extractor
- html_text
---
ONLY:
- devel
- test
web:
- web_environment_ribbon
---
ONLY:
PGDATABASE:
- prod
server-tools:
- auth_*
---
# Custom repositories
ENV:
DEFAULT_REPO_PATTERN: https://github.com/Tecnativa/{}.git
ODOO_VERSION: 14.0-new-feature
/opt/odoo/custom/dependencies/*.txt
Files to indicate dependencies of your subimage, one for each of the supported package
managers:
https://github.com/ieski/doodba 9/16
18/06/2021 GitHub - ieski/doodba: Base image for making the creation of customized Odoo environments a piece of cake
Will remove all code not used from the image by default (not listed in
/opt/odoo/custom/src/addons.yaml ), to keep it thin.
/opt/odoo/auto/addons
/opt/odoo/auto/odoo.conf
The Dockerfile
I will document all build arguments and environment variables some day, but for now keep
this in mind:
This is just a base image, full of tools. You need to build your project subimage
from
this one, even if your project's Dockerfile only contains these 2 lines:
FROM tecnativa/doodba
MAINTAINER Me <me@example.com>
The above sentence becomes true because we have a lot of ONBUILD sentences here,
so
at least your project must have a ./custom folder along with its Dockerfile
for it
to work.
All should be magic if you adhere to our opinions here. Just put the code where it
should go, and relax.
Bundled tools
https://github.com/ieski/doodba 10/16
18/06/2021 GitHub - ieski/doodba: Base image for making the creation of customized Odoo environments a piece of cake
There is a good collections of tools available in the image that help dealing with Odoo
and
its peculiarities:
addons
A handy CLI tool to automate addon management based on the current environment. It
allows you to install, update, test and/or list private, extra and/or core addons
available to
current container, based on current addons.yaml configuration.
nano
The CLI text editor we all know, just in case you need to inspect some bug in hot
deployments.
log
Just a little shell script that you can use to add logs to your build or entrypoint
scripts:
pot
Little shell shortcut for exporting a translation template from any addon(s). Usage:
pot my_addon,my_other_addon
psql
Environment variables are there so that if you need to connect with the database, you
just
need to execute:
inotify
Enables hot code reloading when odoo is started with --dev and passed reload or
all
as an argument.
Doodba supports this feature under versions 11.0 and later. Check
CLI docs
for details.
debugpy
VSCode debugger. If you use this editor with its python module, you will find it
useful.
To debug at a certain point of the code, add this Python code somewhere:
import debugpy
debugpy.listen(6899)
debugpy.wait_for_client()
debugpy.breakpoint()
To start Odoo within a debugpy environment, which will obey the breakpoints established
in
your IDE (but will work slowly), just add -e DEBUGPY_ENABLE=1 to your odoo
container.
If you use the official template, you can boot it in debugpy mode with:
export DOODBA_DEBUGPY_ENABLE=1
docker-compose -f devel.yaml up -d
Of course, you need to have properly configured your VSCode. To do so, make sure in
your
project there is a .vscode/launch.json file with these minimal contents:
"version": "0.2.0",
"configurations": [
"type": "python",
"request": "attach",
"pathMappings": [
"localRoot": "${workspaceRoot}/odoo",
"remoteRoot": "/opt/odoo"
],
"port": 6899,
"host": "localhost"
https://github.com/ieski/doodba 12/16
18/06/2021 GitHub - ieski/doodba: Base image for making the creation of customized Odoo environments a piece of cake
pudb
This is another great debugger that includes remote debugging via telnet, which can be
useful for some cases, or for people that prefer it over wdb.
import pudb.remote
pudb.remote.set_trace(term_size=(80, 24))
It is safe to use in production environments if you know what you are doing and do
not
expose the debugging port to attackers. Usage:
git-aggregator
We found this one to be the most useful tool for downlading code, merging it and placing
it
somewhere.
autoaggregate
This little script wraps git-aggregator to make it work fine and automatically with
this
image. Used in the template's setup-devel.yaml step.
./odoo:
defaults:
depth: $DEPTH_MERGE
remotes:
ocb: https://github.com/OCA/OCB.git
odoo: https://github.com/odoo/odoo.git
https://github.com/ieski/doodba 13/16
18/06/2021 GitHub - ieski/doodba: Base image for making the creation of customized Odoo environments a piece of cake
merges:
- ocb $ODOO_VERSION
- odoo refs/pull/13635/head
shell_command_after:
odoo
Note that version 9.0 has an odoo binary to provide forward compatibility (but it has
the
odoo.py one too).
Subproject template
That's a big structure! Get it up and running quickly using the
copier template we provide to
help you generate your subproject.
FAQ
It runs triggers when doing the automatic build in the Docker Hub.
Check this.
https://github.com/ieski/doodba 14/16
18/06/2021 GitHub - ieski/doodba: Base image for making the creation of customized Odoo environments a piece of cake
Version-pinning is a good idea to keep your code from differing among image updates.
It's
the best way to ensure no updates got in between the last time you checked the
image and
the time you deploy it to production.
Get any image's code through inspect, running from a computer where the correct image
version is downloaded:
Alternatively, you can browse this image's builds, click on the one you know
it works fine for
you, and search for the digest word using your browser's search in
page system (Ctrl+F
usually).
[...]
10.0: digest:
sha256:fba69478f9b0616561aa3aba4d18e4bcc2f728c9568057946c98d5d3817699e1 size: 4508
[...]
8.0: digest:
sha256:27a3dd3a32ce6c4c259b4a184d8db0c6d94415696bec6c2668caafe755c6445e size: 4508
[...]
9.0: digest:
sha256:33a540eca6441b950d633d3edc77d2cc46586717410f03d51c054ce348b2e977 size: 4508
[...]
Once you find them, you can use that pinned version in your builds, using a Dockerfile
similar to this one:
FROM tecnativa/doodba@sha256:fba69478f9b0616561aa3aba4d18e4bcc2f728c9568057946c98d5d3
Related Projects
Of course,
the Doodba Copier Template.
QA tools for Doodba-based projects
Ansible role for automated deployment / update from Le Filament
https://github.com/ieski/doodba 15/16
18/06/2021 GitHub - ieski/doodba: Base image for making the creation of customized Odoo environments a piece of cake
Releases
1
tags
Packages
No packages published
Languages
Python 56.1%
Dockerfile 37.2%
Shell 6.7%
https://github.com/ieski/doodba 16/16