add
This commit is contained in:
20
trading_assistant_api/Makefile
Normal file
20
trading_assistant_api/Makefile
Normal file
@@ -0,0 +1,20 @@
|
||||
# 单独启动某一个业务(如user,make up-svc svc=user)
|
||||
up-svc:
|
||||
docker compose up -d $(svc)
|
||||
|
||||
# 全局停止所有服务
|
||||
down:
|
||||
docker compose down
|
||||
|
||||
# 清理无用镜像/容器(团队开发环境,定期清理)
|
||||
clean:
|
||||
docker system prune -f
|
||||
|
||||
# 初始化Go工作区(新成员拉取代码后,一键执行)
|
||||
go-init:
|
||||
go work init
|
||||
go work use ./common
|
||||
go work use ./services/user
|
||||
go work use ./services/order
|
||||
go work use ./services/pay
|
||||
go mod tidy
|
||||
0
trading_assistant_api/common/db/options.go
Normal file
0
trading_assistant_api/common/db/options.go
Normal file
0
trading_assistant_api/common/db/postgres.go
Normal file
0
trading_assistant_api/common/db/postgres.go
Normal file
11
trading_assistant_api/common/go.mod
Normal file
11
trading_assistant_api/common/go.mod
Normal file
@@ -0,0 +1,11 @@
|
||||
module code/common
|
||||
|
||||
go 1.25.7
|
||||
|
||||
require (
|
||||
github.com/gin-gonic/gin v1.9.1
|
||||
github.com/jmoiron/sqlx v1.3.5
|
||||
github.com/redis/go-redis/v9 v9.3.0
|
||||
go.uber.org/zap v1.26.0
|
||||
github.com/lib/pq v1.10.9
|
||||
)
|
||||
0
trading_assistant_api/common/go.sum
Normal file
0
trading_assistant_api/common/go.sum
Normal file
0
trading_assistant_api/common/logger/logger.go
Normal file
0
trading_assistant_api/common/logger/logger.go
Normal file
0
trading_assistant_api/common/middleware/cors.go
Normal file
0
trading_assistant_api/common/middleware/cors.go
Normal file
0
trading_assistant_api/common/redis/redis.go
Normal file
0
trading_assistant_api/common/redis/redis.go
Normal file
0
trading_assistant_api/common/utils/common.go
Normal file
0
trading_assistant_api/common/utils/common.go
Normal file
4
trading_assistant_api/deploy/postgres/init.sql
Normal file
4
trading_assistant_api/deploy/postgres/init.sql
Normal file
@@ -0,0 +1,4 @@
|
||||
-- PostgresSQL全局初始化脚本
|
||||
-- 所有业务公共建库/建表语句写在这里,单独业务表建议在各自业务中处理
|
||||
CREATE DATABASE IF NOT EXISTS monorepo;
|
||||
\c monorepo;
|
||||
8
trading_assistant_api/deploy/redis/redis.conf
Normal file
8
trading_assistant_api/deploy/redis/redis.conf
Normal file
@@ -0,0 +1,8 @@
|
||||
# Redis基础配置
|
||||
bind 0.0.0.0
|
||||
protected-mode no
|
||||
port 6379
|
||||
daemonize no
|
||||
requirepass 123456
|
||||
appendonly yes
|
||||
appendfsync everysec
|
||||
68
trading_assistant_api/docker-compose.yml
Normal file
68
trading_assistant_api/docker-compose.yml
Normal file
@@ -0,0 +1,68 @@
|
||||
version: '3.8'
|
||||
services:
|
||||
# 公共PostgresSQL
|
||||
postgres:
|
||||
image: postgres:18.1-alpine
|
||||
container_name: trading-assistant-postgres
|
||||
environment:
|
||||
POSTGRES_USER: ${PG_USER:-root}
|
||||
POSTGRES_PASSWORD: ${PG_PWD:-123456}
|
||||
POSTGRES_DB: ${PG_DB:-monorepo}
|
||||
ports:
|
||||
- "${PG_PORT:-5432}:5432"
|
||||
volumes:
|
||||
- ./deploy/postgres/init.sql:/docker-entrypoint-initdb.d/init.sql
|
||||
- pg_data:/var/lib/postgresql/data
|
||||
networks:
|
||||
- trading-assistant-net
|
||||
restart: always
|
||||
|
||||
# 公共Redis
|
||||
redis:
|
||||
image: redis:8.4.-alpine
|
||||
container_name: trading-assistant-redis
|
||||
ports:
|
||||
- "${REDIS_PORT:-6379}:6379"
|
||||
volumes:
|
||||
- ./deploy/redis/redis.conf:/etc/redis/redis.conf
|
||||
- redis_data:/data
|
||||
command: redis-server /etc/redis/redis.conf
|
||||
networks:
|
||||
- trading-assistant-net
|
||||
restart: always
|
||||
|
||||
# 【业务服务模板】新增业务时复制以下块修改
|
||||
# user:
|
||||
# build:
|
||||
# context: ./services/user
|
||||
# dockerfile: Dockerfile
|
||||
# container_name: trading-assistant-user
|
||||
# environment:
|
||||
# - GIN_MODE=release
|
||||
# - PG_ADDR=postgres:5432
|
||||
# - REDIS_ADDR=redis:6379
|
||||
# ports:
|
||||
# - "8080:8080"
|
||||
# volumes:
|
||||
# - ./logs/user:/app/logs
|
||||
# networks:
|
||||
# - trading-assistant-net
|
||||
# restart: always
|
||||
# depends_on:
|
||||
# - postgres
|
||||
# - redis
|
||||
# deploy:
|
||||
# resources:
|
||||
# limits:
|
||||
# cpus: "0.5"
|
||||
# memory: "512M"
|
||||
|
||||
# 全局网络
|
||||
networks:
|
||||
trading-assistant-net:
|
||||
driver: bridge
|
||||
|
||||
# 全局数据卷
|
||||
volumes:
|
||||
pg_data:
|
||||
redis_data:
|
||||
Reference in New Issue
Block a user