From e86c626a25cb889768bc7dbe8e52071757ad938a Mon Sep 17 00:00:00 2001 From: ParkGyeongTae Date: Sun, 14 Sep 2025 23:37:55 +0900 Subject: [PATCH 1/4] =?UTF-8?q?fix:=20=EB=8F=84=EC=BB=A4=ED=8C=8C=EC=9D=BC?= =?UTF-8?q?=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20=EB=B9=8C=EB=93=9C=20=EC=8B=A4?= =?UTF-8?q?=ED=8C=A8=ED=98=84=EC=83=81=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6d30603..705a152 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,32 +1,29 @@ -# Python 3.10 slim 이미지 기반 -FROM python:3.12-slim +# 1. Base image +FROM python:3.12-slim-bullseye -# 시스템 라이브러리 설치 +# 2. 시스템 라이브러리 설치 RUN apt-get update && apt-get install -y \ build-essential \ curl \ - software-properties-common \ git \ libpq-dev \ && rm -rf /var/lib/apt/lists/* -# 작업 디렉토리 설정 +# 3. 작업 디렉토리 설정 WORKDIR /app -# 의존성 파일 복사 및 설치 -COPY requirements.txt . -RUN pip install --no-cache-dir -r requirements.txt - -# 전체 서비스 코드 복사 +# 4. 소스 코드 복사 및 의존성 설치 +COPY pyproject.toml ./ COPY . . +RUN pip install --upgrade pip setuptools wheel \ + && pip install . -# Python 환경 설정 +# 5. 환경 변수 설정 ENV PYTHONPATH=/app ENV PYTHONUNBUFFERED=1 -# Streamlit 포트 노출 +# 6. 포트 노출 EXPOSE 8501 -# Streamlit 실행 명령 -CMD ["python", "-c", "from llm_utils.tools import set_gms_server; import os; set_gms_server(os.getenv('DATAHUB_SERVER', 'http://localhost:8080'))"] -CMD ["streamlit", "run", "./interface/streamlit_app.py", "--server.port=8501"] \ No newline at end of file +# 7. 실행 명령 +CMD streamlit run ./interface/streamlit_app.py --server.port=8501 From e0f7889e469caff6232e7bc6219a7b89f5d0a684 Mon Sep 17 00:00:00 2001 From: ParkGyeongTae Date: Tue, 16 Sep 2025 21:18:49 +0900 Subject: [PATCH 2/4] =?UTF-8?q?feat:=20uv=EB=A1=9C=20=EC=8B=A4=ED=96=89,?= =?UTF-8?q?=20=EB=AA=85=EB=A0=B9=EC=96=B4=20=EC=B6=94=EA=B0=80=20=EB=B0=8F?= =?UTF-8?q?=20=ED=8F=AC=ED=8A=B8=20=EC=99=B8=EB=B6=80=EC=97=90=EC=84=9C=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 21 ++++++++++++--------- cli/__init__.py | 20 +++++++++++++++++++- docker-compose.yml | 21 +++++++++++++-------- 3 files changed, 44 insertions(+), 18 deletions(-) diff --git a/Dockerfile b/Dockerfile index 705a152..5f4034a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,21 +9,24 @@ RUN apt-get update && apt-get install -y \ libpq-dev \ && rm -rf /var/lib/apt/lists/* -# 3. 작업 디렉토리 설정 +# 3. uv 설치 +RUN pip install --no-cache-dir uv + +# 4. 작업 디렉토리 설정 WORKDIR /app -# 4. 소스 코드 복사 및 의존성 설치 +# 5. 소스 코드 복사 및 의존성 설치 COPY pyproject.toml ./ COPY . . -RUN pip install --upgrade pip setuptools wheel \ - && pip install . +RUN uv pip install --system --upgrade pip setuptools wheel \ + && uv pip install --system . -# 5. 환경 변수 설정 +# 6. 환경 변수 설정 ENV PYTHONPATH=/app ENV PYTHONUNBUFFERED=1 -# 6. 포트 노출 -EXPOSE 8501 +# 7. 포트 설정 +ENV STREAMLIT_SERVER_PORT=8501 -# 7. 실행 명령 -CMD streamlit run ./interface/streamlit_app.py --server.port=8501 +# 8. 실행 명령 +CMD ["lang2sql", "run-streamlit-docker"] diff --git a/cli/__init__.py b/cli/__init__.py index 6cd41ce..53e5771 100644 --- a/cli/__init__.py +++ b/cli/__init__.py @@ -5,8 +5,8 @@ 명령어 예시: lang2sql --datahub_server http://localhost:8080 --run-streamlit """ -import os import logging +import os import subprocess import click @@ -238,6 +238,24 @@ def run_streamlit_cli_command(port: int) -> None: run_streamlit_command(port) +@cli.command(name="run-streamlit-docker") +def run_streamlit_docker_command() -> None: + """ + Docker 컨테이너 환경에서 Streamlit 애플리케이션을 실행하는 명령어입니다. + + 이 명령은 환경 변수 STREAMLIT_SERVER_PORT 를 읽어와 + 해당 포트에서 Streamlit 서버를 구동합니다. + docker-compose.yml 에서 설정한 환경 변수를 그대로 활용할 수 있습니다. + + 실행 예시: + lang2sql run-streamlit-docker + """ + + port = int(os.environ.get("STREAMLIT_SERVER_PORT", "8501")) + logger.info("Executing 'run-streamlit-docker' on port %d...", port) + run_streamlit_command(port) + + @cli.command(name="query") @click.argument("question", type=str) @click.option( diff --git a/docker-compose.yml b/docker-compose.yml index 097e87f..10b77a2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,7 @@ services: streamlit: + hostname: streamlit + container_name: streamlit build: . ports: - "8501:8501" @@ -8,21 +10,24 @@ services: env_file: - .env environment: - - DATABASE_URL=postgresql://postgres:password@db:5432/streamlit_db + - STREAMLIT_SERVER_PORT=8501 + - DATABASE_URL=postgresql://pgvector:pgvector@pgvector:5432/streamlit depends_on: - - db + - pgvector - db: + pgvector: image: pgvector/pgvector:pg17 - container_name: pgvector-db + hostname: pgvector + container_name: pgvector environment: - POSTGRES_USER: postgres - POSTGRES_PASSWORD: password - POSTGRES_DB: streamlit_db + POSTGRES_USER: pgvector + POSTGRES_PASSWORD: pgvector + POSTGRES_DB: streamlit ports: - "5432:5432" volumes: - pgdata:/var/lib/postgresql/data - ./postgres/schema.sql:/docker-entrypoint-initdb.d/schema.sql + volumes: - pgdata: \ No newline at end of file + pgdata: From 2e39eb25cd66a01a2476d377e1c98630bf210b17 Mon Sep 17 00:00:00 2001 From: ParkGyeongTae Date: Wed, 17 Sep 2025 08:20:03 +0900 Subject: [PATCH 3/4] =?UTF-8?q?remove:=20CLI=20run-streamlit-docker=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 2 +- cli/__init__.py | 19 ------------------- 2 files changed, 1 insertion(+), 20 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5f4034a..4b3dd4a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,4 +29,4 @@ ENV PYTHONUNBUFFERED=1 ENV STREAMLIT_SERVER_PORT=8501 # 8. 실행 명령 -CMD ["lang2sql", "run-streamlit-docker"] +CMD ["lang2sql", "run-streamlit"] diff --git a/cli/__init__.py b/cli/__init__.py index 53e5771..b5ef658 100644 --- a/cli/__init__.py +++ b/cli/__init__.py @@ -237,25 +237,6 @@ def run_streamlit_cli_command(port: int) -> None: logger.info("Executing 'run-streamlit' command on port %d...", port) run_streamlit_command(port) - -@cli.command(name="run-streamlit-docker") -def run_streamlit_docker_command() -> None: - """ - Docker 컨테이너 환경에서 Streamlit 애플리케이션을 실행하는 명령어입니다. - - 이 명령은 환경 변수 STREAMLIT_SERVER_PORT 를 읽어와 - 해당 포트에서 Streamlit 서버를 구동합니다. - docker-compose.yml 에서 설정한 환경 변수를 그대로 활용할 수 있습니다. - - 실행 예시: - lang2sql run-streamlit-docker - """ - - port = int(os.environ.get("STREAMLIT_SERVER_PORT", "8501")) - logger.info("Executing 'run-streamlit-docker' on port %d...", port) - run_streamlit_command(port) - - @cli.command(name="query") @click.argument("question", type=str) @click.option( From e147aa34dfc602ebfcb09af865204d122c018966 Mon Sep 17 00:00:00 2001 From: ParkGyeongTae Date: Wed, 17 Sep 2025 08:26:43 +0900 Subject: [PATCH 4/4] =?UTF-8?q?style:=20=EC=BD=94=EB=93=9C=20=ED=8F=AC?= =?UTF-8?q?=EB=A9=A7=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cli/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/cli/__init__.py b/cli/__init__.py index b5ef658..d3dce14 100644 --- a/cli/__init__.py +++ b/cli/__init__.py @@ -237,6 +237,7 @@ def run_streamlit_cli_command(port: int) -> None: logger.info("Executing 'run-streamlit' command on port %d...", port) run_streamlit_command(port) + @cli.command(name="query") @click.argument("question", type=str) @click.option(