Framework

Go

Go applications compiled to a static binary and served from Alpine Linux.

Container port8080

Requirements

go.mod in the repo root

DropDeploy runs go build from the root of your repo.

go.sum committed to the repo

Required for go mod download to reproduce the dependency tree.

App listens on port 8080

Hard-code :8080 or read os.Getenv("PORT").

Main package in the repo root

go build -o /app/server . compiles the root package.

Demo app

A minimal app that is ready to push and deploy. Copy the files below into a new repository, commit, and deploy — it should go live without any changes.

Quickstart

mkdir my-go-app && cd my-go-app && go mod init my-go-app
go.mod
module my-go-app

go 1.22
main.go
package main

import (
	"fmt"
	"log"
	"net/http"
	"os"
)

func handler(w http.ResponseWriter, r *http.Request) {
	w.Header().Set("Content-Type", "text/html")
	fmt.Fprintln(w, `
<html>
  <body style="font-family:system-ui;display:flex;justify-content:center;
               align-items:center;min-height:100vh;margin:0;
               background:#0f172a;color:#f1f5f9">
    <div style="text-align:center">
      <h1 style="color:#06b6d4">Hello from DropDeploy!</h1>
      <p style="color:#94a3b8">Go server is live.</p>
    </div>
  </body>
</html>`)
}

func main() {
	port := os.Getenv("PORT")
	if port == "" {
		port = "8080"
	}

	http.HandleFunc("/", handler)
	http.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) {
		fmt.Fprintln(w, `{"status":"ok"}`)
	})

	log.Printf("Server running on :%s", port)
	log.Fatal(http.ListenAndServe(":"+port, nil))
}
No external dependencies — uses Go's built-in net/http. Run go mod tidy after creating go.mod.

Build & start commands

DropDeploy runs these steps inside the container when you click Deploy.

go mod download
CGO_ENABLED=0 GOOS=linux go build -o server .
./server

Environment variables

Set these in Project → Env Vars in the dashboard. Never commit secrets.

VariableRequiredDescription
PORTNoRead with os.Getenv("PORT"). Defaults to 8080 if you hard-code it.

Common issues

Main package not in repo root

If your main is at cmd/server/main.go, change the build command to go build ./cmd/server. This requires a custom Dockerfile.

CGO dependencies

CGO_ENABLED=0 disables cgo. If your app uses cgo (e.g. sqlite3), use a different base image.