Inconnu08 / myapp

πŸ–₯️ How to build a Dockerized RESTful API application using Go.

Home Page:https://learning-cloud-native-go.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

About

πŸ–₯️ How to build a Dockerized RESTful API application using Go.

https://learning-cloud-native-go.github.io

License:MIT License


Languages

Language:Go 96.8%Language:Dockerfile 2.6%Language:Shell 0.6%