How to add custom domain name (/etc/hosts file) on DigitalOcean App Platform?

Context: We have node app running on DigitalOcean App Platform. This app needs to connect to different hosts via custom domains, thus we need to add entries to /etc/hosts file or other ways to achieve the same goal.

Issue: we can see /etc/hosts which is owned by root. By default, DigitalOcean app platform user is apps so cannot edit the file.

-rw-r--r-- 1 root root 233 Oct 23 17:33 /etc/hosts

Question: any advice how to add additional custom domain entries to a DigitalOcean App Platform, either to edit /etc/hosts file or other ways such as settings etc?



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

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.

Hey there!

You are correct in that you wouldn’t be able to edit /etc/hosts from within the console in app platform. The console in app platform is limited and escalated privileges aren’t accessible. In this case you could look at building your application as a Dockerfile build instead and configuring the /etc/hosts file during the build. Technically you could also add all those domains as ENV variables through an app spec file. They would then be accessible via those defined variables. Reference for App Specification

Hope it helps! Nate