区分环境

This commit is contained in:
liangzai 2024-10-02 11:27:51 +08:00
parent ab842d8694
commit b8d9a72dac
30 changed files with 626 additions and 181 deletions

8
aes.go
View File

@ -48,15 +48,13 @@ type Data struct {
func main() {
// 定义 AES 密钥
key, _ := hex.DecodeString("c58e5aa2f91ddd5e0947ffc119b029c4")
key, _ := hex.DecodeString("958de6826370b57d9ae93b88e5009e26")
var data interface{}
data = map[string]interface{}{
"id_card": "45212220000827423X",
"mobile_no": "18276151590",
"name": "张荣宏",
"time_range": "5",
"id_card": "45212220000827423X",
"name": "张荣宏",
}
// 将结构体转为 JSON 字符串

View File

@ -159,7 +159,7 @@
"group_cn": "运营商验证",
"group": "YYSY"
},
{1111111111111111
{
"serviceId": "YYSYF7DB",
"sourceId": "G19-BJ02",
"serviceName": "手机二次卡",
@ -191,7 +191,7 @@
"group_cn": "企业相关",
"group": "QYGL"
},
{1111111111111111111111
{
"serviceId": "FLXG3D56",
"sourceId": "G26-BJ05",
"serviceName": "特殊名单验证",

View File

@ -3,6 +3,7 @@ package main
import (
"flag"
"fmt"
"os"
"tianyuan-api/apps/admin/internal/config"
"tianyuan-api/apps/admin/internal/handler"
@ -12,9 +13,23 @@ import (
"github.com/zeromicro/go-zero/rest"
)
var configFile = flag.String("f", "etc/admin-api.yaml", "the config file")
func main() {
// 读取环境变量 ENV默认为 "prod"
env := os.Getenv("ENV")
if env == "" {
env = "production"
}
// 根据 ENV 加载不同的配置文件
var defaultConfigFile string
if env == "development" {
defaultConfigFile = "etc/admin-api.dev.yaml" // 开发环境配置
} else {
defaultConfigFile = "etc/admin-api.yaml" // 生产环境配置
}
// 允许通过命令行参数覆盖配置文件路径
configFile := flag.String("f", defaultConfigFile, "the config file")
flag.Parse()
var c config.Config

View File

@ -0,0 +1,22 @@
Name: admin-api
Host: 0.0.0.0
Port: 10002
DataSource: "tianyuanapi:g3h98u0291j@tcp(127.0.0.1:3307)/tianyuanapi?charset=utf8mb4&parseTime=True&loc=Local"
AuthJWT:
AccessSecret: "Mf5Xph3PoyKzVpRw0Zy1+X4uR/tM7JvGMEV/5p2M/tU="
AccessExpire: 86400 # JWT过期时间
CacheRedis:
- Host: "127.0.0.1:6379"
Pass: "" # Redis 密码,如果未设置则留空
Type: "node" # 单节点模式
UserRpc:
Etcd:
Hosts:
- 127.0.0.1:2379
Key: user.rpc
SentinelRpc:
Etcd:
Hosts:
- 127.0.0.1:2379
Key: sentinel.rpc

View File

@ -1,22 +1,22 @@
Name: admin-api
Host: 0.0.0.0
Port: 10002
DataSource: "tianyuanapi:g3h98u0291j@tcp(127.0.0.1:3307)/tianyuanapi?charset=utf8mb4&parseTime=True&loc=Local"
DataSource: "tianyuanapi:g3h98u0291j@tcp(tyapi_mysql:3306)/tianyuanapi?charset=utf8mb4&parseTime=True&loc=Local"
AuthJWT:
AccessSecret: "Mf5Xph3PoyKzVpRw0Zy1+X4uR/tM7JvGMEV/5p2M/tU="
AccessExpire: 86400 # JWT过期时间
CacheRedis:
- Host: "127.0.0.1:6379"
- Host: "tyapi_redis:6379"
Pass: "" # Redis 密码,如果未设置则留空
Type: "node" # 单节点模式
UserRpc:
Etcd:
Hosts:
- 127.0.0.1:2379
- tyapi_etcd:2379
Key: user.rpc
SentinelRpc:
Etcd:
Hosts:
- 127.0.0.1:2379
- tyapi_etcd:2379
Key: sentinel.rpc

View File

@ -97,9 +97,6 @@ service api-api {
@handler QYGL6F2D
post /QYGL6F2D (request) returns (response)
@handler QYGL51BC
post /QYGL51BC (request) returns (response)
}
@server (
@ -145,10 +142,5 @@ service api-api {
@handler JRZQ4AA8
post /JRZQ4AA8 (request) returns (response)
@handler JRZQCEE8
post /JRZQCEE8 (request) returns (response)
@handler JRZQFEF8
post /JRZQFEF8 (request) returns (response)
}

View File

@ -3,6 +3,7 @@ package main
import (
"flag"
"fmt"
"os"
"tianyuan-api/apps/api/internal/config"
"tianyuan-api/apps/api/internal/handler"
@ -12,9 +13,23 @@ import (
"github.com/zeromicro/go-zero/rest"
)
var configFile = flag.String("f", "etc/api-api.yaml", "the config file")
func main() {
// 读取环境变量 ENV默认为 "prod"
env := os.Getenv("ENV")
if env == "" {
env = "production"
}
// 根据 ENV 加载不同的配置文件
var defaultConfigFile string
if env == "development" {
defaultConfigFile = "etc/api-api.dev.yaml" // 开发环境配置
} else {
defaultConfigFile = "etc/api-api.yaml" // 生产环境配置
}
// 允许通过命令行参数覆盖配置文件路径
configFile := flag.String("f", defaultConfigFile, "the config file")
flag.Parse()
var c config.Config

View File

@ -1,51 +0,0 @@
syntax = "proto3";
package product;
option go_package = "./api";
service ProductService {
//
rpc GetProducts(ProductListReq) returns (ProductListResp);
//
rpc GetUserProducts(UserProductListReq) returns (UserProductListResp);
}
//
message ProductListReq {}
//
message ProductListResp {
repeated ProductItem products = 1;
}
//
message ProductItem {
int64 id = 1; // ID
string product_name = 2; //
string product_code = 3; //
string product_description = 4; //
string product_content = 5; //
float product_price = 6; //
string created_at = 7; //
}
//
message UserProductListReq {
int64 user_id = 1; // ID
}
//
message UserProductListResp {
repeated UserProductItem user_products = 1;
}
//
message UserProductItem {
int64 id = 1; // ID
int64 user_id = 2; // ID
int64 product_id = 3; // ID
string activation_date = 4; //
string expiration_date = 5; //
}

View File

@ -0,0 +1,20 @@
Name: api-api
Host: 0.0.0.0
Port: 10003
DataSource: "tianyuanapi:g3h98u0291j@tcp(127.0.0.1:3307)/tianyuanapi?charset=utf8mb4&parseTime=True&loc=Local"
CacheRedis:
- Host: "127.0.0.1:6379"
Pass: "" # Redis 密码,如果未设置则留空
Type: "node" # 单节点模式
SentinelRpc:
Etcd:
Hosts:
- 127.0.0.1:2379
Key: sentinel.rpc
KqPusherConf:
Brokers:
- 127.0.0.1:9092
Topic: apirequest
WestConfig:
Key: "121a1e41fc1690dd6b90afbcacd80cf4"
SecretId: "449159"

View File

@ -1,19 +1,19 @@
Name: api-api
Host: 0.0.0.0
Port: 10003
DataSource: "tianyuanapi:g3h98u0291j@tcp(127.0.0.1:3307)/tianyuanapi?charset=utf8mb4&parseTime=True&loc=Local"
DataSource: "tianyuanapi:g3h98u0291j@tcp(tyapi_mysql:3306)/tianyuanapi?charset=utf8mb4&parseTime=True&loc=Local"
CacheRedis:
- Host: "127.0.0.1:6379"
- Host: "tyapi_redis:6379"
Pass: "" # Redis 密码,如果未设置则留空
Type: "node" # 单节点模式
SentinelRpc:
Etcd:
Hosts:
- 127.0.0.1:2379
- tyapi_etcd:2379
Key: sentinel.rpc
KqPusherConf:
Brokers:
- 127.0.0.1:9092
- tyapi_kafka:9092
Topic: apirequest
WestConfig:
key: "121a1e41fc1690dd6b90afbcacd80cf4"

View File

@ -2,6 +2,10 @@ package IVYZ
import (
"context"
"encoding/hex"
"errors"
"tianyuan-api/apps/api/internal/validator"
"tianyuan-api/pkg/crypto"
"tianyuan-api/apps/api/internal/svc"
"tianyuan-api/apps/api/internal/types"
@ -24,7 +28,59 @@ func NewIVYZ5733Logic(ctx context.Context, svcCtx *svc.ServiceContext) *IVYZ5733
}
func (l *IVYZ5733Logic) IVYZ5733(req *types.Request) (resp *types.Response, err error) {
// todo: add your logic here and delete this line
//userId, ok := l.ctx.Value("userId").(int64)
//if !ok {
// return &types.Response{}, errors.New("系统错误,请联系管理员")
//}
secretKey, ok := l.ctx.Value("secretKey").(string)
if !ok {
return &types.Response{}, errors.New("系统错误,请联系管理员")
}
return
// 1、解密
key, err := hex.DecodeString(secretKey)
decryptData, err := crypto.AesDecrypt(req.Data, key)
if err != nil || len(decryptData) == 0 {
return nil, errors.New("参数解密失败")
}
// 2、校验
var data validator.IVYZ5733Request
if validatorErr := validator.ValidateAndParse(decryptData, &data); validatorErr != nil {
return nil, validatorErr
}
// 3、西部加密
westConfig := l.svcCtx.Config.WestConfig
name, err := crypto.WestDexEncrypt(data.Name, westConfig.Key)
if err != nil {
logx.Errorf("西部加密错误:%v", err)
return nil, errors.New("业务异常")
}
idCard, err := crypto.WestDexEncrypt(data.IDCard, westConfig.Key)
if err != nil {
logx.Errorf("西部加密错误:%v", err)
return nil, errors.New("业务异常")
}
// 4、发送请求到西部
westdexRequest := map[string]interface{}{
"id": idCard,
"name": name,
}
westResp, err := l.svcCtx.WestDexService.CallAPI("G09GX01", westdexRequest)
if err != nil {
return nil, err
}
// 5、响应解析
//var respData westmodel.G09GX01Response
//unmarshalErr := json.Unmarshal(westResp, &respData)
//if unmarshalErr != nil {
// return nil, unmarshalErr
//}
//crypto.AesEncrypt()
return &types.Response{
Data: string(westResp),
}, nil
}

View File

@ -21,7 +21,7 @@ type FLXG3D56Request struct {
Name string `json:"name" validate:"required,min=1,validName"`
TimeRange string `json:"time_range" validate:"omitempty,validTimeRange"` // 非必填字段
}
type YYSYf7dbRequest struct {
MobileNo
StartDate
type IVYZ5733Request struct {
Name string `json:"name" validate:"required,min=1,validName"`
IDCard string `json:"id_card" validate:"required,validIDCard"`
}

View File

@ -0,0 +1,38 @@
Name: gateway-api
Host: 0.0.0.0
Port: 10001
DataSource: "tianyuanapi:g3h98u0291j@tcp(127.0.0.1:3307)/tianyuanapi?charset=utf8mb4&parseTime=True&loc=Local"
AuthJWT:
AccessSecret: "Mf5Xph3PoyKzVpRw0Zy1+X4uR/tM7JvGMEV/5p2M/tU="
AccessExpire: 86400 # JWT过期时间
CacheRedis:
- Host: "127.0.0.1:6379"
Pass: "" # Redis 密码,如果未设置则留空
Type: "node" # 单节点模式
VerifyCode:
AccessKeyID: "LTAI5tHKcV1RbC8t68UfsATy"
AccessKeySecret: "wLWjMBnAlchFMa9gC8B7ZVBKaew4t5"
EndpointURL: "dysmsapi.aliyuncs.com"
SignName: "天远查"
TemplateCode: "SMS_299200388"
ValidTime: 300
Qiniu:
AccessKey: "AO6u6sDWi6L9TsPfr4awC7FYP85JTjt3bodZACCM"
SecretKey: "2fjxweGtSAEaUdVgDkWEmN7JbBxHBQDv1cLORb9_"
Bucket: "tianyuanapi"
Domain: "https://file.tianyuanapi.com"
Baidu:
ApiKey: "aMsrBNGUJxgcgqdm3SEdcumm"
SecretKey: "sWlv2h2AWA3aAt5bjXCkE6WeA5AzpAAD"
UserRpc:
Etcd:
Hosts:
- 127.0.0.1:2379
Key: user.rpc
SentinelRpc:
Etcd:
Hosts:
- 127.0.0.1:2379
Key: sentinel.rpc

View File

@ -1,12 +1,12 @@
Name: gateway-api
Host: 0.0.0.0
Port: 10001
DataSource: "tianyuanapi:g3h98u0291j@tcp(127.0.0.1:3307)/tianyuanapi?charset=utf8mb4&parseTime=True&loc=Local"
DataSource: "tianyuanapi:g3h98u0291j@tcp(tyapi_mysql:3306)/tianyuanapi?charset=utf8mb4&parseTime=True&loc=Local"
AuthJWT:
AccessSecret: "Mf5Xph3PoyKzVpRw0Zy1+X4uR/tM7JvGMEV/5p2M/tU="
AccessExpire: 86400 # JWT过期时间
CacheRedis:
- Host: "127.0.0.1:6379"
- Host: "tyapi_redis:6379"
Pass: "" # Redis 密码,如果未设置则留空
Type: "node" # 单节点模式
VerifyCode:
@ -29,10 +29,10 @@ Baidu:
UserRpc:
Etcd:
Hosts:
- 127.0.0.1:2379
- tyapi_etcd:2379
Key: user.rpc
SentinelRpc:
Etcd:
Hosts:
- 127.0.0.1:2379
- tyapi_etcd:2379
Key: sentinel.rpc

View File

@ -3,6 +3,7 @@ package main
import (
"flag"
"fmt"
"os"
"tianyuan-api/apps/gateway/internal/config"
"tianyuan-api/apps/gateway/internal/handler"
@ -12,9 +13,23 @@ import (
"github.com/zeromicro/go-zero/rest"
)
var configFile = flag.String("f", "etc/gateway-api.yaml", "the config file")
func main() {
// 读取环境变量 ENV默认为 "prod"
env := os.Getenv("ENV")
if env == "" {
env = "production"
}
// 根据 ENV 加载不同的配置文件
var defaultConfigFile string
if env == "development" {
defaultConfigFile = "etc/gateway-api.dev.yaml" // 开发环境配置
} else {
defaultConfigFile = "etc/gateway-api.yaml" // 生产环境配置
}
// 允许通过命令行参数覆盖配置文件路径
configFile := flag.String("f", defaultConfigFile, "the config file")
flag.Parse()
var c config.Config

25
apps/mqs/etc/mqs.dev.yaml Normal file
View File

@ -0,0 +1,25 @@
Name: mq
Host: 0.0.0.0
Port: 12001
# kq 消费者组1 - 用于记录
KqConsumerLog:
Name: kqConsumerLog
Brokers:
- 127.0.0.1:9092
Group: logGroup
Topic: apirequest
Offset: first
Consumers: 2 # 为了避免资源争夺分配2个消费者
Processors: 2
# kq 消费者组2 - 用于扣款
KqConsumerCharge:
Name: kqConsumerCharge
Brokers:
- 127.0.0.1:9092
Group: chargeGroup
Topic: apirequest
Offset: first
Consumers: 2 # 同样分配2个消费者
Processors: 2

View File

@ -6,7 +6,7 @@ Port: 12001
KqConsumerLog:
Name: kqConsumerLog
Brokers:
- 127.0.0.1:9092
- tyapi_kafka:9092
Group: logGroup
Topic: apirequest
Offset: first
@ -17,7 +17,7 @@ KqConsumerLog:
KqConsumerCharge:
Name: kqConsumerCharge
Brokers:
- 127.0.0.1:9092
- tyapi_kafka:9092
Group: chargeGroup
Topic: apirequest
Offset: first

View File

@ -4,6 +4,7 @@ import (
"context"
"flag"
"github.com/zeromicro/go-zero/core/service"
"os"
"tianyuan-api/apps/mqs/internal/config"
"tianyuan-api/apps/mqs/internal/mqs"
"tianyuan-api/apps/mqs/internal/svc"
@ -12,9 +13,23 @@ import (
"github.com/zeromicro/go-zero/rest"
)
var configFile = flag.String("f", "etc/mqs.yaml", "the config file")
func main() {
// 读取环境变量 ENV默认为 "prod"
env := os.Getenv("ENV")
if env == "" {
env = "production"
}
// 根据 ENV 加载不同的配置文件
var defaultConfigFile string
if env == "development" {
defaultConfigFile = "etc/mqs.dev.yaml" // 开发环境配置
} else {
defaultConfigFile = "etc/mqs.yaml" // 生产环境配置
}
// 允许通过命令行参数覆盖配置文件路径
configFile := flag.String("f", defaultConfigFile, "the config file")
flag.Parse()
var c config.Config

View File

@ -0,0 +1,11 @@
Name: sentinel.rpc
ListenOn: 0.0.0.0:11002
Etcd:
Hosts:
- 127.0.0.1:2379
Key: sentinel.rpc
DataSource: "tianyuanapi:g3h98u0291j@tcp(127.0.0.1:3307)/tianyuanapi?charset=utf8mb4&parseTime=True&loc=Local"
CacheRedis:
- Host: "127.0.0.1:6379"
Pass: "" # Redis 密码,如果未设置则留空
Type: "node" # 单节点模式

View File

@ -2,10 +2,10 @@ Name: sentinel.rpc
ListenOn: 0.0.0.0:11002
Etcd:
Hosts:
- 127.0.0.1:2379
- tyapi_etcd:2379
Key: sentinel.rpc
DataSource: "tianyuanapi:g3h98u0291j@tcp(127.0.0.1:3307)/tianyuanapi?charset=utf8mb4&parseTime=True&loc=Local"
DataSource: "tianyuanapi:g3h98u0291j@tcp(tyapi_mysql:3306)/tianyuanapi?charset=utf8mb4&parseTime=True&loc=Local"
CacheRedis:
- Host: "127.0.0.1:6379"
- Host: "tyapi_redis:6379"
Pass: "" # Redis 密码,如果未设置则留空
Type: "node" # 单节点模式

View File

@ -3,6 +3,7 @@ package main
import (
"flag"
"fmt"
"os"
"tianyuan-api/apps/sentinel/internal/config"
productServer "tianyuan-api/apps/sentinel/internal/server/product"
@ -19,9 +20,23 @@ import (
"google.golang.org/grpc/reflection"
)
var configFile = flag.String("f", "etc/sentinel.yaml", "the config file")
func main() {
// 读取环境变量 ENV默认为 "prod"
env := os.Getenv("ENV")
if env == "" {
env = "production"
}
// 根据 ENV 加载不同的配置文件
var defaultConfigFile string
if env == "development" {
defaultConfigFile = "etc/sentinel.dev.yaml" // 开发环境配置
} else {
defaultConfigFile = "etc/sentinel.yaml" // 生产环境配置
}
// 允许通过命令行参数覆盖配置文件路径
configFile := flag.String("f", defaultConfigFile, "the config file")
flag.Parse()
var c config.Config

View File

@ -0,0 +1,19 @@
Name: user.rpc
ListenOn: 0.0.0.0:11001
Etcd:
Hosts:
- 127.0.0.1:2379
Key: user.rpc
DataSource: "tianyuanapi:g3h98u0291j@tcp(127.0.0.1:3307)/tianyuanapi?charset=utf8mb4&parseTime=True&loc=Local"
AuthJWT:
AccessSecret: "Mf5Xph3PoyKzVpRw0Zy1+X4uR/tM7JvGMEV/5p2M/tU="
AccessExpire: 86400 # JWT过期时间
CacheRedis:
- Host: "127.0.0.1:6379"
Pass: "" # Redis 密码,如果未设置则留空
Type: "node" # 单节点模式
SentinelRpc:
Etcd:
Hosts:
- 127.0.0.1:2379
Key: sentinel.rpc

View File

@ -2,18 +2,18 @@ Name: user.rpc
ListenOn: 0.0.0.0:11001
Etcd:
Hosts:
- 127.0.0.1:2379
- tyapi_etcd:2379
Key: user.rpc
DataSource: "tianyuanapi:g3h98u0291j@tcp(127.0.0.1:3307)/tianyuanapi?charset=utf8mb4&parseTime=True&loc=Local"
DataSource: "tianyuanapi:g3h98u0291j@tcp(tyapi_mysql:3306)/tianyuanapi?charset=utf8mb4&parseTime=True&loc=Local"
AuthJWT:
AccessSecret: "Mf5Xph3PoyKzVpRw0Zy1+X4uR/tM7JvGMEV/5p2M/tU="
AccessExpire: 86400 # JWT过期时间
CacheRedis:
- Host: "127.0.0.1:6379"
- Host: "tyapi_redis:6379"
Pass: "" # Redis 密码,如果未设置则留空
Type: "node" # 单节点模式
SentinelRpc:
Etcd:
Hosts:
- 127.0.0.1:2379
- tyapi_etcd:2379
Key: sentinel.rpc

View File

@ -24,7 +24,7 @@ func NewGetPendingEnterpriseLogic(ctx context.Context, svcCtx *svc.ServiceContex
}
// 获取待审核企业列表
func (l *GetPendingEnterpriseLogic) GetPendingEnterprise() (*user.GetPendingEnterpriseResp, error) {
func (l *GetPendingEnterpriseLogic) GetPendingEnterprise(in *user.GetPendingEnterpriseReq) (*user.GetPendingEnterpriseResp, error) {
// 调用 Model 层获取待审核企业列表
enterprises, total, err := l.svcCtx.EnterpriseAuthModel.FindPendingList(l.ctx, in.Page, in.PageSize)
if err != nil {

View File

@ -26,7 +26,7 @@ func NewEnterpriseServer(svcCtx *svc.ServiceContext) *EnterpriseServer {
// 获取待审核企业列表
func (s *EnterpriseServer) GetPendingEnterprise(ctx context.Context, in *user.GetPendingEnterpriseReq) (*user.GetPendingEnterpriseResp, error) {
l := enterpriselogic.NewGetPendingEnterpriseLogic(ctx, s.svcCtx)
return l.GetPendingEnterprise()
return l.GetPendingEnterprise(in)
}
// 审核企业

View File

@ -3,6 +3,7 @@ package main
import (
"flag"
"fmt"
"os"
"tianyuan-api/apps/user/internal/config"
authServer "tianyuan-api/apps/user/internal/server/auth"
@ -18,9 +19,23 @@ import (
"google.golang.org/grpc/reflection"
)
var configFile = flag.String("f", "etc/user.yaml", "the config file")
func main() {
// 读取环境变量 ENV默认为 "prod"
env := os.Getenv("ENV")
if env == "" {
env = "production"
}
// 根据 ENV 加载不同的配置文件
var defaultConfigFile string
if env == "development" {
defaultConfigFile = "etc/user.dev.yaml" // 开发环境配置
} else {
defaultConfigFile = "etc/user.yaml" // 生产环境配置
}
// 允许通过命令行参数覆盖配置文件路径
configFile := flag.String("f", defaultConfigFile, "the config file")
flag.Parse()
var c config.Config

196
docker-compose-dev.yml Normal file
View File

@ -0,0 +1,196 @@
version: '3'
services:e
tyapi_etcd:
image: bitnami/etcd
container_name: tyapi_etcd
environment:
- TZ=Asia/Shanghai
- ALLOW_NONE_AUTHENTICATION=yes
- ETCD_ADVERTISE_CLIENT_URLS=http://127.0.0.1:2379
ports:
- "2379:2379"
networks:
- tyapi_network
restart: always
tyapi_etcdManage:
image: evildecay/etcdkeeper
container_name: tyapi_etcdManage
environment:
- TZ=Asia/Shanghai
depends_on:
- tyapi_etcd
ports:
- "7000:8080" # 将容器的8080端口映射到宿主机的7000端口便于web访问
networks:
- tyapi_network
restart: always
tyapi_zookeeper:
image: wurstmeister/zookeeper
container_name: tyapi_zookeeper
ports:
- "2181:2181"
networks:
- tyapi_network
restart: always
tyapi_kafka:
image: wurstmeister/kafka
container_name: tyapi_kafka
ports:
- "9092:9092"
environment:
KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9092
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:9092
KAFKA_ZOOKEEPER_CONNECT: tyapi_zookeeper:2181
volumes:
- /var/run/docker.sock:/var/run/docker.sock
networks:
- tyapi_network
restart: always
tyapi_redis:
image: redis:7.4.0
container_name: tyapi_redis
ports:
- "6379:6379"
networks:
- tyapi_network
restart: always
tyapi_mysql:
image: mysql:8.0.34
container_name: tyapi_mysql
environment:
- MYSQL_ROOT_PASSWORD=rootpassword
- MYSQL_DATABASE=tianyuanapi
- MYSQL_USER=tianyuanapi
- MYSQL_PASSWORD=g3h98u0291j
ports:
- "3307:3306"
volumes:
- mysql_data:/var/lib/mysql
networks:
- tyapi_network
restart: always
tyapi_gateway:
container_name: tyapi_gateway
build:
context: .
dockerfile: ./apps/gateway/Dockerfile
ports:
- "10001:10001"
environment:
- ENV=production
depends_on:
- tyapi_etcd
- tyapi_redis
- tyapi_mysql
- tyapi_user
- tyapi_sentinel
networks:
- tyapi_network
restart: always
tyapi_admin:
container_name: tyapi_admin
build:
context: .
dockerfile: ./apps/admin/Dockerfile
ports:
- "10002:10002"
environment:
- ENV=production
depends_on:
- tyapi_etcd
- tyapi_redis
- tyapi_mysql
- tyapi_user
- tyapi_sentinel
networks:
- tyapi_network
restart: always
tyapi_api:
container_name: tyapi_api
build:
context: .
dockerfile: ./apps/api/Dockerfile
ports:
- "10003:10003"
environment:
- ENV=production
depends_on:
- tyapi_etcd
- tyapi_redis
- tyapi_mysql
- tyapi_user
- tyapi_sentinel
- tyapi_mqs
- tyapi_kafka
networks:
- tyapi_network
restart: always
tyapi_mqs:
container_name: tyapi_mqs
build:
context: .
dockerfile: ./apps/mqs/Dockerfile
environment:
- ENV=production
ports:
- "12001:12001"
depends_on:
- tyapi_kafka
- tyapi_etcd
- tyapi_redis
- tyapi_user
- tyapi_sentinel
networks:
- tyapi_network
restart: always
tyapi_sentinel:
container_name: tyapi_sentinel
build:
context: .
dockerfile: ./apps/sentinel/Dockerfile
environment:
- ENV=production
depends_on:
- tyapi_redis
- tyapi_mysql
- tyapi_etcd
ports:
- "11002:11002"
networks:
- tyapi_network
restart: always
tyapi_user:
container_name: tyapi_user
build:
context: .
dockerfile: ./apps/user/Dockerfile
environment:
- ENV=production
ports:
- "11001:11001"
depends_on:
- tyapi_mysql
- tyapi_redis
- tyapi_etcd
networks:
- tyapi_network
restart: always
volumes:
mysql_data:
driver: local
networks:
tyapi_network:
driver: bridge

View File

@ -1,64 +1,75 @@
version: '3'
services:
etcd:
tyapi_etcd:
image: bitnami/etcd
container_name: etcd
container_name: tyapi_etcd
environment:
- TZ=Asia/Shanghai
- ALLOW_NONE_AUTHENTICATION=yes
#- ETCD_ADVERTISE_CLIENT_URLS=http://etcd:2379
- ETCD_ADVERTISE_CLIENT_URLS=http://127.0.0.1:2379
ports:
- "2379:2379" # 宿主机可以通过127.0.0.1:2379访问etcd服务
networks:
- tyapi_network
restart: always
etcdManage:
tyapi_etcdManage:
image: evildecay/etcdkeeper
container_name: etcdManage
container_name: tyapi_etcdManage
environment:
- TZ=Asia/Shanghai
ports:
- "7000:8080" # 将容器的8080端口映射到宿主机的7000端口便于web访问
depends_on:
- etcd # 确保etcd容器先启动
- tyapi_etcd
networks:
- tyapi_network
restart: always
zookeeper:
image: wurstmeister/zookeeper
ports:
- "2181:2181"
kafka:
tyapi_zookeeper:
image: wurstmeister/zookeeper
container_name: tyapi_zookeeper
networks:
- tyapi_network
restart: always
tyapi_kafka:
image: wurstmeister/kafka
ports:
- "9092:9092"
container_name: tyapi_kafka
environment:
KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9092
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:9092
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://tyapi_kafka:9092
KAFKA_ZOOKEEPER_CONNECT: tyapi_zookeeper:2181
volumes:
- /var/run/docker.sock:/var/run/docker.sock
redis:
image: redis:7.4.0
ports:
- "6379:6379"
networks:
- tyapi_network
restart: always
mysql:
tyapi_redis:
image: redis:7.4.0
container_name: tyapi_redis
ports:
- "11002:6379"
networks:
- tyapi_network
restart: always
tyapi_mysql:
image: mysql:8.0.34
container_name: tyapi_mysql
environment:
- MYSQL_ROOT_PASSWORD=rootpassword
- MYSQL_DATABASE=tianyuanapi
- MYSQL_USER=tianyuanapi
- MYSQL_PASSWORD=g3h98u0291j
ports:
- "3307:3306"
- "11001:3306"
volumes:
- mysql_data:/var/lib/mysql
networks:
- tyapi_network
- 1panel-network
restart: always
# Gateway service
gateway:
tyapi_gateway:
container_name: tyapi_gateway
build:
context: .
dockerfile: ./apps/gateway/Dockerfile
@ -67,14 +78,17 @@ services:
environment:
- ENV=production
depends_on:
- etcd
- redis
- mysql
- user
- sentinel
- tyapi_etcd
- tyapi_redis
- tyapi_mysql
- tyapi_user
- tyapi_sentinel
networks:
- tyapi_network
restart: always
# Admin service
admin:
tyapi_admin:
container_name: tyapi_admin
build:
context: .
dockerfile: ./apps/admin/Dockerfile
@ -83,14 +97,17 @@ services:
environment:
- ENV=production
depends_on:
- etcd
- redis
- mysql
- user
- sentinel
- tyapi_etcd
- tyapi_redis
- tyapi_mysql
- tyapi_user
- tyapi_sentinel
networks:
- tyapi_network
restart: always
# API service
api:
tyapi_api:
container_name: tyapi_api
build:
context: .
dockerfile: ./apps/api/Dockerfile
@ -99,58 +116,70 @@ services:
environment:
- ENV=production
depends_on:
- etcd
- redis
- mysql
- user
- sentinel
- mqs
- kafka
- tyapi_etcd
- tyapi_redis
- tyapi_mysql
- tyapi_user
- tyapi_sentinel
- tyapi_mqs
- tyapi_kafka
networks:
- tyapi_network
restart: always
# MQS service
mqs:
tyapi_mqs:
container_name: tyapi_mqs
build:
context: .
dockerfile: ./apps/mqs/Dockerfile
ports:
- "12001:12001"
environment:
- ENV=production
depends_on:
- kafka
- etcd
- redis
- user
- sentinel
- tyapi_kafka
- tyapi_etcd
- tyapi_redis
- tyapi_user
- tyapi_sentinel
networks:
- tyapi_network
restart: always
# Sentinel service
sentinel:
tyapi_sentinel:
container_name: tyapi_sentinel
build:
context: .
dockerfile: ./apps/sentinel/Dockerfile
ports:
- "11002:11002"
environment:
- ENV=production
depends_on:
- redis
- mysql
- etcd
- tyapi_redis
- tyapi_mysql
- tyapi_etcd
networks:
- tyapi_network
restart: always
# User service
user:
tyapi_user:
container_name: tyapi_user
build:
context: .
dockerfile: ./apps/user/Dockerfile
ports:
- "11001:11001"
environment:
- ENV=production
depends_on:
- mysql
- redis
- etcd
- tyapi_mysql
- tyapi_redis
- tyapi_etcd
networks:
- tyapi_network
restart: always
volumes:
mysql_data:
driver: local
driver: local
networks:
tyapi_network:
driver: bridge
1panel-network:
external: true

View File

@ -6,7 +6,7 @@ Upstreams: # upstreams
Target: 0.0.0.0:8080 # grpc target,the direct grpc server address,for only one node
# Endpoints: [0.0.0.0:8080,192.168.120.1:8080] # grpc endpoints, the grpc server address list, for multiple nodes
# Etcd: # etcd config, if you want to use etcd to discover the grpc server address
# Hosts: [127.0.0.1:2378,127.0.0.1:2379] # etcd hosts
# Hosts: [127.0.0.1:2378,tyapi_etcd:2379] # etcd hosts
# Key: greet.grpc # the discovery key
# protoset mode
ProtoSets:

View File

@ -2,5 +2,5 @@ Name: {{.serviceName}}.rpc
ListenOn: 0.0.0.0:8080
Etcd:
Hosts:
- 127.0.0.1:2379
- tyapi_etcd:2379
Key: {{.serviceName}}.rpc