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.
- Usage of Docker and Docker Compose.
- Usage of Golang and MySQL Alpine images.
- Usage of Docker Multistage builds.
- Health API for K8s liveness & readiness.
- 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.v10 as the Form Validator.
- DB: 230MB
- App
- Development environment: 667MB
- Production environment: 21MB
๐ก Building Docker image for production
docker build -f prod.Dockerfile . -t myapp_app
- Store executable packages inside the
cmdfolder. - Store database migrations inside the
migrationsfolder. - Store main application code inside the
appfolder. - Store reusable packages like configs, utils 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-compose.yml
โโโ Dockerfile
โโโ prod.Dockerfile
โ
โโโ cmd
โ โโโ api
โ โ โโโ main.go
โ โโโ migrate
โ โโโ main.go
โ
โโโ migrations
โ โโโ 00001_create_books_table.sql
โ
โโโ api
โ โโโ resource
โ โ โโโ book
โ โ โ โโโ api.go
โ โ โ โโโ handler.go
โ โ โ โโโ model.go
โ โ โ โโโ repository.go
โ โ โโโ common
โ โ โ โโโ err
โ โ โ โโโ err.go
โ โ โโโ health
โ โ โโโ handler.go
โ โ
โ โโโ router
โ โ โโโ router.go
โ โ โโโ middleware
โ โ โโโ content_type_json.go
โ โ โโโ content_type_json_test.go
โ โ
โ โโโ requestlog
โ โโโ handler.go
โ โโโ log_entry.go
โ
โโโ config
โ โโโ config.go
โ
โโโ util
โ โโโ logger
โ โ โโโ logger.go
โ โ โโโ logger_test.go
โ โโโ validator
โ โโโ validator.go
โ โโโ validator_test.go
โ
โโโ k8s
โ โโโ app-configmap.yaml
โ โโโ app-secret.yaml
โ โโโ app-deployment.yaml
โ โโโ app-service.yaml
โ
โโโ go.mod
โโโ go.sum



