How do I use the $PORT environment variable in container based apps?


Container based apps using a Dockerfile have no build phase as part of the deploy process (the images are built locally before they are pushed to the registry). This means that dynamic information like the value of the $PORT environment variable must be read at runtime -the EXPOSE in the Dockerfile is not respected by the Heroku platform, but can be used for local testing.