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)