Skip to content

wchan2/go-service-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-service-template

A template for a Go web service. Its built with the following concepts:

  • docker-compose to manage external service dependencies such as databases for development
  • Using multi-stage builds for small minimal images for deployment
  • Makefile to run tests, static analysis and build and deploy docker images

Dependencies

  • dep for dependency management
  • Gorilla Mux for building the web service

Installing the dependencies

go get -u github.com/golang/dep/cmd/dep
dep ensure

The Development Environment

Setting up the local environment

docker-compose up   # start up the webapp with hot reloading
docker-compose down # tear down the service

Building the binary

Build the binary for development purposes

docker build --target binary binary .   # builds the image with the binary inside
docker run binary                       # runs the service in the container

Building the deploy image

Build a minimal image that runs the Go binary

docker build --target deploy -t deployment . # builds a the minimal image with the binary
docker run deployment                        # runs the service in the container

Batteries Included

Includes the following batteries:

  1. A Makefile that includes simple build targets for
    1. Running tests
    2. Running static analysis
    3. Building the image

About

Golang Web Service Template

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •