This commit is contained in:
hiondal 2025-06-15 20:19:52 +00:00
parent 67d4d69bc4
commit 42dd563205
5 changed files with 201 additions and 67 deletions

View File

@ -1,22 +1,35 @@
# vector/app/main.py
import os
import sys
import logging
from contextlib import asynccontextmanager
from datetime import datetime
from typing import Optional
# 현재 디렉토리를 Python 경로에 추가
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
# =============================================================================
# .env 파일 로딩 (다른 import보다 먼저)
# =============================================================================
from dotenv import load_dotenv
def is_kubernetes_env():
"""Kubernetes 환경 감지"""
return (
os.path.exists('/var/run/secrets/kubernetes.io/serviceaccount') or
os.getenv('KUBERNETES_SERVICE_HOST') or
os.getenv('ENVIRONMENT') == 'production'
)
# .env 파일에서 환경변수 로드
load_dotenv()
# 조건부 dotenv 로딩
if not is_kubernetes_env():
try:
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from dotenv import load_dotenv
load_dotenv()
print("✅ 로컬 개발환경: .env 파일 로딩")
except ImportError:
print("⚠️ python-dotenv 없음, 환경변수만 사용")
else:
print(" Kubernetes/Production: ConfigMap/Secret 사용")
import logging
from contextlib import asynccontextmanager
from datetime import datetime
from typing import Optional
import asyncio
import fastapi
from fastapi import FastAPI, HTTPException, BackgroundTasks, Depends

View File

@ -1,17 +1,15 @@
# deployment/container/Dockerfile
# Vector DB API Service Image - 디버깅 버전 (사용자 정보 및 Poetry 환경 수정)
ARG BASE_IMAGE=vector-api-base:latest
# Vector DB API Service Image - 수정 버전
ARG BASE_IMAGE=vector-api-base:optimized-dotenv-0.9.9-v1.0
FROM ${BASE_IMAGE}
# 메타데이터
LABEL maintainer="admin@example.com"
LABEL version="1.0.6-debug-fixed"
LABEL description="Vector DB API Service - Debug Version (사용자 정보 수정)"
LABEL version="1.0.7-fixed"
LABEL description="Vector DB API Service - Fixed Poetry Environment"
# 🔧 사용자 정보 수정 (root 권한으로)
USER root
# passwd 파일에 appuser 정보 추가
RUN echo "appuser:x:1000:1000:App User:/home/appuser:/bin/bash" >> /etc/passwd && \
echo "appuser:x:1000:" >> /etc/group
@ -21,6 +19,12 @@ USER appuser
# 작업 디렉토리 설정
WORKDIR /home/appuser
# 🔧 Poetry 프로젝트 파일 복사 (중요!)
COPY pyproject.toml poetry.lock ./
# 🔧 Base Image의 패키지를 현재 프로젝트에서 사용 가능하도록 설정
RUN poetry install --only=main --no-root
# 🚀 애플리케이션 소스 코드 복사
COPY app/ app/

View File

@ -100,7 +100,7 @@ packages = [{include = "app"}]
[tool.poetry.dependencies]
python = "^3.11"
dotenv = "^0.9.9"
python-dotenv = "^1.1.0"
[build-system]
requires = ["poetry-core"]
@ -130,8 +130,6 @@ RUN echo "🚀 최적화된 의존성 설치 시작..." && \
\
echo "6⃣ Claude AI 라이브러리 설치..." && \
poetry add anthropic && \
echo "2⃣ dotenv 0.9.9 설치..." && \
poetry add dotenv==0.9.9 && \
\
echo "✅ 최적화된 의존성 설치 완료!"

214
vector/poetry.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -30,7 +30,6 @@ torch = {version = "^2.7.1+cpu", source = "pytorch-cpu"}
torchvision = {version = "^0.22.1+cpu", source = "pytorch-cpu"}
torchaudio = {version = "^2.7.1+cpu", source = "pytorch-cpu"}
starlette = ">=0.40.0,<0.46.0"
dotenv = "^0.9.9"
[[tool.poetry.source]]
name = "pytorch-cpu"