Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save bubunyo/6ffbd2fd07b6c4b2928349b87df5b5f8 to your computer and use it in GitHub Desktop.
Save bubunyo/6ffbd2fd07b6c4b2928349b87df5b5f8 to your computer and use it in GitHub Desktop.
AWS EB - Golang Binary Server Deployment
branch-defaults:
default:
environment: test
group_suffix: null
global:
application_name: test
default_platform: Go 1.4
default_region: us-west-2

This simple example will build a binary for linux/amd64 and deploy on AWS EB.

Setup --> See install.sh Run --> See run.sh Deploy --> See deploy.sh

The final binary is 10Mb and deployment is very fast for both upload and setting up the executable.

The example server is running here: http://goeb001.us-west-2.elasticbeanstalk.com/

GOOS=linux GOARCH=amd64 go build -o bin/application server.go
eb deploy
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>GO AWS EB</title>
</head>
<body>
<h1>GO AWS EB</h1>
<p>A server in golang deployed to AWS EB as a pre-compiled binary.</p>
<a href="https://gist.github.com/diverted247/89ca10f6a87c62a34d4e9332ac12ad4b">SOURCE</a>
</body>
</html>
go get github.com/gin-gonic/gin
go build -o bin/application server.go
./bin/application
package main
import (
"github.com/gin-gonic/gin"
)
func main() {
r := gin.Default()
r.LoadHTMLGlob("*.html")
r.GET( "/" , func( c *gin.Context ){
c.HTML( 200 , "index.html" , gin.H{} )
})
r.Run(":5000")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment