How to auto deploy an ASP.NET 6.0 application to Digital Ocean App
Tags: aspnetcore, digitalocean, deploy, github
Published: 2023-04-11 10:18:16

---
title: How to auto deploy an ASP.NET 6.0 application to Digital Ocean App
published: true
date: 2023-04-09 00:00:00 UTC
tags: aspnetcore,digitalocean,deploy,github
canonical_url: http://driesdeboosere.dev/blog/how-to-auto-deploy-an-aspnet-60-application-to-digital-ocean-app/
---
Automatic deploy your ASP.NET 6.0 GitHub repository to an DigitalOcean App. Auto-deploy your app from your GitHub source by committing and pushing your changes to your GitHub repository.

## Create a new ASP.NET 6.0 web application

- Open your Visual Studio and create a new ASP.NET MVC application.

![](http://driesdeboosere.dev/blog/how-to-auto-deploy-aspnet-60-app-docker-image-to-digital-ocean-app/how-to-deploy-asp-net-docker-image-to-digital-ocean-13.png)

- In my case I choose .NET 6.0 framework
- Check the **Enable Docker** checkbox.
- Create the project.

![](http://driesdeboosere.dev/blog/how-to-auto-deploy-aspnet-60-app-docker-image-to-digital-ocean-app/how-to-deploy-asp-net-docker-image-to-digital-ocean-14.png)

- Open the `Views/Home/Index.cshtml` file and add the following code.

![](http://driesdeboosere.dev/blog/how-to-auto-deploy-aspnet-60-app-docker-image-to-digital-ocean-app/how-to-deploy-asp-net-docker-image-to-digital-ocean-29.png)

## Create a new GitHub repository from our project

- Now we'll create a new GitHub repository from our project. You can do this by clicking on the **Add to Source Control** option.

![](http://driesdeboosere.dev/blog/how-to-auto-deploy-aspnet-60-app-docker-image-to-digital-ocean-app/how-to-deploy-asp-net-docker-image-to-digital-ocean-15.png)

- Select **Git** as your source control provider.

![](http://driesdeboosere.dev/blog/how-to-auto-deploy-aspnet-60-app-docker-image-to-digital-ocean-app/how-to-deploy-asp-net-docker-image-to-digital-ocean-16.png)

- On the next screen you can fill in the details of your repository. In my case I will use **DigitalOceanDeploymentDemo** as the name for my new repository. You can use the name of your repository and decide if you want to make it public or private, if you need a README, ...
- Click on the **Create and Push** button.

![](http://driesdeboosere.dev/blog/how-to-auto-deploy-aspnet-60-app-docker-image-to-digital-ocean-app/how-to-deploy-asp-net-docker-image-to-digital-ocean-17.png)

- Now you can see that the repository is created and the project is pushed to the repository.

![](http://driesdeboosere.dev/blog/how-to-auto-deploy-aspnet-60-app-docker-image-to-digital-ocean-app/how-to-deploy-asp-net-docker-image-to-digital-ocean-18.png)

## Move the Dockerfile to the root of the project

It's important that the Dockerfile is in the root of the project. So we'll move the Dockerfile to the root of the project.

The easiest way to do this is to right-click on the Dockerfile in Visual Studio Solution Explorer and choose the **Open Containing Folder** option.

Now you can move the Dockerfile to the root of the project from the Windows Explorer.

![](http://driesdeboosere.dev/blog/how-to-auto-deploy-aspnet-60-app-docker-image-to-digital-ocean-app/how-to-deploy-asp-net-docker-image-to-digital-ocean-19.png)

- Commit and push the changes to GitHub

![](http://driesdeboosere.dev/blog/how-to-auto-deploy-aspnet-60-app-docker-image-to-digital-ocean-app/how-to-deploy-asp-net-docker-image-to-digital-ocean-20.png)

Now it's time to create our Digital Ocean App.

## Create Digital Ocean account

- First of all, you'll need a Digital Ocean account. If you don't have an DO account than you can create an account with this [referral link](https://m.do.co/c/1f04571a4bbe) and you'll get $200 credits to spend in the next 60 days. _(And you'll help me to keep this blog running.)_

## Digital Ocean App

DigitalOcean App Platform is a Platform-as-a-Service (PaaS) offering that makes it easy for developers to deploy their C# asp.net core applications to DigitalOcean servers. With App Platform, you can publish your code directly from your GitHub repository without worrying about the underlying infrastructure. This means that you can focus on building your app and let DigitalOcean take care of the rest!

### Create Digital Ocean App

- Now you'll need to go to the Digital Ocean dashboard and create a new App. You can do this by clicking on the "Apps" menu item.

![](http://driesdeboosere.dev/blog/how-to-auto-deploy-aspnet-60-app-docker-image-to-digital-ocean-app/how-to-deploy-asp-net-docker-image-to-digital-ocean-01.png)

- Click on the "Create App" button.

![](http://driesdeboosere.dev/blog/how-to-auto-deploy-aspnet-60-app-docker-image-to-digital-ocean-app/how-to-deploy-asp-net-docker-image-to-digital-ocean-02.png)

### Digital Ocean App configuration

- It's time to configure the Digital Ocean App. As **Service Provider** we will use **GitHub** , because we want to deploy our ASP.NET Docker image from a GitHub repository. So we select **GitHub** as our service provider.
- Now click on the **Manage Access** button to grant Digital Ocean access to your GitHub repository.

![](http://driesdeboosere.dev/blog/how-to-auto-deploy-aspnet-60-app-docker-image-to-digital-ocean-app/how-to-deploy-asp-net-docker-image-to-digital-ocean-03.png)

- On the next screen, choose **Only select repositories** and select the repository that you want to use. In this demo, we will use the **Drieze/DigitalOceanDeploymentDemo** repository.
- Click on the **Install & Authorize** button to grant Digital Ocean access to your GitHub repository.

![](http://driesdeboosere.dev/blog/how-to-auto-deploy-aspnet-60-app-docker-image-to-digital-ocean-app/how-to-deploy-asp-net-docker-image-to-digital-ocean-04.png)

- Now you can choose your granted repository in the dropdown menu below **Repository**. Choose the repository that you want to use. In my case it's the _Drieze/DigitalOceanDeploymentDemo_ repository.
- Next you have to choose the **branch** on your repository that you want to be published every time you make an update on the selected branch. In my case it's the _master_ branch.
- Leave the **Source Directory** on the root folder `/` .
- Make sure that the **Autodeploy** checkbox is checked. It should be checked by default.
- Click on the **Next** button.

![](http://driesdeboosere.dev/blog/how-to-auto-deploy-aspnet-60-app-docker-image-to-digital-ocean-app/how-to-deploy-asp-net-docker-image-to-digital-ocean-05.png)

- Now you see a summary of your app. As you can see I get a random name for my app (_clownfish-app_), yours can be different.

![](http://driesdeboosere.dev/blog/how-to-auto-deploy-aspnet-60-app-docker-image-to-digital-ocean-app/how-to-deploy-asp-net-docker-image-to-digital-ocean-06.png)

- Now click on the **Edit** button to edit the app configuration. It's important that we change the port number. We need to change the port number to **80**. Because we want to use the default port for HTTP traffic.

![](http://driesdeboosere.dev/blog/how-to-auto-deploy-aspnet-60-app-docker-image-to-digital-ocean-app/how-to-deploy-asp-net-docker-image-to-digital-ocean-21.png)

- Click on the **Edit** button in the **HTTP Port** section.

![](http://driesdeboosere.dev/blog/how-to-auto-deploy-aspnet-60-app-docker-image-to-digital-ocean-app/how-to-deploy-asp-net-docker-image-to-digital-ocean-22.png)

- Change the port number to **80** and click on the **Save** button.
- Click on the **Back** button to go back to the summary screen.

![](http://driesdeboosere.dev/blog/how-to-auto-deploy-aspnet-60-app-docker-image-to-digital-ocean-app/how-to-deploy-asp-net-docker-image-to-digital-ocean-23.png)

- If you want, you can add an addiontal resource, but in this demo we will not add any additional resources.

- Click on the **Next** button.

- I don't have any enivronment variables, so I will skip this step. And click on **Next**.

![](http://driesdeboosere.dev/blog/how-to-auto-deploy-aspnet-60-app-docker-image-to-digital-ocean-app/how-to-deploy-asp-net-docker-image-to-digital-ocean-07.png)

- In the next screen you'll see a summary of your app. If everything is correct, click on the **Next** button.

![](http://driesdeboosere.dev/blog/how-to-auto-deploy-aspnet-60-app-docker-image-to-digital-ocean-app/how-to-deploy-asp-net-docker-image-to-digital-ocean-08.png)

- On the next screen you can do a review of your app. Scroll down to change the **Billing** plan.
- Click on the **Edit Plan** button.

![](http://driesdeboosere.dev/blog/how-to-auto-deploy-aspnet-60-app-docker-image-to-digital-ocean-app/how-to-deploy-asp-net-docker-image-to-digital-ocean-10.png)

> You can choose the plan that you want. If you want to use some **free credits** , you can use this [referral link](https://m.do.co/c/1f04571a4bbe) to get $200 credits to spend in the next 60 days.

- I choose the **Basic** plan.
- And changed the Size to **$5.00/mo - Basic**.
- Click **Back**

![](http://driesdeboosere.dev/blog/how-to-auto-deploy-aspnet-60-app-docker-image-to-digital-ocean-app/how-to-deploy-asp-net-docker-image-to-digital-ocean-09.png)

- Now click on the **Create Resources** button.

![](http://driesdeboosere.dev/blog/how-to-auto-deploy-aspnet-60-app-docker-image-to-digital-ocean-app/how-to-deploy-asp-net-docker-image-to-digital-ocean-11.png)

- Now you can see that your app is being deployed. It can take a few minutes.

![](http://driesdeboosere.dev/blog/how-to-auto-deploy-aspnet-60-app-docker-image-to-digital-ocean-app/how-to-deploy-asp-net-docker-image-to-digital-ocean-12.png)

### Building the Docker image

- Now you can see that the Docker image is being built. It can take a few minutes.
- Click on the **Go to Build Logs** button to see the build logs.

![](http://driesdeboosere.dev/blog/how-to-auto-deploy-aspnet-60-app-docker-image-to-digital-ocean-app/how-to-deploy-asp-net-docker-image-to-digital-ocean-24.png)

> If you see an error that the Dockerfile is not found, you can check if the Dockerfile is in the root folder of your repository.

- After a succesfull build, your app is gonna be deployed.
- Now click on the **Live App** button to see your app live.

![](http://driesdeboosere.dev/blog/how-to-auto-deploy-aspnet-60-app-docker-image-to-digital-ocean-app/how-to-deploy-asp-net-docker-image-to-digital-ocean-25.png)

- Now you can see that your app is live and running on Digital Ocean.

![](http://driesdeboosere.dev/blog/how-to-auto-deploy-aspnet-60-app-docker-image-to-digital-ocean-app/how-to-deploy-asp-net-docker-image-to-digital-ocean-26.png)

### Update the GitHub repository

Now it's time to make a change to the GitHub repository. We will change the text on the home page. I'll add a new p-tag with the text "Test".

![](http://driesdeboosere.dev/blog/how-to-auto-deploy-aspnet-60-app-docker-image-to-digital-ocean-app/how-to-deploy-asp-net-docker-image-to-digital-ocean-30.png)

- Now we need to commit the changes to the GitHub repository.
- Our Digital Ocean App will detect the changes and will build a new Docker image and deploy the new Docker image to our Digital Ocean App.

![](http://driesdeboosere.dev/blog/how-to-auto-deploy-aspnet-60-app-docker-image-to-digital-ocean-app/how-to-deploy-asp-net-docker-image-to-digital-ocean-27.png)

- After the build and deployment is done you can see that the text on the home page is changed.

![](http://driesdeboosere.dev/blog/how-to-auto-deploy-aspnet-60-app-docker-image-to-digital-ocean-app/how-to-deploy-asp-net-docker-image-to-digital-ocean-28.png)

## GitHub repository for this demo

You can find the GitHub repository for this demo [here](https://github.com/Drieze/driesdeboosere.dev.demos/tree/master/DigitalOceanAppDeployment>).