-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Support environment variables in odoo.conf #539
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Add a --database param which defaults to postgres
Add a database param which is removed if not set
To test the changes, cd into the Eg: git clone [email protected]:odoo/docker.git
cd docker
gh pr checkout 539
cd 18.0 Then: docker compose build && docker compose up |
I'm further testing this. One thing that I do not like is that if you mount a config file at /etc/odoo/odoo.conf, it will be overwritten once merged on the host machine. This is because the mounted file is the same location as the config file that Odoo uses. Additionally, the file will be mounted as The ps python script can remain as-is. There are two ways to address this: Option 1: Change ODOO_RC to another locationWe can use the default /etc/odoo/odoo.conf as the input for envsubst. We update the ODOO_RC env location in the docker file. This will enable these features by default. No existing changes would need to be done for setups mounting the configuration in /etc/odoo/odoo.conf, we would just natively support this Option 2: Make this feature optional using a config template locationMoving the file into a different file other than |
I've pushed a change to address that issue. The config file that Odoo now loads is The wait script automatically picked that change up. This enables this feature by default, and reduces any complexity that would come with template files. This also is a drop-in replacement for current builds, nothing will need to change for end users to take advantage of this. If the user mounts their config to /etc/odoo/odoo.conf, under the hood, it will automatically be moved to |
…DB_HOST, DB_PORT, DB_USER, DB_PASSWORD) as possible environment vars
Further testing: Forgot to add the new environment variables to match the Odoo config values, eg:
The existing environment variables should continue to work (eg, HOST), but they are mapped to $DB_HOST for consistency. For example: environment:
# DB_HOST: ${DB_HOST:-db}
HOST: "testing" will be merged such that the following:
results in a correct merge: However, the |
I tested all the config settings. The only one that had an issue was
I've pushed a change to rename that option. I think most major development efforts with this are done. Some testing should be performed by someone other than me. All my needs are more or less met. I think one minor change I may make is to make the timeout configurable by If we want to continue with this method, I can get some documentation up for the settings. Please let me know if anyone has any feedback on this. |
…d timeout in the entrypoint.sh file
Sorry, I figured if we're going to do it, may as well go all the way with it. I couldnt help but adding the timeout setting and switching things over to pg_isready. Pushed a patch to support
Odoo supports domain and sub-domain driven database selection. In order to get truly multi-tenant behavior out of this, we must not actually specify a database to connect to when waiting for psql to come up: https://www.odoo.com/documentation/18.0/administration/on_premise/deploy.html#dbfilter Using Additionally, I added an environment variable for the timeout for |
AFAIK this repository has no maintainer yet receives bi-weekly updates from some internal Odoo SA build process. I have never seen a PR get merged. |
That isn't surprising and more or less checks out. This repository as it is does not support many features of Odoo, specifically around multi-tenancy. I'll leave these changes here, as they work, and anyone can use them, or I will create my own container with these features and publish that to Dockerhub, whatever that is worth. These are necessary features, especially if you are selling or hosting Odoo on cloud providers aside from Odoo.sh. If the OCA is interested, maybe we can transfer it to them. |
I have submitted a patch to fix a potential race condition with ps_isready on initial startup. That should be resolved. This will likely be the last PR update I submit here if this repository is not maintained. Having checked the commit history, I believe you are correct @amh-mw I actually do need this container to be working this way, so I have moved my efforts over to a new repository. It is available here. Image name will be adomi-io/odoo I'll accept PRs if anyone would like to contribute. I also switched the image over to Alpine Linux and split this up into a multi-layer build process for things like wkhtmltopdf, node, and source management, so that we're able to actually automate the build process with Github actions, as opposed to some internal build process over at Odoo. The resulting docker image is very lightweight by comparison to the full Ubuntu image this repo is pulling. This should let us setup a mirror of the Odoo Github repo so we are not dependent on some internal build process to submit secret updates that occasionally break enterprise. I'm happy to contribute those changes back to this repository but it doesnt seem like that is going to be accepted, so why bother. In the meantime, the changes submitted here should work if anyone wants these features. Let me know if anyone out there in the void ends up using this. Thanks folks. Edit: I have setup that package with the changes listed above. If you want access to these features while this PR is pending, they are available at the linked repository. Still doing some testing on it, help is welcomed, but I setup a GitHub action to automatically build the corresponding Odoo branches on a schedule. This will take daily snapshots of Odoo, so no weird back-end internal build process at Odoo corporate. I know Odoo docker containers are a dime-a-dozen, but this is my drop in the ocean. I will maintain this for the foreseeable future. I use Odoo images every day. If you want to track a specific Odoo branch:
It will automatically build a daily container with the corresponding Odoo version. I will include some details in the readme on how to build an enterprise version of this container when I have time, and document some of the upgrades I made. |
Following on from the changes mentioned in:
#538
This also resolves:
#535
and permanently addresses:
#497