Skip to content

Commit 44ef119

Browse files
committed
数据库配置支持读取环境变量
1 parent 124d389 commit 44ef119

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# https://hub.docker.com/_/node
2-
FROM node:12-slim
2+
FROM node:16-slim
33

44
# Create and change to the app directory.
55
WORKDIR /usr/src/app

src/config/adapter.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ exports.model = {
3636
},
3737
mysql: {
3838
handle: mysql,
39-
database: 'blog',
39+
database: process.env.MYSQL_DATABASE || 'blog',
4040
prefix: 'ls_',
4141
encoding: 'utf8',
42-
host: '127.0.0.1',
42+
host: process.env.MYSQL_HOST || '127.0.0.1',
4343
port: '',
44-
user: 'root',
45-
password: '123456',
44+
user: process.env.MYSQL_USERNAME || 'root',
45+
password: process.env.MYSQL_PASSWORD || '123456',
4646
dateStrings: true
4747
}
4848
};

0 commit comments

Comments
 (0)