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
cmd
folder. - Store database migrations inside the
migrations
folder. - Store main application code inside the
app
folder. - 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