A simple Go REST service using:
- Gin-gonic web framework
go get -u github.com/gin-gonic/gin
- Goth for OAuth2 connections
go get github.com/markbates/goth
- GORM as DB ORM
go get -u github.com/jinzhu/gorm
- Gomigrate orm migrations
go get gopkg.in/gormigrate.v2
- Migrate for migrations scripts
go get -u github.com/golang-migrate/migrate/v4
- Zerolog for formatted logging
go get -u github.com/rs/zerolog
Clone the example.env
file to .env
and update the values for your local development.
Run it locally with hot-reload:
sh scripts/run-air.sh
Run it locally without hot-reload:
sh scripts/run-dev.sh
Just run it with docker-compose
:
docker-compose run dev
And you'll have the service for your development and testing.
Use docker, swarm or kubernetes, GCP, AWS, DO, you name it.
Running prod.dockerfile
will build a multistaged build that will give you a slim image containing just the service executable.
docker-compose build prod
or
docker-compose run prod
docker build -f docker/prod.dockerfile -t go-service.prod ./