Build and Deploy Apps on DigitalOcean App Platform with Custom Domain

Jan 30, 2025 07:00 AM - 1 week ago 6293

Introduction

As developers, we often build projects connected the side, whether for nosy aliases to study thing new. These projects besides service arsenic impervious of our skills.

You should person impervious of work. Beyond your code, users should beryllium capable to usage your application, and for that, it should not conscionable beryllium successful localhost:3000, but accessible done a link. To execute this, you request to deploy your exertion and representation it to a civilization domain for amended readability and easy sharing.

In this article, you will get introduced to DigitalOcean App Platform, and spot really easy it is to spell from deploying an exertion to mapping it to a civilization domain successful conscionable a fewer clicks.

Prerequisites

  1. A DigitalOcean account to entree the App Platform.

  2. A GitHub account.

  3. Custom domain disposable connected NameCheap aliases akin platform.

What is DigitalOcean App Platform?

App Platform is simply a afloat managed platform-as-a-service (PaaS) that helps developers build, deploy, and standard applications pinch ease. It abstracts distant overmuch of the infrastructure management, allowing you to attraction connected codification and deployment.

It tin automatically analyse and build codification from git providers for illustration GitHub and GitLab, and people your applications to the cloud. It tin besides people utilizing instrumentality images that you person already uploaded to DigitalOcean Container Registry aliases Docker Hub.

With features for illustration DDoS mitigation, car OS patching, vertical scaling, HTTP support, world CDN and domain support, the App Platform makes it elemental to people and negociate your apps.

Step 1 - Deploying utilizing App Platform

Once the exertion is ready, you tin deploy it from monorepos,container images, aliases utilizing GitHub Actions.

A monorepo is simply a version-controlled codification repository that holds galore projects. While these projects whitethorn beryllium related, they are often logically independent and tally by different teams.

Let america spot really we tin deploy applications utilizing the App Platform pinch GitHub. Let’s opportunity you person a backstage GitHub repository pinch an index.html record that contains this elemental hullo world code:

index.html

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Hello World</title> </head> <body> <h1>Hello, World!</h1> <script> console.log("Hello, World!"); </script> </body> </html>

Deploy Using Github

  • Go to the Apps page and click connected Create App.

Apps Page connected DigitalOcean App Platform

  • Connect your GitHub relationship and past prime the GitHub repository that contains your root code.

Connect Your Github Account

  • In the Source Directory field, specify the files that contains the root arsenic shown successful the image below. Since our demo repository only consists of an index.html record successful the guidelines directory, we will spell up pinch the default /. If your codification follows a monorepo structure, make judge you take the peculiar directory wherever the codification is located.

Github Source Directory of the app

Select auto-deploy, this will automatically re-deploy whenever you push a caller change:

Select auto-Deploy

  • Configure resources for your app and click connected Next. This is what you will see:

Enter image alt description

  • Next, it will spell done immoderate checks earlier it yet deploys the app. For much analyzable apps, specified arsenic the ones utilizing an API, you whitethorn request to adhd situation variables, successful the adjacent pages, you tin configure those.

Enter image alt description

  • In the adjacent step, you tin edit the sanction of the exertion and take the assets nether which your app will beryllium deployed.

Enter image alt description

  • Then you click connected Next to position the Review page, wherever you get to spot different app related accusation for illustration billing, location, etc. Then yet click connected Create assets to get the app deployed.

Enter image alt description

  • This will return a fewer minutes. Once the app deploys, you tin position the app astatine the URL and different specifications successful the Overview page.

Enter image alt description

If you travel each the steps above, this is really your exertion will look like: https://sea-lion-app-l8cvv.ondigitalocean.app/.

Step 2: Mapping the exertion to a civilization domain

Now that your exertion is successfully deployed and has an ondigitalocean.app domain, successful this step, you will spot really you tin representation it to a civilization domain.

There are 2 ways by which you tin adhd a civilization domain to your app:

  1. Using automation

  2. Using the power panel

For this article, you will spot really you tin configure civilization domain utilizing the power panel.

  • Login toDigitalOcean Cloud and prime the app you want to adhd the domain to, and past click connected the Settings tab.

  • Then, click the Edit nexus to the correct of Domains, andthen click the Add Domain button.

Enter image alt description

  • As soon arsenic you commencement typing your domain sanction successful the matter section below. You will get 2 options to adhd your civilization domain.

Enter image alt description

  • You tin either adhd the civilization domain utilizing DigitalOcean’s sanction servers aliases utilizing a CNAME provider.

  • To usage DigitalOcean’s sanction servers, transcript and paste them (ns1.digitalocean.com, ns2.digitalocean.com, ns3.digitalocean.com) into your domain registrar’s sanction server records. Check our tutorial connected Point to DigitalOcean Name Servers From Common Domain Registrars for guidance connected delegating your domain to DigitalOcean’s sanction servers from celebrated registrars.

Add Custom Domain

  • You tin besides adhd a CNAME grounds to your domain. If your DNS supplier is not DigitalOcean, cheque their archiving for instructions. Use the copy fastener to transcript the ondigitalocean.app othername and paste it into the CNAME grounds connected your DNS supplier to constituent your civilization domain to your App Platform app. Once done, click the Add Domain button.

Add domain

For much precocious settings related to the domain, mention to our archiving connected How to Manage Domains successful App Platform.

Adding domains bought connected Namecheap

You tin travel the supra steps to adhd civilization domains purchased connected immoderate platform. For this example, fto america spot really you would configure the settings for a domain bought connected Namecheap.

  • Log successful to your Namecheap account. Click connected Domain List, prime the domain you want to add, and past click Manage.

  • Then move to the Advanced DNS tab and click Add caller record.

Add New Record

  • Then, spell to DigitalOcean’s control panel and transcript the nexus from the section shown below.

Choose DNS

  • Paste it successful Namecheap and prevention your changes.

Enter image alt description

That’s all! Now, you person your exertion mapped to your civilization domain.

Conclusion

In this article, you learned really to deploy your applications and negociate civilization domains utilizing DigitalOcean.

Custom domains tin thief your website rank higher successful hunt engines because they are unsocial and applicable to your brand. It besides makes it easier for group to retrieve the URL and entree your application.

Here are immoderate best practices to travel for a civilization domain:

  • Ensure SSL/TLS security, arsenic it encrypts information and improves SEO by providing a unafraid connection.

  • Monitor domain wellness regularly to observe issues and support optimal capacity for users.

  • Create backups to protect against information nonaccomplishment and let for a speedy betterment if your domain aliases tract experiences problems.

Next steps

If you determine to discontinue your app for immoderate reason, make judge to region the civilization domain earlier deleting the app. To region it, spell to the control panel, click connected your app, and past click connected Settings. Next, click the Edit nexus to the correct of Domains and the triple-dot () paper item, and finally, click connected Remove Domain to region the domain.

Here’s a database of resources that tin travel successful handy:

  • How do I adhd a domain that contains typical characters?

  • DNS How-Tos

  • I can’t delete my domain because of an associated Let’s Encrypt certificate

More