Skip to content

Hello World web app using Golang, Gin, and Docker

Notifications You must be signed in to change notification settings

caladoj/go-hello

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hello-go

hello-go is a basic Hello World web app using Golang, Gin, and Docker.

It's useful as a test app for various deployment techniques. Using gin is overkill but makes this a good starting point for real projects.

The docker build is setup as a multi-stage build where the build stage will use go dep to install dependencies and build the app but the final image contains only the app. The result is a build image that's 520MB but it's usually discarded and the runtime image that gets deployed is just 20MB.

Build

Runtime Image

$ docker build -t go-hello .

Build Image

In case you want it for reference or for debugging

$ docker build --target build -t go-hello:build .

Run

$ docker run --rm -p 8080:80 go-hello

Interact with Build Image

$ docker run --rm -it go-hello:build ash

Examples

In the examples below, the http cli tool comes from installing httpie but any client will work.

Plain Text

$ http localhost:8080
HTTP/1.1 200 OK
Content-Length: 13
Content-Type: text/plain; charset=utf-8
Date: Mon, 23 Apr 2018 15:05:35 GMT

hello, world

JSON

$ http localhost:8080/ping
HTTP/1.1 200 OK
Content-Length: 18
Content-Type: application/json; charset=utf-8
Date: Mon, 23 Apr 2018 15:01:58 GMT

{
    "message": "pong"
}

About

Hello World web app using Golang, Gin, and Docker

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages