Skip to content

Conversation

@eajnoeyeel
Copy link
Contributor

@eajnoeyeel eajnoeyeel commented Oct 31, 2025

📌 변경 내용 요약

이 PR은 두 가지 주요 문제를 해결합니다:

  1. PostgreSQL 18+ 호환성: Docker 볼륨 마운트 경로를 PostgreSQL 18+의 새로운 디렉토리 구조에 맞게 수정했습니다.
  2. 마이크로서비스 데이터베이스 격리: 환경 변수 우선순위 문제를 해결하고, 프론트엔드 HTTP 설정을 추가했습니다.

🔗 관련 이슈

💡 주요 변경 사항

docker-compose.yml:

  • PostgreSQL 볼륨 마운트 경로 변경:
    • database_user, database_chat, database_game: /var/lib/postgresql/data/var/lib/postgresql (PostgreSQL 18+ 호환)
  • user, chat, game 서비스에 DATABASE_ENGINE=postgresql 명시적 설정 추가 (최고 우선순위)
  • 프론트엔드 환경 변수에 HTTP URL 설정 추가:
    • USER_API_URL=http://localhost/api/user
    • CHAT_API_URL=http://localhost/api/chat
    • FRIEND_API_URL=http://localhost/api/user/friend
    • GAME_API_URL=http://localhost/api/game

환경 변수 우선순위:

  • environment: (최고) > 서비스별 .env > 메인 .env (최저)

🧩 리뷰어 참고 사항

  • PostgreSQL 18+는 데이터를 /var/lib/postgresql/18/docker/에 저장합니다.
  • 기존 볼륨이 있다면 docker-compose down -v로 제거 후 재생성이 필요할 수 있습니다.
  • 각 서비스별 데이터베이스 생성 및 권한 부여 필요:
    # User 서비스 예시
    docker exec database_user psql -U myuser -d postgres -c "CREATE DATABASE user_db OWNER myuser;"
    docker exec database_user psql -U myuser -d postgres -c "CREATE USER user_user WITH PASSWORD 'user_pass';"
    docker exec database_user psql -U myuser -d user_db -c "GRANT ALL ON SCHEMA public TO user_user;"
    
    # Chat 및 Game 서비스도 동일하게 생성 필요

✅ 테스트 방법

  1. Docker Compose 완전 재시작:

    docker-compose down -v
    docker-compose up -d
  2. 데이터베이스 연결 확인:

    docker exec user python manage.py shell -c "from django.conf import settings; print(settings.DATABASES['default']['NAME'])"
    # 예상 출력: user_db
  3. 프론트엔드 환경 변수 확인:

    docker exec frontend env | grep API_URL
    # 예상: http://localhost/api/...
  4. 통합 테스트:

    curl -X POST http://localhost/api/user/register/nickname-check/ \
      -H "Content-Type: application/json" \
      -d '{"nickname":"testuser"}'
    # 예상 응답: {"message":"ok"}

⚠️ Breaking Changes

  • 기존 PostgreSQL 볼륨 경로가 변경되어 기존 데이터는 접근할 수 없을 수 있습니다.
  • 완전한 재설정이 필요할 수 있습니다 (docker-compose down -v 실행 후 재시작).

Changes to docker-compose.yml:
- Updated PostgreSQL volume mounts from /var/lib/postgresql/data to /var/lib/postgresql (PostgreSQL 18+ compatibility)
- Added explicit DATABASE_ENGINE=postgresql environment variable to user, chat, game services
- Updated frontend environment to use HTTP URLs instead of HTTPS (avoids SSL cert issues in development)
- Ensures each service connects to its own database

Changes to .env:
- Updated DATA_PATH to correct absolute path
- Service-specific database configurations (user_db, chat_db, game_db)

Resolves 'Failed to check nickname' error by ensuring proper database isolation between microservices.
@eajnoeyeel eajnoeyeel changed the title 🐛 fix: Docker Compose 설정 - PostgreSQL 18+ 호환성 및 마이크로서비스 데이터베이스 격리 Docker Compose 설정 - PostgreSQL 18+ 호환성 및 마이크로서비스 데이터베이스 격리 Oct 31, 2025
@eajnoeyeel eajnoeyeel requested review from AhnJoonSung, Newsujin and bean-baek and removed request for bean-baek November 3, 2025 02:59
Copy link
Member

Choose a reason for hiding this comment

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

이거 근데 env가 왜 올라와있지?

env_file:
- ./.env
- ./frontend/.env
environment:
Copy link
Member

Choose a reason for hiding this comment

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

env 파일에 안하고 명시적으로 한 이유가 있을까요?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants