데이터베이스 구성 및 엔트리포인트 개선#28
Conversation
- Changed from generic POSTGRES_DB/USER/PASSWORD to DB_CHAT_NAME/USER/PASSWORD - Ensures chat service connects to its own database (chat_db) - Disabled automatic migrations in entrypoint to prevent startup crashes - Migrations should be run manually after verifying database connectivity - Part of microservices database isolation improvements
There was a problem hiding this comment.
Pull Request Overview
This PR updates database configuration environment variables and comments out automatic migrations during container startup.
- Renamed database environment variables from
POSTGRES_*toDB_CHAT_*naming convention - Commented out automatic Django migrations in the entrypoint script
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| config/settings.py | Updates PostgreSQL database configuration to use DB_CHAT_NAME, DB_CHAT_USER, and DB_CHAT_PASSWORD environment variables instead of POSTGRES_* variants |
| utils/entrypoint.sh | Comments out automatic execution of Django migrations during container startup |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| 'HOST': config('POSTGRES_HOST', default='localhost'), | ||
| 'PORT': config('POSTGRES_PORT', default='5432'), |
There was a problem hiding this comment.
Inconsistent naming convention for database environment variables. While NAME, USER, and PASSWORD now use the DB_CHAT_* prefix, HOST and PORT still use the POSTGRES_* prefix. Consider renaming POSTGRES_HOST to DB_CHAT_HOST and POSTGRES_PORT to DB_CHAT_PORT for consistency.
| 'HOST': config('POSTGRES_HOST', default='localhost'), | |
| 'PORT': config('POSTGRES_PORT', default='5432'), | |
| 'HOST': config('DB_CHAT_HOST', default='localhost'), | |
| 'PORT': config('DB_CHAT_PORT', default='5432'), |
There was a problem hiding this comment.
각 디비별로 독립적인 env를 사용하는건 원래 목표와 부합하여 좋은 변경이네요
There was a problem hiding this comment.
해당 로직 자체의 문제보단 기존에 디비 컨테이너가 제대로 실행 및 연결이 되지 않아서 발생한 문제 같아 보이네요.
거기에 해당 파일의 상단에 보면 running 중인지 확인하는 로직이 있는데 해당 로직도 제대로 동작하지 않는다고 보여집니다.
결국 근본적인 원인인 postgre 실행 및 연결 문제를 해결하는 것이 급선무라고 판단됩니다.
📌 변경 내용 요약
DB_CHAT_NAME,DB_CHAT_USER,DB_CHAT_PASSWORD)로 분리했습니다.🔗 관련 이슈
💡 주요 변경 사항
config/settings.py: 서비스별 DB 환경 변수로 변경POSTGRES_DB→DB_CHAT_NAMEPOSTGRES_USER→DB_CHAT_USERPOSTGRES_PASSWORD→DB_CHAT_PASSWORDutils/entrypoint.sh: 자동 마이그레이션 비활성화 (주석 처리)python manage.py makemigrations주석 처리python manage.py migrate주석 처리🧩 리뷰어 참고 사항
.env파일의 값이 변경되었으므로, 로컬 환경에서 테스트 시.env를 새로 적용해야 합니다.mydatabase)는 더 이상 사용하지 않으며,chat_db데이터베이스가 생성됩니다.docker exec chat python manage.py migrate✅ 테스트 방법
Chat 서비스가 정상적으로 시작되는지 확인:
데이터베이스 연결 확인: