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
Makefileto run tests, static analysis and build and deploy docker images
- dep for dependency management
- Gorilla Mux for building the web service
go get -u github.com/golang/dep/cmd/dep
dep ensure
Setting up the local environment
docker-compose up # start up the webapp with hot reloading
docker-compose down # tear down the service
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
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
Includes the following batteries:
- A
Makefilethat includes simple build targets for- Running tests
- Running static analysis
- Building the image