I've tested the package and it works wonderfully in the examples you provide 🎉.
However, I fail to make it work with Docker and Docker Compose 🥀.
The idea would be to define the variables in a .env next to the docker.compose.yml, not next to the nextjs project. Then, pass the variables to the container at the startup.
I've prepared an example here.
I get undefined at the client side.
Note the __ENV.js file is present, but empty (window.__ENV = {}).