feat (infra): Trae 完成 asset_helper_backend 微服务基础架构 V1 初始化
核心实现:搭建 Monorepo 架构,完成 shared 共享包、gateway、user-service 基础框架开发 技术落地:严格匹配指定技术栈版本,完成 Docker、gRPC、FastAPI、PostgreSQL、Redis 等配置,实现服务间基础连通 配套文件:生成 Makefile、环境变量模板、数据库 / 脚本初始化文件及启动验证文档 架构定位:仅搭建基础架构骨架,无任何业务逻辑、业务规则及业务相关字段,为后续业务开发提供支撑
This commit is contained in:
49
asset_helper_backend/infra/nginx/nginx.conf
Normal file
49
asset_helper_backend/infra/nginx/nginx.conf
Normal file
@@ -0,0 +1,49 @@
|
||||
# Nginx 配置文件
|
||||
|
||||
user nginx;
|
||||
worker_processes auto;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
||||
'$status $body_bytes_sent "$http_referer" '
|
||||
'"$http_user_agent" "$http_x_forwarded_for"';
|
||||
|
||||
access_log /var/log/nginx/access.log main;
|
||||
error_log /var/log/nginx/error.log warn;
|
||||
|
||||
sendfile on;
|
||||
keepalive_timeout 65;
|
||||
|
||||
upstream gateway {
|
||||
server gateway:8000;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
|
||||
location / {
|
||||
proxy_pass http://gateway;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection 'upgrade';
|
||||
proxy_set_header Host $host;
|
||||
proxy_cache_bypass $http_upgrade;
|
||||
}
|
||||
|
||||
location /ws {
|
||||
proxy_pass http://gateway;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_set_header Host $host;
|
||||
}
|
||||
}
|
||||
}
|
||||
17
asset_helper_backend/infra/postgres/init.sql
Normal file
17
asset_helper_backend/infra/postgres/init.sql
Normal file
@@ -0,0 +1,17 @@
|
||||
-- 创建用户和数据库
|
||||
CREATE USER user_service WITH PASSWORD 'password';
|
||||
CREATE DATABASE user_db OWNER user_service;
|
||||
GRANT ALL PRIVILEGES ON DATABASE user_db TO user_service;
|
||||
|
||||
-- 连接到 user_db 并创建表
|
||||
\c user_db;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS users (
|
||||
id SERIAL PRIMARY KEY,
|
||||
username VARCHAR(255) UNIQUE NOT NULL,
|
||||
password_hash VARCHAR(255) NOT NULL,
|
||||
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
|
||||
updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_users_username ON users(username);
|
||||
21
asset_helper_backend/infra/redis/redis.conf
Normal file
21
asset_helper_backend/infra/redis/redis.conf
Normal file
@@ -0,0 +1,21 @@
|
||||
# Redis 配置文件
|
||||
|
||||
# 绑定地址
|
||||
bind 0.0.0.0
|
||||
|
||||
# 端口
|
||||
port 6379
|
||||
|
||||
# 数据持久化
|
||||
appendonly yes
|
||||
appendfsync everysec
|
||||
|
||||
# 内存限制
|
||||
maxmemory 128mb
|
||||
maxmemory-policy allkeys-lru
|
||||
|
||||
# 日志级别
|
||||
loglevel notice
|
||||
|
||||
# 日志文件
|
||||
logfile "/var/log/redis/redis.log"
|
||||
Reference in New Issue
Block a user