fix: Dockerfile chmod 에러 수정 및 환경변수 지원 추가

- Dockerfile: chmod 명령어에 RUN 추가
- .env.example: 모든 설정 항목 및 자세한 주석 추가
- config.yaml: 각 설정 항목에 대한 상세 주석 추가
- config.sample.yaml: 샘플 파일 주석 개선
- conf/db.py: 환경변수 우선 적용 기능 추가
- lib/common.py: load_config에 환경변수 오버라이드 지원
- 환경변수로 모든 설정값 제어 가능 (DB, API, POS 등)
This commit is contained in:
2025-12-26 17:42:20 +09:00
parent 7121f250bc
commit 98d633ead8
5 changed files with 214 additions and 54 deletions

View File

@ -12,12 +12,22 @@ BASE_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
CONFIG_PATH = os.path.join(BASE_DIR, 'conf', 'config.yaml')
def load_config(path=CONFIG_PATH):
"""설정 파일 로드"""
"""설정 파일 로드 (환경변수 우선)"""
try:
# config.yaml 로드
with open(path, 'r', encoding='utf-8') as f:
config = yaml.safe_load(f)
if not config:
raise ValueError(f"설정 파일이 비어있음: {path}")
# 환경변수로 데이터베이스 설정 덮어쓰기
if os.getenv('DB_HOST'):
config.setdefault('database', {})
config['database']['host'] = os.getenv('DB_HOST', config['database'].get('host'))
config['database']['user'] = os.getenv('DB_USER', config['database'].get('user'))
config['database']['password'] = os.getenv('DB_PASSWORD', config['database'].get('password'))
config['database']['name'] = os.getenv('DB_NAME', config['database'].get('name'))
return config
except FileNotFoundError:
logger.error(f"설정 파일을 찾을 수 없음: {path}")