I assume the variables are defined in the env file ./frontend/.env.prod
?
The env file you use in the docker-compose file yaml key env_file:
will be applied to the container once it's started. To inject its content in the docker-compose file context itself, you need to tell so in the docker-compose command.
Example:
docker-compose --env-file ./frontend/.env.prod up