Docker-compose build.args doens't care about env_file directive

Hi there!

I’m facing about an issue? from docker-compose build.args.

When i try to pass .env variable to an ARG from docker-compose.yml on the build directive the ARG is always returned empty if the .env is not in the same directory than the docker-compose.yml file.

docker-compose 1.27.4 / docker engine community 20.10.2 / / windows 10 pro

you can reproduce using this example:

project
    |_docker-compose.yml
    |_Dockerfile
    |_my-app-folder/.env
    |_my-app-folder/<other parts of code>

docker-compose.yml content:

version: "2.4"
services:
  test:
    env_file: my-app-folder/.env
    build:
      context: .
      dockerfile: Dockerfile
      args:
        - HELLO=${HELLO}

Dockerfile content:

FROM python:3.7
ARG HELLO
ENV HELLO ${HELLO}
RUN echo ${HELLO}

my-app-folder/.env content:

HELLO="world"

Inspecting the docker-compose.yml:

docker-compose -f .\docker-compose.yml config

services:
  test:
    build:
      args:
        HELLO: ''
      context: D:\Pro\Drive\GPK-Dev\Python_Projects\docker-compose-test
      dockerfile: Dockerfile
    environment:
      HELLO: world
version: '2.4'

Somebody can tell me why the env_file haven’t any effect for args in build?

Of course this is an example and in the real project i can’t move the .env from my-app-folder to the main folder.