Do service level variables work only for non image services

If I have a service that is using a image and also has service level variables defined, I cant seem to access the service level variables in the service, they just don’t show up. Am I missing something here?

For example, doing the below doesn’t set the env variables

environment:
  - GLOBALFOO=foobar
services:
  web:
    image: nginx
    port: 80
    enviroment:
      - ENV1=env1
      - ENV2=env2
  worker:
    build: .
    port: 80
    environment:
      - ENV3=env3

In the above example the web service has only GLOBALFOO set, whereas the worker service has GLOBALFOO and ENV3 set.

Thanks for any help.