'Is it possible to use an environment file in a Dockerfile?

Hey I need to split a docker compose file into Dockerfiles. I have multiple repositories that share environment files like some_file.env:

VARIABLE_1 = some_value
VARIABLE_2 = another_value
...

In docker compose I load those files with:

    env_file:
      - some_file.env

But is there a way to do this in a Dockerfile? I know I could do:

ENV VARIABLE_1 = some_value
ENV VARIABLE_2 = antoher_value

But I want the Dockerfiles to be affected when the submodules update without needing to change 3 Dockerfiles.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source