I am trying to understand if there is a way to set the value of an environment variable at the top level of a compose file and use it in services. I saw that it is possible to set a value via the per service environment tag. I tried to put that at the top-level but docker-compose complained tha this is invalid.
I understand that it is possible to use a .env file but I would rather set that once at the beginning of the compose file. Is there a method to achieve this?