doodba (Docker Odoo Base)
repository·master·Indexed 20 days ago
https://github.com/tecnativa/doodbaA highly opinionated Docker base image for Odoo developers built on Debian. Doodba provides a structured environment to manage Odoo versions, custom patches, third-party repositories, and dependencies. It includes tools like the `addons` CLI for module management and `autoaggregate` for git repository aggregation via `repos.yaml` and `addons.yaml` configurations.
What's inside doodba
- Doodba (Docker Odoo Base) is a highly opinionated Docker base image designed to facilitate building custom Odoo projects. It does not include Odoo itself; instead, it provides a standardized project structure, a collection of best practices, and tools to manage the complex customizations (patches, merges, repositories, and dependencies) typically required when developing with Odoo. It is built on top of Debian.
Enable hot code reloading with `inotify`
masterDoodba supports hot code reloading for Odoo versions 11.0 and later. When starting Odoo with the
--devflag, you can passreloadorallas an argument to enable this feature viainotify.If you use the Doodba Copier Template, this is enabled by default in development environments.
Manage project source code with repos.yaml and addons.yaml
masterProject source code resides in
/opt/odoo/custom/src. Doodba uses two main files to manage this:repos.yaml: A git-aggregator configuration that defines remotes, targets (branches), and merges for your repositories. This is used to pull in Odoo core, OCA modules, or custom repos at build time.addons.yaml: Defines which specific addons/modules from the downloaded repositories should be activated in your project.
Important Folders:
/opt/odoo/custom/src/odoo: REQUIRED. Contains the Odoo source code./opt/odoo/custom/src/private: REQUIRED. Contains your project's private addons.
Recommendation: Use
repos.yamlfor everything except theprivatefolder. In your.gitignoreand.dockerignore, ignore everything inodoo/custom/src/*except for theprivatefolder.Understand the Doodba directory structure
masterDoodba organizes files into three main directories under
/opt/odoo. Understanding this structure is key to customizing your Odoo environment:/opt/odoo/custom: The primary location for your project-specific files (source code, configuration, dependencies, SSH keys)./opt/odoo/common: Contains internal logic and shared scripts used by the build and entrypoint processes./opt/odoo/auto: Contains automatically generated files at build time, such as symlinks to selected addons and the mergedodoo.conf.
Note: For Doodba to function correctly, your Odoo source code must be located in the
odoofolder within the structure.Customize repository patterns via build arguments
masterDoodba automatically downloads repositories based on
DEFAULT_REPO_PATTERNandDEFAULT_REPO_PATTERN_ODOO. You can override these patterns by passing them as build arguments in yourdocker-compose.yamlfile.services: odoo: build: args: DEFAULT_REPO_PATTERN: &origin "https://github.com/Tecnativa/{}.git" DEFAULT_REPO_PATTERN_ODOO: *originConfigure custom entrypoints and build scripts
masterYou can extend the container's lifecycle by placing executables in the following directories within
/opt/odoo/custom:/opt/odoo/custom/entrypoint.d: Executables here run when the container launches, immediately before the main command./opt/odoo/custom/build.d: Executables here are aggregated with/opt/odoo/common/build.d, sorted alphabetically, and executed during the build process.
Build a project subimage from Doodba
masterDoodba is a base image containing tools and
ONBUILDinstructions. You must build your own project subimage from it. Your project'sDockerfileshould look like this:FROM tecnativa/doodba MAINTAINER Me <me@example.com>Crucial: Your project must include a
./customfolder alongside yourDockerfilefor theONBUILDlogic to work.Set up SSH keys and deployment keys
masterThe
/opt/odoo/custom/sshdirectory functions like a standard~/.sshdirectory (equivalent to~root/.ssh). This is used to provide deployment keys for accessing private git repositories.- Default keys: Files named
id_rsa,id_rsa.pub,id_dsa, oridentity[.pub]are used by default. - Custom keys: Use a
configfile to specifyIdentityFilepaths. - Host checking: Host key checking is enabled by default. You must provide a
known_hostsfile for any repositories accessed via SSH. To disable this for a specific host, useStrictHostKeyChecking noin yourconfigfile.
# Example config for a private repo Host repo.example.com IdentityFile ~/.ssh/my_private_key # Example to disable host key checking Host repo.example.com StrictHostKeyChecking no- Default keys: Files named
Pin Doodba image versions using SHA256 digests
masterTo ensure stability and prevent unexpected updates, pin your Doodba image version using its
sha256digest rather than a tag.- Find the digest by inspecting a local image:
docker image inspect --format='{{.RepoDigests}}' tecnativa/doodba:10.0-onbuild- Use the digest in your
Dockerfile:
# Hash-pinned version of tecnativa/doodba:10.0-onbuild FROM tecnativa/doodba@sha256:fba69478f9b0616561aa3aba4d18e4bcc2f728c9568057946c98d5d3817699e1FROM tecnativa/doodba@sha256:fba69478f9b0616561aa3aba4d18e4bcc2f728c9568057946c98d5d3817699e1How to start with Doodba
masterTo begin working with Doodba, you should use the provided project template. This ensures you follow the intended directory structure and configuration patterns required for the image to function correctly.Debug Python code with `debugpy` in VSCode
masterTo use the VSCode debugger, you can enable it by setting the
DEBUGPY_ENABLE=1environment variable for your Odoo container.- In your Python code, add a breakpoint trigger:
import debugpy debugpy.listen(6899) print("Waiting for debugger attach") debugpy.wait_for_client() debugpy.breakpoint() print('break on this line')- In your environment, if using the official template, boot with:
export DOODBA_DEBUGPY_ENABLE=1 docker-compose -f devel.yaml up -d- Configure VSCode by creating a
.vscode/launch.jsonfile with the following minimal configuration to attach to the container:
{ "version": "0.2.0", "configurations": [ { "name": "Attach to debug in devel.yaml", "type": "python", "request": "attach", "pathMappings": [ { "localRoot": "${workspaceRoot}/odoo", "remoteRoot": "/opt/odoo" } ], "port": 6899, "host": "localhost" } ] }export DOODBA_DEBUGPY_ENABLE=1 docker-compose -f devel.yaml up -dAggregate repositories with `autoaggregate` and `repos.yaml`
masterThe
autoaggregatescript (a wrapper forgit-aggregator) allows you to merge multiple git repositories into your project. You define these in arepos.yamlfile.Example
repos.yamlconfiguration:./odoo: defaults: # Shallow repositories are faster & thinner. depth: $DEPTH_MERGE remotes: ocb: https://github.com/OCA/OCB.git odoo: https://github.com/odoo/odoo.git target: ocb $ODOO_VERSION merges: - ocb $ODOO_VERSION - odoo refs/pull/13635/head shell_command_after: # Useful to merge a diff when there's no git history correlation - curl -sSL https://github.com/odoo/odoo/pull/37187.diff | patch -fp1./odoo: defaults: depth: $DEPTH_MERGE remotes: ocb: https://github.com/OCA/OCB.git odoo: https://github.com/odoo/odoo.git target: ocb $ODOO_VERSION merges: - ocb $ODOO_VERSION - odoo refs/pull/13635/head shell_command_after: - curl -sSL https://github.com/odoo/odoo/pull/37187.diff | patch -fp1