Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 25 additions & 4 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,30 @@ services:
ports:
- '5432:5432'
environment:
POSTGRES_USER: postgres # 기본 사용자를 postgres로 변경 (root도 가능)
POSTGRES_PASSWORD: 1234 # 비밀번호 설정
POSTGRES_DB: stockdb # 사용할 DB 이름
POSTGRES_USER: postgres
POSTGRES_PASSWORD: 1234
POSTGRES_DB: stockdb
Comment on lines +13 to +15

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Store Postgres credentials securely.
Hardcoded credentials (POSTGRES_USER, POSTGRES_PASSWORD, POSTGRES_DB) can lead to security risks. If this is for production, consider using Docker secrets or environment variables injected by your CI/CD pipeline.


nestjs:
build: .
container_name: nestjs_app
restart: always
depends_on:
- postgres
ports:
- '3000:3000'
environment:
- DATABASE_HOST=postgres
- DATABASE_PORT=5432
- DATABASE_USERNAME=postgres
- DATABASE_PASSWORD=1234
- DATABASE_NAME=stockdb
networks:
- default
Comment on lines +17 to +32

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Use environment variable files for the NestJS service.
Plainly setting credentials in the docker-compose file is convenient for development but risky in production. Move these values into an .env file and reference them with env_file: to mitigate secrets exposure.


volumes:
postgres_data: # Docker가 자동으로 볼륨을 관리하도록 설정
postgres_data:

networks:
default:
driver: bridge
19 changes: 19 additions & 0 deletions dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Node.js 이미지를 베이스로 사용
FROM node:18

# 앱 디렉터리 생성
WORKDIR /usr/src/app

# 의존성 설치
COPY package*.json ./
RUN npm install

# 애플리케이션 소스 복사
COPY . .

# 애플리케이션 빌드
RUN npm run build

# 앱 실행
EXPOSE 3000
CMD ["npm", "run", "start:prod"]
Loading