docker icon indicating copy to clipboard operation
docker copied to clipboard

PORT environment variable conflicts with Google Cloud Run

Open sffc opened this issue 3 years ago • 10 comments

As documented in the Odoo Docker Readme, the Odoo container expects the following environment variables:

  • HOST: The address of the postgres server. If you used a postgres container, set to the name of the container. Defaults to db.
  • PORT: The port the postgres server is listening to. Defaults to 5432.
  • USER: The postgres role with which Odoo will connect. If you used a postgres container, set to the same value as POSTGRES_USER. Defaults to odoo.
  • PASSWORD: The password of the postgres role with which Odoo will connect. If you used a postgres container, set to the same value as POSTGRES_PASSWORD. Defaults to odoo.

Unfortunately, the name for PORT conflicts with the PORT variable used in Google Cloud Run, which is the port of the application server, not the port of the database. This means that Odoo cannot be deployed on Google Cloud Run without additional workarounds.

Suggested backwards-compatible fix: allow DB_HOST and DB_PORT as environment variables, and if they are present, they are used instead of HOST and PORT when connecting to Postgres.

sffc avatar Dec 15 '20 11:12 sffc

Same issue here and I think the idea suggested above is a good solution. It would also help clarity to prefix the environment variables with DB_ as it would be instantly clear that they are not for the Odoo server itself.

tbinna avatar Feb 27 '21 05:02 tbinna

Cloud Run is not the only compute platform that will prepopulate a PORT env var, so I guess @sffc 's suggested change makes a lot of sense. Additionally, having something as unspecific as PORT refer to a very specific downstream PGSQL dependency feels really counter-intuitive. The same is true for HOST, PASSWORD and USER, all refering to PGSQL starting here but probably well extending into the web server configuration of upstream odoo.

helloworlddan avatar Sep 20 '22 11:09 helloworlddan

So it seems that database connectivity can also be specified in a config file. Assuming that the config in the file takes precedence over ENV vars, one could build a slight variation of the odoo image that configures PGSQL in /etc/odoo.conf and that may be able to run on platforms like Cloud Run.

helloworlddan avatar Sep 20 '22 11:09 helloworlddan

Same issue with amazon appRunner here, there seems no way of overriding that behavior in apprunner either

LeonFedotov avatar Jan 11 '23 11:01 LeonFedotov

iv'e been able to get everything working, if you have access to the cmd and you can overwrite it. env PORT=5432 /entrypoint.sh odoo this will be executed within entrypoint and will reset the port number. another option might be changing the postgress port to the preset PORT internally.

LeonFedotov avatar Jan 11 '23 11:01 LeonFedotov

+1

mooperd avatar Feb 14 '23 10:02 mooperd

@sffc do the responses in this issue help you at all? Do you need this issue or can it be closed?

lathama avatar Apr 02 '24 19:04 lathama

I don't use this deployment any more, but if it hasn't been fixed, this would still be a pain point in deploying Odoo on Google Cloud Platform. The only workaround suggested in this thread is https://github.com/odoo/docker/issues/344#issuecomment-1378624472, which requires running a custom command line in the container, meaning that the Odoo image can't be used off-the-shelf in GCP.

sffc avatar Apr 02 '24 20:04 sffc

So we need a PR against https://github.com/docker-library/docs/blob/master/odoo/content.md and the entrypoint.sh to update to a more Odoo ENV name. And they would need to be committed at the same time.

lathama avatar Apr 02 '24 20:04 lathama

My suggestion in the OP is to add additional variables that don't require breaking existing customers and documentation.

sffc avatar Apr 02 '24 20:04 sffc