Quickstart: Deploy a Gin App
This guide explains how to deploy a Gin application to seenode.
Deploy a Gin Template
Section titled “Deploy a Gin Template”Get started in seconds by deploying our pre-configured Gin template. This example is ready to deploy and reflects the structure discussed in this guide.
Gin Template
Deploy a minimal, production-ready Gin application with optimized performance.Deploying an Existing Gin Project
Section titled “Deploying an Existing Gin Project”Follow these steps to prepare and deploy your Gin project.
-
Prepare Your Project for Production
Your project structure should be ready for deployment.
Project Structure
A minimal Gin project contains a
main.go
entry point and ago.mod
file.Directoryyour-gin-project/
- main.go // The application entry point
- go.mod
- go.sum
Dependencies
Make sure your
go.mod
listsgin-gonic/gin
as a dependency.go.mod module your-gin-projectgo 1.21require github.com/gin-gonic/gin v1.9.1Run
to create yourgo mod tidygo.sum
file.Alternative Setup
If you want to start from scratch, you can set up a new Gin project with these commands:
Terminal window # Install Go (if you haven't yet)sudo apt update && sudo apt install golang-go# Create a new projectmkdir your-gin-projectcd your-gin-projectgo mod init your-gin-projectgo get github.com/gin-gonic/ginTerminal window # Install Go using Homebrew (if you haven't yet)brew install go# Create a new projectmkdir your-gin-projectcd your-gin-projectgo mod init your-gin-projectgo get github.com/gin-gonic/ginTerminal window # Install Go from https://golang.org/dl/# Download and run the installer, then restart your terminal# Create a new projectmkdir your-gin-projectcd your-gin-projectgo mod init your-gin-projectgo get github.com/gin-gonic/ginApplication Code
Your
main.go
file should create a Gin server that listens on a port defined by an environment variable. This allows seenode to correctly route traffic to your application.main.go package mainimport "github.com/gin-gonic/gin"func main() {r := gin.Default()r.GET("/", func(c *gin.Context) {c.String(200, "Hello, Welcome to seenode 👋")})r.Run(":80")}Testing Locally
You can test your application locally by running:
go run main.go -
Deploy on seenode
Follow these steps to deploy your Gin application:
- First, create a new Web Service from the seenode Dashboard and connect your Gin project’s Git repository.
- Configure your build and start commands. seenode will attempt to detect these automatically.
- Build Command: go build -o app main.go
- Start Command: ./app
- Build Command:
- Choose your preferred instance size and create your service.
- Watch your deployment progress in real-time through the Logs tab.
- Once complete, your Gin application will be accessible via your service’s URL.
Next Steps
Section titled “Next Steps”Now that your Gin application is deployed, here are some things you might want to do next:
Set up a Custom Domain (Coming Soon)
Configure a custom domain to point to your new web service.Connect to a Database
Instantly scaffold and connect PostgreSQL and MySQL databases