This commit is contained in:
vipg
2026-02-06 15:46:20 +08:00
parent 99ed42aff5
commit 978969b271
13 changed files with 101 additions and 9 deletions

View File

View File

11
code/common/go.mod Normal file
View 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
code/common/go.sum Normal file
View File

View File

View File

View File

View File

View File

@@ -0,0 +1,4 @@
-- PostgresSQL全局初始化脚本
-- 所有业务公共建库/建表语句写在这里,单独业务表建议在各自业务中处理
CREATE DATABASE IF NOT EXISTS monorepo;
\c monorepo;

View 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
code/docker-compose.yml Normal file
View 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:
- monorepo-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:
- monorepo-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:
# - monorepo-net
# restart: always
# depends_on:
# - postgres
# - redis
# deploy:
# resources:
# limits:
# cpus: "0.5"
# memory: "512M"
# 全局网络
networks:
monorepo-net:
driver: bridge
# 全局数据卷
volumes:
pg_data:
redis_data: