From e243d7bf676d27c772d86634e36a083c41f06d05 Mon Sep 17 00:00:00 2001 From: twoo1999 Date: Wed, 22 Nov 2023 21:06:33 +0900 Subject: [PATCH] =?UTF-8?q?[BE]=20=EB=B3=B4=EC=95=88=20=EB=B0=8F=20docker?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80=20(#90)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * swagger 설정 * :recycle: 보안 추가 * :sparkles: docker 추가 --- BE/musicspot/.dockerignore | 4 ++++ BE/musicspot/Dockerfile | 8 ++++++++ BE/musicspot/src/app.module.ts | 4 +++- BE/musicspot/src/journey/journey.service.spec.ts | 4 +++- BE/musicspot/src/user/user.service.spec.ts | 4 +++- 5 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 BE/musicspot/.dockerignore create mode 100644 BE/musicspot/Dockerfile diff --git a/BE/musicspot/.dockerignore b/BE/musicspot/.dockerignore new file mode 100644 index 0000000..56b80bd --- /dev/null +++ b/BE/musicspot/.dockerignore @@ -0,0 +1,4 @@ +.git +Dockerfile +node_modules +dist \ No newline at end of file diff --git a/BE/musicspot/Dockerfile b/BE/musicspot/Dockerfile new file mode 100644 index 0000000..9c87f0d --- /dev/null +++ b/BE/musicspot/Dockerfile @@ -0,0 +1,8 @@ +FROM node:18 +RUN mkdir -p /var/app +WORKDIR /var/app +COPY . . +RUN npm install +RUN npm run build +EXPOSE 3000 +CMD ["node", "dist/main.js"] \ No newline at end of file diff --git a/BE/musicspot/src/app.module.ts b/BE/musicspot/src/app.module.ts index cd3b162..ee7887b 100644 --- a/BE/musicspot/src/app.module.ts +++ b/BE/musicspot/src/app.module.ts @@ -7,7 +7,9 @@ import { JourneyModule } from './journey/journey.module'; import { UserModule } from './user/user.module'; @Module({ imports: [ - MongooseModule.forRoot('mongodb://192.168.174.128:27017/musicspotDB'), + MongooseModule.forRoot( + `mongodb://${process.env.DB_HOST}:${process.env.DB_PORT}/${process.env.DB_NAME}`, + ), JourneyModule, UserModule, ], diff --git a/BE/musicspot/src/journey/journey.service.spec.ts b/BE/musicspot/src/journey/journey.service.spec.ts index e977809..99ae3e0 100644 --- a/BE/musicspot/src/journey/journey.service.spec.ts +++ b/BE/musicspot/src/journey/journey.service.spec.ts @@ -12,7 +12,9 @@ describe('JourneysService', () => { let userModel; let journeyModel; beforeEach(async () => { - mongoose.connect('mongodb://192.168.174.128:27017/musicspotDB'); + mongoose.connect( + `mongodb://${process.env.DB_HOST}:${process.env.DB_PORT}/${process.env.DB_NAME}`, + ); userModel = mongoose.model(User.name, UserSchema); journeyModel = mongoose.model(Journey.name, JourneySchema); diff --git a/BE/musicspot/src/user/user.service.spec.ts b/BE/musicspot/src/user/user.service.spec.ts index 5806e97..ff97864 100644 --- a/BE/musicspot/src/user/user.service.spec.ts +++ b/BE/musicspot/src/user/user.service.spec.ts @@ -8,7 +8,9 @@ describe('UserService', () => { let service: UserService; let userModel; beforeEach(async () => { - mongoose.connect('mongodb://192.168.174.128:27017/musicspotDB'); + mongoose.connect( + `mongodb://${process.env.DB_HOST}:${process.env.DB_PORT}/${process.env.DB_NAME}`, + ); userModel = mongoose.model(User.name, UserSchema); const module: TestingModule = await Test.createTestingModule({ providers: [