msfidelis / cloud-native-microservice-boilerplate

:package: :whale: :rocket: :zap: Personal project boilerplate to start new cloud native microservices projects with Go quickly

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Welcome to Easy Golang API Bootstrap πŸ‘‹

Version License: MIT Twitter: fidelissauro

Project boilerplate to start new cloud native golang projects quickly

How to start

  1. Clone this boilerplate
git clone git@github.com:msfidelis/cloud-native-microservice-boilerplate.git
  1. Change project name

Use your CTRL + F or Search/Replace

  • Search for change-me in project folder
  • Change for your project name

Developer mode (live reload with Air)

docker-compose up --force-recreate
change-me_1  | 
change-me_1  |   __    _   ___  
change-me_1  |  / /\  | | | |_) 
change-me_1  | /_/--\ |_| |_| \_ v1.12.1 // live reload for Go apps, with Go1.14.0
change-me_1  | 
change-me_1  | watching .
change-me_1  | watching configs
change-me_1  | watching controllers
change-me_1  | watching controllers/healthcheck
change-me_1  | watching controllers/version
change-me_1  | watching models
change-me_1  | watching models/foo
change-me_1  | watching pkg
change-me_1  | watching pkg/configuration
change-me_1  | watching pkg/system
change-me_1  | !exclude tmp
change-me_1  | building...

Testing

curl 0.0.0.0:8080/version -i
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Date: Sun, 02 Aug 2020 22:06:54 GMT
Content-Length: 16

{"version":"v1"}

Unit Tests

ENVIRONMENT=test go test -v -cover

Production Image

docker build -t newproject .

Project Structure

.
β”œβ”€β”€ Dockerfile (Production golang Dockerfile - Multistage Build)
β”œβ”€β”€ Dockerfile.dev (Development golang Dockerfile - With Air)
β”œβ”€β”€ LICENSE
β”œβ”€β”€ README.md
β”œβ”€β”€ configs (unsensitive configuration files)
β”‚   β”œβ”€β”€ dev.json
β”‚   β”œβ”€β”€ prod.json
β”‚   └── test.json
β”œβ”€β”€ controllers (controller folder)
β”‚   β”œβ”€β”€ healthcheck (controller name / context)
β”‚   β”‚   └── main.go (main module for controller)
β”‚   └── version
β”‚       └── main.go
β”œβ”€β”€ docker-compose.yml (docker-compose for development environment)
β”œβ”€β”€ go.mod
β”œβ”€β”€ go.sum
β”œβ”€β”€ pkg (Shared libs folder)
β”‚   β”œβ”€β”€ configuration (Lib Context / Name)
β”‚   β”‚   └── main.go (Main module for package)
β”‚   └── system
β”‚       └── main.go
└── main.go (Entrypoint / Routes)

Features

Chaos Monkey

This boilerplate works with a side-project called gin-chaos-monkey.

You can enable chaos assaults in your app setting some environment variables in runtime, like:

// ... 
    environment:
      - ENVIRONMENT=dev
      - CHAOS_MONKEY_ENABLED=true
      - CHAOS_MONKEY_MODE=critical
      - CHAOS_MONKEY_LATENCY=true
      - CHAOS_MONKEY_EXCEPTION=false
      - CHAOS_MONKEY_APP_KILLER=true
      - CHAOS_MONKEY_MEMORY=false

You can enable assaults in production setting this variables in your platform cluster runtime. For more information, read the docs!

Swagger

Access Swagger in http://0.0.0.0/swagger/index.html

Swagger runs on production build on Dockerfile.

Author

πŸ‘€ Matheus Fidelis

🀝 Contributing

Contributions, issues and feature requests are welcome!

Feel free to check issues page.

Show your support

Give a ⭐️ if this project helped you!

πŸ“ License

Copyright Β© 2020 Matheus Fidelis.

This project is MIT licensed.


This README was generated with ❀️ by readme-md-generator

About

:package: :whale: :rocket: :zap: Personal project boilerplate to start new cloud native microservices projects with Go quickly

License:MIT License


Languages

Language:Go 96.3%Language:Dockerfile 3.7%