How to use App Platform env variables in Docker build phase?

I’m currently trying to port my webapp from heroku to App Platform, and I’m struggling to use env variable set in the App Platform UI in my docker build phase. Any idea? Thanks

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

You can pass the values of environment variables from the host to your containers without much effort. Simply don’t specify a value in the command line, and make sure that the environment variable is named the same as the variable the containerized app expects:

$ docker run -e var_name (…) In the above snippet, the value of a var_name variable in the current environment is used to set the value of var_name in the container environment upon startup.