Browse Source

update db config

supeng 1 month ago
parent
commit
e42f09ca77
1 changed files with 36 additions and 24 deletions
  1. 36 24
      docker-compose.yml

+ 36 - 24
docker-compose.yml

@@ -26,9 +26,15 @@ services:
       - ./data:/data
       - ./logs:/app/logs
     environment:
-      - SQL_DSN=postgresql://root:123456@postgres:5432/new-api # ⚠️ IMPORTANT: Change the password in production!
-#      - SQL_DSN=root:123456@tcp(mysql:3306)/new-api  # Point to the mysql service, uncomment if using MySQL
-      - REDIS_CONN_STRING=redis://redis
+      # 阿里云 MySQL 连接配置 (Aliyun MySQL Connection)
+      # 格式: username:password@tcp(host:port)/database
+      # 示例: - SQL_DSN=root:your_password@tcp(rm-xxxxx.mysql.rds.aliyuncs.com:3306)/new-api
+      - SQL_DSN=ai_rw:ws8oRahcYm5GwkQy@mr-y9gker44xqhwnrnv59.rwlb.singapore.rds.aliyuncs.com:3306/new-api  # ⚠️ 请替换为您的阿里云 MySQL 连接信息
+
+      # 阿里云 Redis 连接配置 (Aliyun Redis Connection)
+      # 格式: redis://:password@host:port/db
+      # 示例: - REDIS_CONN_STRING=redis://:your_password@r-xxxxx.redis.rds.aliyuncs.com:6379/0
+      - REDIS_CONN_STRING=redis://:RPDUyra6szoS0LA1@r-t4n74k8muxmjo181qd.redis.singapore.rds.aliyuncs.com:6379/0  # ⚠️ 请替换为您的阿里云 Redis 连接信息
       - TZ=Asia/Shanghai
       - ERROR_LOG_ENABLED=true # 是否启用错误日志记录 (Whether to enable error log recording)
       - BATCH_UPDATE_ENABLED=true  # 是否启用批量更新 (Whether to enable batch update)
@@ -40,31 +46,36 @@ services:
 #      - UMAMI_WEBSITE_ID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx  # Umami 网站 ID (Umami Website ID)
 #      - UMAMI_SCRIPT_URL=https://analytics.umami.is/script.js  # Umami 脚本 URL,默认为官方地址 (Umami Script URL, defaults to official URL)
 
-    depends_on:
-      - redis
-      - postgres
-#      - mysql  # Uncomment if using MySQL
+    # 使用外部阿里云服务时,不需要依赖本地容器 (No local container dependencies when using external Aliyun services)
+    # depends_on:
+    #   - redis
+    #   - postgres
     healthcheck:
       test: ["CMD-SHELL", "wget -q -O - http://localhost:3000/api/status | grep -o '\"success\":\\s*true' || exit 1"]
       interval: 30s
       timeout: 10s
       retries: 3
 
-  redis:
-    image: redis:latest
-    container_name: redis
-    restart: always
+# ============================================================
+# 以下本地服务已禁用,因为使用外部阿里云服务
+# Local services disabled - using external Aliyun services
+# ============================================================
 
-  postgres:
-    image: postgres:15
-    container_name: postgres
-    restart: always
-    environment:
-      POSTGRES_USER: root
-      POSTGRES_PASSWORD: 123456  # ⚠️ IMPORTANT: Change this password in production!
-      POSTGRES_DB: new-api
-    volumes:
-      - pg_data:/var/lib/postgresql/data
+#  redis:
+#    image: redis:latest
+#    container_name: redis
+#    restart: always
+#
+#  postgres:
+#    image: postgres:15
+#    container_name: postgres
+#    restart: always
+#    environment:
+#      POSTGRES_USER: root
+#      POSTGRES_PASSWORD: 123456  # ⚠️ IMPORTANT: Change this password in production!
+#      POSTGRES_DB: new-api
+#    volumes:
+#      - pg_data:/var/lib/postgresql/data
 #    ports:
 #      - "5432:5432"  # Uncomment if you need to access PostgreSQL from outside Docker
 
@@ -80,6 +91,7 @@ services:
 #    ports:
 #      - "3306:3306"  # Uncomment if you need to access MySQL from outside Docker
 
-volumes:
-  pg_data:
-#  mysql_data:
+# 使用外部阿里云服务时不需要本地数据卷 (No local volumes needed when using external Aliyun services)
+# volumes:
+#   pg_data:
+#   mysql_data: