DEV Community

Naushad Nizar Ali
Naushad Nizar Ali

Posted on

Deploy a Go Backend to DigitalOcean in 5 Minutes 🚀

Originally published on Medium


🚀 Deploy a Go Backend to DigitalOcean in 5 Minutes (No DevOps Needed)

Tired of complicated cloud setups for your Go apps? Here's a dead-simple way to go live on DigitalOcean in under 5 minutes.


If you're building Go microservices or full-stack apps, you know how deployment can eat up your time. Kubernetes? CI/CD pipelines? SSH configs? 😩

What if you could deploy a Go backend in just 5 minutes — without all the DevOps overhead?

Today, I’ll walk you through exactly that using DigitalOcean App Platform, a fully managed, scalable PaaS (Platform-as-a-Service) that’s tailor-made for developers who just want to ship.


🛠️ What You'll Need

💡 Pro tip: You can follow along with my sample Go repo


Step 1: Push Your Go App to GitHub

Make sure your app has the following:

package main

import (
 "encoding/json"
 "fmt"
 "log"
 "net/http"
)

func main() {
 http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
  // Define the response data
  response := map[string]string{"message": "Hello from DigitalOcean!"}

  // Set the content type header
  w.Header().Set("Content-Type", "application/json")

  // Encode response as JSON
  if err := json.NewEncoder(w).Encode(response); err != nil {
   http.Error(w, fmt.Sprintf("JSON encoding error: %v", err), http.StatusInternalServerError)
   return
  }
 })

 log.Default().Printf("Server running on :8080")
 if err := http.ListenAndServe(":8080", nil); err != nil {
  log.Default().Fatalf("Error spawning server: %s", err.Error())
 }
}
Enter fullscreen mode Exit fullscreen mode

Create a Dockerfile at root of your repo and paste following contents in it:

# Start from the official Go image
FROM golang:1.24-alpine

# Set working directory inside container
WORKDIR /app

# Copy go.mod and go.sum first for dependency caching
COPY go.mod ./

# Download Go modules
RUN go mod download

# Copy the entire project
COPY . .

# Build the Go app
RUN go build -o server .

# Expose the port
EXPOSE 8080

# Run the binary
CMD ["./server"]
Enter fullscreen mode Exit fullscreen mode

Step 2: Connect to DigitalOcean App Platform

  1. Go to App Platform
  2. Click Create → App
  3. Connect your GitHub repo
  4. Choose the branch and root directory

App Platform auto-detects Go projects and gives you some defaults.

Step 3: Configure Build Settings

  • Set port to 8080 (or your app’s port)
  • Choose your preferred region
  • Turn on auto-deploy on push if you want CI/CD-like behaviour

Step 4: Launch 🚀

Click Next → Launch App

In under 2 minutes, your Go backend is LIVE:

https://your-app-name.ondigitalocean.app

Yes, with HTTPS. Yes, for free (with credits). Yes, in production.

💸 Bonus: Get $200 in Free Hosting Credits

Claim your $200 DigitalOcean credits here →

Perfect for:

  • Testing MVPs
  • Hosting personal APIs
  • Deploying freelance or client apps

🧠 Why DigitalOcean Over AWS or Heroku?

I now deploy Go APIs, Supabase projects, and small SaaS ideas on App Platform — no stress, no ops.

👨‍💻 Final Thoughts

Whether you’re launching a microservice, webhook, or full-fledged backend — DigitalOcean’s App Platform is the fastest, cleanest way to go live.

Skip the DevOps. Just build.

If this helped, consider giving it a ❤️ and sharing it with your dev friends.

Top comments (0)