.env에서 서버 바인딩(HOST/PORT/LOG_LEVEL/RELOAD) 받아오기
- config.Settings에 host/port/log_level/reload 필드 추가
- app/main.py에 main() + __main__ 진입점 추가 (python -m app.main)
- Dockerfile: python:3.13-slim 베이스로, CMD를 python -m app.main 으로 변경
- docker-compose: env_file 사용, ports를 ${PORT} 변수화
- 환경변수 PORT=N 으로 override 가능 (uvicorn 직접 실행도 그대로 지원)
This commit is contained in:
1 parent
bc40ace2fd
commit
f31ef142e8
6 files changed
+71
-14
No files matched your search
+8
-5
@@ -1,12 +1,14 @@
|
||||
FROM python:3.11-slim
|
||||
FROM python:3.13-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
ENV PYTHONDONTWRITEBYTECODE=1 \
|
||||
PYTHONUNBUFFERED=1 \
|
||||
PIP_NO_CACHE_DIR=1
|
||||
PIP_NO_CACHE_DIR=1 \
|
||||
HOST=0.0.0.0 \
|
||||
PORT=8000
|
||||
|
||||
# kiwipiepy/scikit-learn 빌드에 필요한 시스템 패키지
|
||||
# kiwipiepy/scikit-learn/torch 빌드에 필요한 시스템 패키지
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
build-essential \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
@@ -23,6 +25,7 @@ VOLUME ["/app/data/reference"]
|
||||
EXPOSE 8000
|
||||
|
||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=30s --retries=3 \
|
||||
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/v1/health').read()" || exit 1
|
||||
CMD python -c "import os, urllib.request; urllib.request.urlopen(f'http://localhost:{os.environ.get(\"PORT\", 8000)}/v1/health').read()" || exit 1
|
||||
|
||||
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
|
||||
# .env의 HOST/PORT/LOG_LEVEL 따라 동작
|
||||
CMD ["python", "-m", "app.main"]
|
||||
Reference in new issue
Block a user