Recently, Digital Ocean announced they’re entering the PaaS market with their new application platform. They’ve hosted virtual machines (droplets) and Kubernetes based services for years, but now they’re creating a platform that’s a simple point and click to get an application up and running.

So I decided to try it. In this tutorial, we’re going to build an application on that platform. I will use Go to make a small web API and have it backed by an SQLite database. I’ll show you the steps required, and we’ll see just how easy it is (or isn’t) to deploy applications on the platform.

We’ll create a small service that:

  • Takes a city name as input
  • searches against a database
  • Returns ZIP code and other information for that city

If you want to follow along with this tutorial, here’s what you’ll need:

Creating Your Repository

The first thing we’ll need to do is create a repository on GitHub. The Digital Ocean app platform uses your repos to pull code from and builds from there.

Now, clone the Digital Ocean sample repository to another folder:

git clone https://github.com/digitalocean/sample-golang.git

Now, you can fork this. However, since we’re not going to be contributing changes back to that repo, and we don’t want to pull changes from it, it’s essentially a new project. So I’m just going to copy the files from that repo into mine.

git clone https://github.com/JeremyMorgan/GoZipCodeDigitalOcean.git

cp -r /sample-golang/* /GoZipCodeDigitalOcean

Now I have the sample code in my own repo:

Cool, now let’s push it up to Github.

git add .

git commmit -m "Initial Commit"

git push origin main

Now the sample project is available on my Github, where I can connect to it.

Setting up a Digital Ocean Application

Go to https://cloud.digitalocean.com/apps

And click “Launch Your App”

Next, you’ll connect your Github to Digital Ocean.

You can give it permission to all of your repositories, or just certain ones (recommended).

Next, create your application and the branch you want to deploy from. I’m selecting “main” in my case.

You can choose whether to automatically deploy code changes here. Click next.

On the next screen, you can configure some things. Make sure Go is detected and set it up as a web service.

You can add a database here, but we’ll skip that and click next.

Then you’ll select a plan. Static sites are free but Go services are not, so I chose the $5 plan here. It’s sufficient for proof of concept and development sites.

Once you click next, your site will start deploying automatically.

And we’re up! Let’s test it out.

#api #software development #programming #paas #golang #platform as a service #golang app development #wen dev

Building a Go Web API with the New Digital Ocean App Platform
1.50 GEEK