Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
02eb7714
authored
Oct 02, 2025
by
CaIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore(docker): switch from MySQL to PostgreSQL in docker-compose configuration
parent
9d418d0d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
17 deletions
+46
-17
docker-compose.yml
+46
-17
No files found.
docker-compose.yml
View file @
02eb7714
# New-API Docker Compose Configuration
#
# Quick Start:
# 1. docker-compose up -d
# 2. Access at http://localhost:3000
#
# Using MySQL instead of PostgreSQL:
# 1. Comment out the postgres service and SQL_DSN line 15
# 2. Uncomment the mysql service and SQL_DSN line 16
# 3. Uncomment mysql in depends_on (line 28)
# 4. Uncomment mysql_data in volumes section (line 64)
#
# ⚠️ IMPORTANT: Change all default passwords before deploying to production!
version
:
'
3.4'
version
:
'
3.4'
services
:
services
:
...
@@ -12,21 +26,22 @@ services:
...
@@ -12,21 +26,22 @@ services:
-
./data:/data
-
./data:/data
-
./logs:/app/logs
-
./logs:/app/logs
environment
:
environment
:
-
SQL_DSN=root:123456@tcp(mysql:3306)/new-api
# Point to the mysql service
-
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
-
REDIS_CONN_STRING=redis://redis
-
TZ=Asia/Shanghai
-
TZ=Asia/Shanghai
-
ERROR_LOG_ENABLED=true
# 是否启用错误日志记录
-
ERROR_LOG_ENABLED=true
# 是否启用错误日志记录
# - STREAMING_TIMEOUT=300 # 流模式无响应超时时间,单位秒,默认120秒,如果出现空补全可以尝试改为更大值
-
BATCH_UPDATE_ENABLED=true
# 是否启用批量更新 batch update enabled
# - SESSION_SECRET=random_string # 多机部署时设置,必须修改这个随机字符串!!!!!!!
# - STREAMING_TIMEOUT=300 # 流模式无响应超时时间,单位秒,默认120秒,如果出现空补全可以尝试改为更大值 Streaming timeout in seconds, default is 120s. Increase if experiencing empty completions
# - NODE_TYPE=slave # Uncomment for slave node in multi-node deployment
# - SESSION_SECRET=random_string # 多机部署时设置,必须修改这个随机字符串!! multi-node deployment, set this to a random string!!!!!!!
# - SYNC_FREQUENCY=60 # Uncomment if regular database syncing is needed
# - SYNC_FREQUENCY=60 # Uncomment if regular database syncing is needed
# - FRONTEND_BASE_URL=https://openai.justsong.cn # Uncomment for multi-node deployment with front-end URL
depends_on
:
depends_on
:
-
redis
-
redis
-
mysql
-
postgres
# - mysql # Uncomment if using MySQL
healthcheck
:
healthcheck
:
test
:
[
"
CMD-SHELL"
,
"
wget
-q
-O
-
http://localhost:3000/api/status
|
grep
-o
'
\"
success
\"
:
\\
s*true'
|
awk
-F:
'{print
$$2}'
"
]
test
:
[
"
CMD-SHELL"
,
"
wget
-q
-O
-
http://localhost:3000/api/status
|
grep
-o
'
\"
success
\"
:
\\
s*true'
|
|
exit
1
"
]
interval
:
30s
interval
:
30s
timeout
:
10s
timeout
:
10s
retries
:
3
retries
:
3
...
@@ -36,17 +51,31 @@ services:
...
@@ -36,17 +51,31 @@ services:
container_name
:
redis
container_name
:
redis
restart
:
always
restart
:
always
mysql
:
postgres
:
image
:
mysql:8.2
image
:
postgres:15
container_name
:
mysql
container_name
:
postgres
restart
:
always
restart
:
always
environment
:
environment
:
MYSQL_ROOT_PASSWORD
:
123456
# Ensure this matches the password in SQL_DSN
POSTGRES_USER
:
root
MYSQL_DATABASE
:
new-api
POSTGRES_PASSWORD
:
123456
# ⚠️ IMPORTANT: Change this password in production!
POSTGRES_DB
:
new-api
volumes
:
volumes
:
-
mysql_data:/var/lib/mysql
-
pg_data:/var/lib/postgresql/data
# ports:
# ports:
# - "3306:3306" # If you want to access MySQL from outside Docker, uncomment
# - "5432:5432" # Uncomment if you need to access PostgreSQL from outside Docker
# mysql:
# image: mysql:8.2
# container_name: mysql
# restart: always
# environment:
# MYSQL_ROOT_PASSWORD: 123456 # ⚠️ IMPORTANT: Change this password in production!
# MYSQL_DATABASE: new-api
# volumes:
# - mysql_data:/var/lib/mysql
# ports:
# - "3306:3306" # Uncomment if you need to access MySQL from outside Docker
volumes
:
volumes
:
mysql_data
:
pg_data
:
# mysql_data:
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment