Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions apps/pre-processing-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM python:3.11-slim AS builder
WORKDIR /app
RUN apt-get update && apt-get install -y --no-install-recommends curl \
&& rm -rf /var/lib/apt/lists/*
RUN curl -sSL https://install.python-poetry.org | python3 -
ENV PATH="/root/.local/bin:$PATH"
RUN poetry config virtualenvs.create false
COPY pyproject.toml poetry.lock ./
RUN poetry install --no-root

FROM python:3.11-slim AS final
WORKDIR /app
# site-packages + 콘솔 스크립트(gunicorn/uvicorn) 함께 복사
COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages
COPY --from=builder /usr/local/bin /usr/local/bin
COPY ./app ./app
EXPOSE 8000
CMD ["gunicorn", "-w", "2", "-k", "uvicorn.workers.UvicornWorker", "-b", "0.0.0.0:8000", "app.main:app"]
12 changes: 12 additions & 0 deletions apps/pre-processing-service/app/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,15 @@ class PrdSettings(BaseSettingsConfig):
class Config:
env_file = ['.env', 'prd.env']

def get_settings() -> BaseSettingsConfig:
"""환경 변수에 따라 적절한 설정 객체를 반환하는 함수"""
mode = os.getenv("MODE", "dev")
if mode == "dev":
return DevSettings()
elif mode == "prd":
return PrdSettings()
else:
raise ValueError(f"Invalid MODE environment variable: {mode}")


settings = get_settings()
24 changes: 23 additions & 1 deletion apps/pre-processing-service/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion apps/pre-processing-service/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ dependencies = [
"loguru (>=0.7.3,<0.8.0)",
"pytest (>=8.4.1,<9.0.0)",
"dotenv (>=0.9.9,<0.10.0)",
"pydantic-settings (>=2.10.1,<3.0.0)"
"pydantic-settings (>=2.10.1,<3.0.0)",
"gunicorn (>=23.0.0,<24.0.0)"
]


Expand Down
12 changes: 12 additions & 0 deletions docker/local/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@ services:
- pgadmin_data:/var/lib/pgadmin
depends_on:
- postgres
pre-processing-service:
build:
context: ../../apps/pre-processing-service # 프로젝트 루트 (Dockerfile이 루트에 없으면 맞게 조정)
dockerfile: Dockerfile # Dockerfile 경로 (루트에 없다면 상대경로로 수정)
image: pre-processing-service:latest
container_name: pre-processing-service
restart: always
ports:
- "8000:8000"
env_file:
- ../../apps/pre-processing-service/.env # 공통
- ../../apps/pre-processing-service/dev.env # 개발

volumes:
postgres_data:
Expand Down
Loading