Skip to content

Commit

Permalink
fix: 로컬에서 정상적으로 서버가 켜지도록 수정 (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
Coalery authored Oct 15, 2024
2 parents d1eae79 + c12b8f4 commit 5e454ee
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .env.development
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Database
DATABASE_HOST=localhost
DATABASE_HOST=mysql
DATABASE_PORT=3306
DATABASE_USER=root
DATABASE_PASSWORD=test
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ ENV NODE_ENV production
WORKDIR /sight

COPY --from=builder /sight/package*.json ./
COPY --from=builder /sight/.env.* ./
COPY --from=builder /sight/node_modules/ ./node_modules/
COPY --from=builder /sight/dist/ ./dist/

Expand Down
3 changes: 3 additions & 0 deletions docker-compose.arm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
services:
mysql:
platform: linux/arm64
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json",
"compose": "docker-compose down && docker-compose up"
"compose": "docker-compose down && docker-compose up",
"compose:arm": "docker-compose -f docker-compose.yaml -f docker-compose.arm.yaml down && docker-compose -f docker-compose.yaml -f docker-compose.arm.yaml up"
},
"dependencies": {
"@mikro-orm/core": "^6.3.13",
Expand Down
22 changes: 14 additions & 8 deletions src/core/core.module.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,41 @@
import { defineConfig } from '@mikro-orm/mysql';
import { MikroOrmModule } from '@mikro-orm/nestjs';
import { Module } from '@nestjs/common';
import { Global, Module } from '@nestjs/common';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { CqrsModule } from '@nestjs/cqrs';
import { ClsModule } from 'nestjs-cls';

import { configuration } from '@khlug/core/config';
import { DatabaseConfig } from '@khlug/core/config/DatabaseConfig';
import { EntityModels } from '@khlug/core/persistence/Entities';
import { TransactionModule } from '@khlug/core/persistence/transaction/TransactionModule';

@Global()
@Module({
imports: [
ClsModule.forRoot({ middleware: { mount: true } }),
ConfigModule.forRoot({ envFilePath: `.env.${process.env.NODE_ENV}` }),
ConfigModule.forRoot({
envFilePath: `.env.${process.env.NODE_ENV}`,
load: [configuration],
}),
MikroOrmModule.forRootAsync({
imports: [ConfigModule],
inject: [ConfigService],
useFactory: (configService: ConfigService) => {
const databaseConfig =
configService.getOrThrow<DatabaseConfig>('database');

return {
return defineConfig({
entities: EntityModels,
type: 'mysql',
host: databaseConfig?.host,
port: databaseConfig?.port,
user: databaseConfig?.username,
password: databaseConfig?.password,
dbName: databaseConfig?.database,
};
});
},
}),
TransactionModule,
CqrsModule,
],
exports: [ClsModule, MikroOrmModule, TransactionModule],
exports: [ClsModule, ConfigModule, MikroOrmModule, CqrsModule],
})
export class CoreModule {}

0 comments on commit 5e454ee

Please sign in to comment.