應用範本

1. 準備工作

  • 已安裝 dubbo-go cli 工具和相關工具

2. 使用 dubbogo-cli 建立專案範本

執行 dubbogo-cli newApp .

$ mkdir cli-create-server
$ cd cli-create-server
$ dubbogo-cli newApp .
$ tree .
.
├── Makefile
├── api
│ └── api.proto
├──build
│ └── Dockerfile
├── chart
│ ├── app
│ │ ├── Chart.yaml
│ │ ├── templates
│ │ │ ├── _helpers.tpl
│ │ │ ├── deployment.yaml
│ │ │ ├── service.yaml
│ │ │ └── serviceaccount.yaml
│ │ └── values.yaml
│ └── nacos_env
│ ├── Chart.yaml
│ ├── templates
│ │ ├── _helpers.tpl
│ │ ├── deployment.yaml
│ │ └── service.yaml
│ └── values.yaml
├── cmd
│ └── app.go
├── conf
│ └── dubbogo.yaml
├── go.mod
├── go.sum
└── pkg
    └── service
        └── service.go

產生的專案包含幾個目錄

  • api:放置介面檔案:proto 檔案和產生的 pb.go 檔案

  • build:放置構建相關檔案

  • chart:放置用於發佈的 chart 套件,基礎環境的 chart 套件:nacos、mesh(開發中)

  • cmd:程式進入點

  • conf:框架配置

  • pkg/service:RPC 服務實作

  • Makefile

    • 映像檔、應用程式名稱

      • IMAGE = $(your_repo)/$(namespace)/$(image_name) TAG = 1.0.0

      • APPNAME = dubbo-go-app # 用於 helm 發佈,對應 chart 名稱、應用程式名稱和服務名稱

    • 提供以下腳本:

      • make build # 打包映像檔並推送

      • make buildx-publish # 在本地端使用 arm 架構打包 amd64 映像檔並推送,依賴 docker buildx

      • make deploy # 通過 helm 發佈應用程式

      • make remove # 刪除已發佈的 helm 應用程式

      • make proto-gen # 產生 api/ 下的 pb.go 檔案


上次修改時間:2023 年 1 月 2 日:增強 Dubbogo 文件 (#1800) (71c8e722740)