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
- A simple Go app (REST API, microservice, etc.)
- GitHub or GitLab account
- A DigitalOcean account with $200 credit
๐ก 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())
}
}
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"]
Step 2: Connect to DigitalOcean App Platform
- Go to App Platform
- Click Create โ App
- Connect your GitHub repo
- 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)