feat: 初始化后端微服务架构骨架

This commit is contained in:
fish
2026-03-28 19:52:35 +08:00
parent 4b3e40afab
commit 03728d743e
10 changed files with 455 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
#!/bin/bash
# 纯 Docker 启动脚本
echo "Starting backend services with Docker..."
# 进入脚本所在目录的父目录backend 目录)
cd "$(dirname "$0")/.." || exit 1
# 构建服务
echo "Building services..."
docker compose build
# 启动服务
echo "Starting services..."
docker compose up -d
# 查看服务状态
echo "Services status:"
docker compose ps
echo "Backend services started successfully!"
echo "Nginx: http://localhost:8080"
echo "Gateway: http://localhost:8000"
echo "User Service: http://localhost:9000"

View File

@@ -0,0 +1,14 @@
FROM golang:1.26.1-alpine3.23
# 安装 protoc 和相关工具
RUN apk add --no-cache protobuf-dev
# 安装 protoc-gen-go 和 protoc-gen-go-grpc
RUN go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
RUN go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
# 设置工作目录
WORKDIR /proto
# 生成 proto 文件的命令
CMD protoc --go_out=. --go-grpc_out=. common/*.proto

View File

@@ -0,0 +1,12 @@
#!/bin/bash
# Docker 内编译 proto 脚本
echo "Generating proto files..."
# 进入脚本所在目录的父目录backend 目录)
cd "$(dirname "$0")/.." || exit 1
# 运行 proto-builder 容器
docker compose run --rm proto-builder
echo "Proto files generated successfully!"