我正在开发一个已停靠的express.js应用程序。这是我给书架的配置信息。
{
"database_dev" : {
"client": "mysql",
"connection": {
"host": "DB",
"database": "TERRA_DEV",
"user": "dev",
"port": "3306",
"password": "goon",
"charset": "utf8",
"host": ""
}
},
"database_test" : {
"client": "mysql",
"connection": {
"host": "DB",
"database": "TERRA_TEST",
"user": "tester",
"port": "3306",
"password": "goon",
"charset": "utf8",
"host": ""
}
},
....
这是我的docker-compose.test.yml,我正在运行以尝试执行我的测试。
version: '2'
volumes:
services:
sut:
build: .
command: npm test
depends_on:
- web
web:
build: .
command: "npm start"
volumes:
- .:/usr/app/
- /usr/app/node_modules
ports:
- "3000:3000"
depends_on:
- redis
- DB
networks:
- web_sql_bridge
redis:
image: 'bitnami/redis:latest'
environment:
- ALLOW_EMPTY_PASSWORD=yes
ports:
- '6379:6379'
DB:
image: mysql:5.7
restart: always
environment:
- MYSQL_ROOT_PASSWORD="goon"
- MYSQL_DATABASE="TERRA_TEST"
- MYSQL_DATABASE="TERRA_DEV"
- MYSQL_USER="tester"
- MYSQL_PASSWORD="goon"
ports:
- "3306:3306"
networks:
- web_sql_bridge
volumes:
appconf:
networks:
web_sql_bridge:
driver: bridge
这是错误
Error: connect ECONNREFUSED 127.0.0.1:3306
sut_1 | at Object._errnoException (util.js:1022:11)
sut_1 | at _exceptionWithHostPort (util.js:1044:20)
sut_1 | at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1198:14)
sut_1 | --------------------
sut_1 | at Protocol._enqueue (/TerraServer/node_modules/mysql/lib/protocol/Protocol.js:145:48)
sut_1 | at Protocol.handshake (/TerraServer/node_modules/mysql/lib/protocol/Protocol.js:52:23)
sut_1 | at Connection.connect (/TerraServer/node_modules/mysql/lib/Connection.js:130:18)
所以基本上你可以从上面看到,我有一个config.json,里面有一些数据库信息,我在一个js文件中得到,然后把它作为一个参数交给bookshelf.js。这是在我的摩卡测试中使用的,它抛出了我发布的错误。这个错误似乎表明它试图连接到127.0.0.1。为什么bookshelf.js在我给它db时要连接到127.0.0.1?
1条答案
按热度按时间5gfr0r5j1#
我发现了我的问题。结果我得跑了。
当我第二次构建时,它不会更新文件,我的配置文件在映像中,而不是我的repo,它在那里提取代码。
并且删除了db环境中的引号。