Need help with myapp?
Click the β€œchat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

learning-cloud-native-go
185 Stars 27 Forks MIT License 41 Commits 1 Opened issues

Description

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

Services available

!
?

Need anything else?

Contributors list

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.

πŸ’‘ Refer learning-cloud-native-go.github.io or commit messages and

step-
branches for a step by step guild.

Points to Highlight

πŸ’­ Hope to use Wire for Compile-time Dependency Injection in the future.

Endpoints

endpoints

Docker Image Sizes

  • DB: 217MB
  • App
    • Development environment: 650MB
    • Production environment: 20.9MB

πŸ’‘ Building Docker image for production

docker build -f docker/app/prod.Dockerfile . -t myapp_app

Design Decisions & Project Folder Structure

  • Store Docker related files inside the
    docker
    folder. But keep the
    docker-compose.yml
    file in the project root.
  • 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, models and repositories 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
β”‚  └── app
β”‚     β”œβ”€β”€ bin
β”‚     β”‚  β”œβ”€β”€ init.sh
β”‚     β”‚  └── wait-for-mysql.sh
β”‚     └── Dockerfile
β”œβ”€β”€ docker-compose.yml
β”‚
β”œβ”€β”€ cmd
β”‚  β”œβ”€β”€ app
β”‚  β”‚  └── main.go
β”‚  └── migrate
β”‚     └── main.go
β”‚
β”œβ”€β”€ migrations
β”‚  └── 20190805170000_create_books_table.sql
β”‚
β”œβ”€β”€ app
β”‚  β”œβ”€β”€ app
β”‚  β”‚  β”œβ”€β”€ app.go
β”‚  β”‚  β”œβ”€β”€ book_handler.go
β”‚  β”‚  β”œβ”€β”€ health_handler.go
β”‚  β”‚  └── index_handler.go
β”‚  β”œβ”€β”€ requestlog
β”‚  β”‚  β”œβ”€β”€ handler.go
β”‚  β”‚  └── log_entry.go
β”‚  └── router
β”‚     β”œβ”€β”€ middleware
β”‚     β”‚  β”œβ”€β”€ content_type_json.go
β”‚     β”‚  └── content_type_json_test.go
β”‚     └── router.go
β”‚
β”œβ”€β”€ config
β”‚  └── config.go
β”‚
β”œβ”€β”€ adapter
β”‚  β”œβ”€β”€ db
β”‚  β”‚  └── db.go
β”‚  └── gorm
β”‚     └── gorm.go
β”‚
β”œβ”€β”€ util
β”‚  β”œβ”€β”€ logger
β”‚  β”‚  β”œβ”€β”€ logger.go
β”‚  β”‚  └── logger_test.go
β”‚  └── validator
β”‚     └── validator.go
β”‚     └── validator_test.go
β”‚
β”œβ”€β”€ model
β”‚  └── book.go
β”œβ”€β”€ repository
β”‚  └── book.go
β”‚
β”œβ”€β”€ go.mod
└── go.sum

πŸ’‘ About

app/app/app.go
; Some prefer
app/server/server.go
or
http/app/app.go

Form Validation

Form validation

Logs

Logs in app init Logs in crud

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.