Cloud Native Application Development is a one way of speeding up building web applications, using micro-services, containers and orchestration tools.
As the first step, this repository shows How to build a Dockerized RESTful API application using Go.
π‘Refer commit messages and
step-
branches for a step by step guild. (Blog: Coming soon!)
- Usage of Docker and Docker Compose.
- Usage of Golang and MySQL Alpine images.
- Usage of Docker Multistage builds.
- Liveness and Readiness APIs for K8s.
- Usage of Goose for Migrations.
- Usage of GORM as the ORM.
- Usage of Chi as the Router.
- Usage of Zerolog as the Logger.
- Usage of Validator.v9 as the Form Validator.
π Hope to use Wire for Compile-time Dependency Injection in the future.
REPOSITORY TAG SIZE
myapp_app latest 58.7MB
myapp_db latest 233MB
- Store Docker related files inside the
docker
folder. But keep thedocker-compose.yml
file in the project root. - Store executable packages inside the
cmd
folder. - Store database migrations inside the
migrations
folder. - Store main application code inside the
app
folder. - Store reusable packages like configs, utils, models and repositories in separate folders. This will be helpful if you are adding more executable applications to support web front-ends, publish/subscribe systems, document stores and etc.
.
βββ docker
β βββ app
β β βββ bin
β β β βββ init.sh
β β β βββ wait-for-mysql.sh
β β βββ Dockerfile
β βββ mariadb
β βββ Dockerfile
βββ docker-compose.yml
β
βββ cmd
β βββ app
β β βββ main.go
β βββ migrate
β βββ main.go
β
βββ migrations
β βββ 20190805170000_create_books_table.sql
β
βββ app
β βββ app
β β βββ app.go
β β βββ bookHandler.go
β β βββ heathHandler.go
β β βββ indexHandler.go
β βββ handler
β β βββ handler.go
β β βββ logEntry.go
β βββ router
β βββ middleware
β β βββ content_type_json.go
β β βββ content_type_json_test.go
β βββ router.go
β
βββ config
β βββ config.go
β
βββ adapter
β βββ db
β β βββ db.go
β βββ gorm
β βββ gorm.go
β
βββ util
β βββ logger
β β βββ logger.go
β β βββ logger_test.go
β βββ validator
β βββ validator.go
| βββ validator_test.go
β
βββ model
β βββ book.go
βββ repository
β βββ book.go
β
βββ go.mod
βββ go.sum
π‘About
app/app/app.go
; Some preferapp/server/server.go
orhttp/app/app.go