Skip to content

Commit

Permalink
FEAT: Docker
Browse files Browse the repository at this point in the history
  • Loading branch information
손보석 authored and 손보석 committed Sep 6, 2023
1 parent b5123a0 commit 1490dc1
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 4 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM node:latest
RUN npm install -g @nestjs/cli
WORKDIR /server
COPY package.json yarn.lock ./
RUN yarn
COPY . .
CMD ["yarn", "start:dev"]
EXPOSE 3000
20 changes: 20 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
services:
server:
build: .
volumes:
- ./:/server
ports:
- "3000:3000"
links:
- db

db:
image: mongo:latest
ports:
- "27017:27017"
volumes:
- ./:/mongodb/data/db
environment:
- MONGO_INITDB_ROOT_USERNAME=root
- MONGO_INITDB_ROOT_PASSWORD=root
- MONGO_INITDB_DATABASE=sclife
4 changes: 2 additions & 2 deletions src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import { QuestionModule } from './question/question.module'
import { FileModule } from './file/file.module'

@Module({
imports: [MongooseModule.forRoot('mongodb://localhost/sclife'), UserModule, SignModule, HealthModule, CommentsModule, QuestionModule, FileModule],
imports: [MongooseModule.forRoot('mongodb://db/sclife'), UserModule, SignModule, HealthModule, CommentsModule, QuestionModule, FileModule],
controllers: [AppController],
providers: [AppService, LoggerMiddleware, JwtAuthGuard],
})
export class AppModule implements NestModule {
configure(consumer: MiddlewareConsumer) {
consumer.apply(LoggerMiddleware).forRoutes('*')
}
}
}
4 changes: 2 additions & 2 deletions src/user/user.controller.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Body, Controller, Get, Patch, Post, UploadedFile, UseInterceptors } from '@nestjs/common'
import { Body, Controller, Get, Post, Put, UploadedFile, UseInterceptors } from '@nestjs/common'
import { UserService } from './user.service'
import { UserDto } from '../dto/user.dto'
import { Types } from 'mongoose'
Expand Down Expand Up @@ -52,7 +52,7 @@ export class UserController {
description: '서버 에러',
})
@UseInterceptors(FileInterceptor('file'))
@Patch('profile')
@Put('profile')
uploadUserProfile(@UploadedFile() file: Array<Express.Multer.File>, @Body('id') _id: Types.ObjectId) {
return this.userService.profile(_id, JSON.parse(JSON.stringify(file)).filename)
}
Expand Down

0 comments on commit 1490dc1

Please sign in to comment.