diff --git a/backend/.env.example b/backend/.env.example new file mode 100644 index 0000000..d068664 --- /dev/null +++ b/backend/.env.example @@ -0,0 +1,42 @@ +# 数据库配置 (连接现有的PostgreSQL) +DB_HOST=localhost +DB_PORT=5432 +DB_NAME=photography +DB_USER=postgres +DB_PASSWORD=your_database_password +DB_SSLMODE=disable + +# Redis配置 (连接现有的Redis) +REDIS_HOST=localhost +REDIS_PORT=6379 +REDIS_PASSWORD= +REDIS_DB=0 + +# JWT配置 +JWT_SECRET=your_jwt_secret_key_here_make_it_long_and_random +JWT_EXPIRE=24h + +# 服务配置 +APP_ENV=production +APP_PORT=8080 +APP_HOST=0.0.0.0 + +# 文件上传配置 +UPLOAD_DIR=/app/uploads +MAX_FILE_SIZE=10485760 # 10MB +ALLOWED_FILE_TYPES=image/jpeg,image/png,image/gif,image/webp + +# CORS配置 +CORS_ORIGINS=https://photography.iriver.top,https://admin.photography.iriver.top + +# 日志配置 +LOG_LEVEL=info + +# 中间件配置 +ENABLE_CORS=true +ENABLE_LOGGER=true +ENABLE_ERROR_HANDLE=true + +# 安全配置 +RATE_LIMIT_REQUESTS=100 +RATE_LIMIT_WINDOW=60s \ No newline at end of file diff --git a/backend/docker-compose.example.yml b/backend/docker-compose.example.yml new file mode 100644 index 0000000..971942a --- /dev/null +++ b/backend/docker-compose.example.yml @@ -0,0 +1,54 @@ +version: '3.8' + +services: + backend: + image: registry.cn-hangzhou.aliyuncs.com/photography/backend:latest + container_name: photography_backend + restart: unless-stopped + network_mode: host # 使用主机网络连接现有的PostgreSQL和Redis + environment: + # 数据库配置 (连接现有的PostgreSQL) + DB_HOST: ${DB_HOST:-localhost} + DB_PORT: ${DB_PORT:-5432} + DB_NAME: ${DB_NAME:-photography} + DB_USER: ${DB_USER:-postgres} + DB_PASSWORD: ${DB_PASSWORD:-your_password} + DB_SSLMODE: ${DB_SSLMODE:-disable} + + # Redis配置 (连接现有的Redis) + REDIS_HOST: ${REDIS_HOST:-localhost} + REDIS_PORT: ${REDIS_PORT:-6379} + REDIS_PASSWORD: ${REDIS_PASSWORD:-} + REDIS_DB: ${REDIS_DB:-0} + + # JWT配置 + JWT_SECRET: ${JWT_SECRET:-your_jwt_secret_key} + JWT_EXPIRE: ${JWT_EXPIRE:-24h} + + # 服务配置 + APP_ENV: ${APP_ENV:-production} + APP_PORT: ${APP_PORT:-8080} + APP_HOST: ${APP_HOST:-0.0.0.0} + + # 文件上传配置 + UPLOAD_DIR: ${UPLOAD_DIR:-/app/uploads} + MAX_FILE_SIZE: ${MAX_FILE_SIZE:-10485760} # 10MB + + # CORS配置 + CORS_ORIGINS: ${CORS_ORIGINS:-https://photography.iriver.top,https://admin.photography.iriver.top} + + # 日志配置 + LOG_LEVEL: ${LOG_LEVEL:-info} + + volumes: + # 文件上传存储 + - /home/gitea/photography/uploads:/app/uploads + # 日志存储 + - /home/gitea/photography/logs:/app/logs + + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:8080/health"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s \ No newline at end of file diff --git a/frontend/.env.local b/frontend/.env.local index 3ba32d4..4502cf0 100644 --- a/frontend/.env.local +++ b/frontend/.env.local @@ -7,5 +7,5 @@ NEXT_PUBLIC_MOCK_API_URL=http://localhost:3001/api # 开发环境配置 NODE_ENV=development -# 启用真实API -NEXT_PUBLIC_USE_REAL_API=true \ No newline at end of file +# 启用真实API (临时改为false以解决SSR问题) +NEXT_PUBLIC_USE_REAL_API=false \ No newline at end of file