Boa noite amigos, alguem poderia me ajudar. to tentando criar uma api com typescript e typeorm e docker-compose mas não estou conseguindo conectar com o banco. meu arqui compose:
version: "3.3"
services:
node-app:
build: .
ports:
- "8080:8080"
volumes:
- ./:/app
- /app/node_modules
environment:
- PORT=8080
- DB_USERNAME=root
- DB_PASSWORD=root
- DB_NAME=project-fap
- DB_HOST=db_fap
container_name: app-fap
restart: always
depends_on:
- db_fap
db_fap:
image: mysql
ports:
- "3309:3306"
volumes:
- datasource:/var/lib/database_fap
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: project-fap
container_name: database-fap
volumes: datasource:
meu arquivo data-source.ts:
import "dotenv/config";
import { DataSource } from "typeorm";
export const AppDataSource = new DataSource({
type: "mysql",
host: process.env.DB_HOST,
port: 3309,
username: process.env.DB_USERNAME,
password: process.env.DB_PASSWORD,
database: process.env.DB_NAME,
logging: true,
synchronize: false,
entities: [],
subscribers: [],
});
e o erro q estou recebendo no log:
app-node-ts@1.0.0 dev ts-node-dev 'src/index.ts'
[INFO] 01:31:22 ts-node-dev ver. 2.0.0 (using ts-node ver. 10.9.1, typescript ver. 5.2.2)
Server is running in port 8080
Error: connect ECONNREFUSED 172.29.0.2:3308
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1555:16) {
errno: -111,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '172.29.0.2',
port: 3308,
fatal: true
desde já muito grato.