/myapp

🖥️ How to build a Dockerized RESTful API application using Go.

Primary LanguageGoMIT LicenseMIT

Learning Cloud Native Go - myapp

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.

Points to Highlight

Endpoints

endpoints

Docker Image Sizes

  • DB: 230MB
  • App
    • Development environment: 667MB
    • Production environment: 21MB

💡 Building Docker image for production docker build -f prod.Dockerfile . -t myapp_app

Design Decisions & Project Folder Structure

  • 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

Form Validation

Form validation

Logs

Logs in app init Logs in crud