Well the reason why we set env variables this way - because we build bundle once. So if we want env variables to be picked correctly on docker-compose up, every time we need to rebuild webapp again and we do not want to do it. The only possible way was either replace some part of index.html ( or .js code ) on the fly on nginx layer, but much easier was to just inject small additional script and pick values from it.
Probably for cloud we do not want to set them on the fly, so we can get rid of them, just set some env variables during build and deploy.