Skip to content

Instantly share code, notes, and snippets.

@diverted247
Last active May 12, 2020 15:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save diverted247/89ca10f6a87c62a34d4e9332ac12ad4b to your computer and use it in GitHub Desktop.
Save diverted247/89ca10f6a87c62a34d4e9332ac12ad4b 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")
}
@gresbtim
Copy link

gresbtim commented May 12, 2020

Unable to launch application as the source bundle does not contain a Buildfile, Procfile or an executable.

is this still valid?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment