Development

Go (Gin) Stack

Go 1.22+, Gin, Nginx and PostgreSQL 16 preconfigured — production-ready environment for lightweight Go APIs.

About Go (Gin) Stack

Go (Gin) Stack provisions your VPS with the full toolchain a Go API needs in production: Go 1.22+ installed from the official binary (not the outdated distro package), Gin as the HTTP framework, Nginx as the TLS-terminating reverse proxy, and PostgreSQL 16 as the relational database. No PPA, no buildpack, no runtime dependency on the VPS.

A Go binary compiled with CGO_ENABLED=0 is entirely self-contained: you can cross-compile it on your workstation (GOOS=linux GOARCH=amd64 go build) and deploy it with a single scp. Gin adds a router with zero allocation on hot paths, middleware support, and built-in binding for JSON, form, and multipart payloads. The stack mirrors a production-proven pattern: Nginx terminates TLS with Let's Encrypt, proxies to the Go process listening on loopback, and handles static files from disk. PostgreSQL 16 is available for any data model — use database/sql directly, pgx, or GORM according to your project's needs.

What gets installed

Ready when the VPS starts

Compatible OS
Ubuntu 24.04
Application
Go (Gin) Stack
Tech stack
Go 1.22+GinNginxPostgreSQL 16
Minimum RAM
1 GB
Minimum CPU
1 vCPU
Access
root over SSH

Key features

  • Go 1.22+ from the official binary — the latest stable release installed directly from go.dev, not the outdated distro package. Cross-compile locally (GOOS=linux GOARCH=amd64) and deploy without Go installed on the server.
  • Gin HTTP framework — zero-allocation router, middleware chaining, JSON/form/multipart binding, and context-level error handling. Covers 99 % of REST API patterns without a framework-imposed ORM or template engine.
  • Nginx reverse proxy — TLS termination via Let's Encrypt (Certbot or Caddy), loopback-only binding for the Go process, gzip compression, and static-file serving without touching the Go binary.
  • PostgreSQL 16 — the best-supported Go database. Use pgx for async-capable, performance-first access, or database/sql with the lib/pq driver for portability. JSONB columns, full-text search, and window functions available from day one.
  • Minimal memory footprint — a Gin API idles at 15–30 MB. 1 GB RAM is enough for a solo API; 2 GB if PostgreSQL shares the VPS.
  • Systemd-ready — manage the Go process as a systemd service with automatic restart on failure, journal logging, and resource limits. No process manager dependency.
  • Production deployment patterns included — the documentation covers cross-compilation, scratch Docker images, Nginx vhost configuration, and TLS setup for the most common deployment scenarios.

When to use this solution?

REST API or microservice

Deploy a Gin application as a standalone REST API or microservice. The binary listens on loopback, Nginx terminates TLS, and PostgreSQL backs any data model. Cross-compile on your CI pipeline and deploy the artifact directly — no build toolchain needed on the VPS at runtime.

High-throughput backend

Go goroutines handle thousands of concurrent connections on a single vCPU without the thread-per-request overhead of traditional servers. Bind Gin to loopback, let Nginx handle keep-alive and buffering, and saturate a 1 GB VPS with load that would require a 4 GB instance in a JVM or interpreted language.

Webhook receiver or internal API

Receive GitHub webhooks, Stripe events, or inter-service API calls with a lightweight Gin server. The binary starts in milliseconds — redeployments produce zero perceptible downtime with a systemd restart. No Node runtime, no Python interpreter, no package manager to update on the server.

Guide

Deploy Go (Gin) Stack on your VPS

  1. Order a ServOrbit VPS

    1 GB RAM on Ubuntu 24.04 is enough for a Go API. Add 2 GB if PostgreSQL runs on the same VPS. The Go (Gin) Stack template is available in the marketplace order form — Go 1.22+, Nginx, and PostgreSQL 16 are installed automatically.

  2. Deploy from the marketplace

    Go to Marketplace → Development → Go (Gin) Stack and click Deploy. The script downloads Go 1.22+ from go.dev, installs Nginx and PostgreSQL 16, and sets the PATH. No SSH session for the base setup.

  3. Cross-compile and upload your binary

    On your workstation: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o app .. Upload with scp app root@your-vps:/opt/myapp/. The binary runs directly — no Go on the server required.

  4. Create a systemd service

    Create /etc/systemd/system/myapp.service with ExecStart=/opt/myapp/app, Restart=always, and your environment variables in EnvironmentFile=/opt/myapp/.env. Enable with systemctl enable --now myapp.

  5. Configure Nginx and enable HTTPS

    Add a Nginx server block with proxy_pass http://127.0.0.1:8080 and run certbot --nginx -d api.yourdomain.com for a free Let's Encrypt certificate. Your API is live at https://api.yourdomain.com.

  6. First login

    Go (Gin) Stack installs the runtime environment only — your application handles its own authentication. Connect to your API at the domain you configured and test your first endpoint.

Frequently asked questions

Questions about Go (Gin) Stack

← Back to DevelopmentAll applications
Go compiles to a static binary with no runtime dependency on the server: deploy by copying a single file. Node.js runs the source code through a JavaScript engine with a node_modules tree. Gin handles concurrency via goroutines without threads; Node relies on an event loop. Choose Go for lower memory usage and simpler deployments; choose Node.js for a larger ecosystem and JavaScript full-stack teams.

Embed the deploy button

Maintaining a project that uses Go (Gin) Stack? This button lets your readers deploy it on a VPS in one click, without reading Docker documentation.

Deploy Go (Gin) Stack on ServOrbit
Markdown
[![Deploy Go (Gin) Stack on ServOrbit](https://servorbit.com/brand/deploy/button.svg)](https://servorbit.com/vps-cloud?template=golang&utm_source=deploy-badge&utm_medium=referral&utm_campaign=golang)
HTML
<a href="https://servorbit.com/vps-cloud?template=golang&utm_source=deploy-badge&utm_medium=referral&utm_campaign=golang"><img src="https://servorbit.com/brand/deploy/button.svg" alt="Deploy Go (Gin) Stack on ServOrbit" height="40"></a>

The button points to a VPS order with the template preselected. The image is served from servorbit.com — nothing to host on your side.

Need help?

Browse our help center and FAQ, or reach our team — callback, WhatsApp or email.

Message us on WhatsAppopens in a new tab