#TypeORM errors on Docker

1 messages · Page 1 of 1 (latest)

sage flower
#

Hi Guys.
I'm trying to use my nest.js API on Docker, but I have the error on the screenshot.
These are my files:

Database Provider

@Module({
    imports: [
        TypeOrmModule.forRootAsync({
            imports: [DatabaseConfigModule],
            useFactory: async (dbConfigService: DatabaseConfigService) => ({
                type: 'postgres' as DatabaseType,
                host: dbConfigService.host,
                port: dbConfigService.port,
                username: dbConfigService.user,
                password: dbConfigService.password,
                database: dbConfigService.name,
                entities: ['src/modules/**/entities/*.entity.ts'],
                autoLoadEntities: true
            }),
            inject: [DatabaseConfigService]
        } as TypeOrmModuleAsyncOptions)
    ]
})
export class DatabaseProviderModule {}

Anyone can help me?

#

DataSource File

import { config } from 'dotenv';
import { DataSource } from 'typeorm';
import { PostgresConnectionOptions } from 'typeorm/driver/postgres/PostgresConnectionOptions';

config();

const ormDbConfig: PostgresConnectionOptions = {
    type: 'postgres',
    schema: 'public',
    host: process.env.DATABASE_HOST ?? 'localhost',
    port: Number(process.env.DATABASE_PORT) ?? 5432,
    username: process.env.DATABASE_USER,
    password: process.env.DATABASE_PASSWORD,
    database: process.env.DATABASE_NAME,
    migrationsTableName: 'migrations',
    logging: false,
    migrationsRun: true
};

const ormDevConfig: Partial<PostgresConnectionOptions> = {
    migrations: ['src/database/migrations/*.{js,ts}'],
    entities: ['src/modules/**/entities/*.entity.ts']
    // synchronize: true
};

const ormProdConfig: Partial<PostgresConnectionOptions> = {
    migrations: ['dist/database/migrations/*.{js}'],
    entities: ['dist/modules/**/entities/*.entity.js'],
    synchronize: false
};

const envConfig =
    process.env.NODE_ENV === 'production' ? ormProdConfig : ormDevConfig;

export const OrmConfig: PostgresConnectionOptions = {
    ...ormDbConfig,
    ...envConfig
};

export default new DataSource(OrmConfig);