Inconnu08/myapp

๐Ÿ–ฅ๏ธ How to build a Dockerized RESTful API application using Go.

โ˜… 0Forks 0GitHub โ†—Compare

Project website โ†—

README

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

Contributors

dumindujosemukorivo

Issues