Skip to content

Commit e0f7889

Browse files
committed
feat: uv로 실행, 명령어 추가 및 포트 외부에서 설정
1 parent e86c626 commit e0f7889

File tree

3 files changed

+44
-18
lines changed

3 files changed

+44
-18
lines changed

Dockerfile

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,24 @@ RUN apt-get update && apt-get install -y \
99
libpq-dev \
1010
&& rm -rf /var/lib/apt/lists/*
1111

12-
# 3. 작업 디렉토리 설정
12+
# 3. uv 설치
13+
RUN pip install --no-cache-dir uv
14+
15+
# 4. 작업 디렉토리 설정
1316
WORKDIR /app
1417

15-
# 4. 소스 코드 복사 및 의존성 설치
18+
# 5. 소스 코드 복사 및 의존성 설치
1619
COPY pyproject.toml ./
1720
COPY . .
18-
RUN pip install --upgrade pip setuptools wheel \
19-
&& pip install .
21+
RUN uv pip install --system --upgrade pip setuptools wheel \
22+
&& uv pip install --system .
2023

21-
# 5. 환경 변수 설정
24+
# 6. 환경 변수 설정
2225
ENV PYTHONPATH=/app
2326
ENV PYTHONUNBUFFERED=1
2427

25-
# 6. 포트 노출
26-
EXPOSE 8501
28+
# 7. 포트 설정
29+
ENV STREAMLIT_SERVER_PORT=8501
2730

28-
# 7. 실행 명령
29-
CMD streamlit run ./interface/streamlit_app.py --server.port=8501
31+
# 8. 실행 명령
32+
CMD ["lang2sql", "run-streamlit-docker"]

cli/__init__.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
명령어 예시: lang2sql --datahub_server http://localhost:8080 --run-streamlit
66
"""
77

8-
import os
98
import logging
9+
import os
1010
import subprocess
1111

1212
import click
@@ -238,6 +238,24 @@ def run_streamlit_cli_command(port: int) -> None:
238238
run_streamlit_command(port)
239239

240240

241+
@cli.command(name="run-streamlit-docker")
242+
def run_streamlit_docker_command() -> None:
243+
"""
244+
Docker 컨테이너 환경에서 Streamlit 애플리케이션을 실행하는 명령어입니다.
245+
246+
이 명령은 환경 변수 STREAMLIT_SERVER_PORT 를 읽어와
247+
해당 포트에서 Streamlit 서버를 구동합니다.
248+
docker-compose.yml 에서 설정한 환경 변수를 그대로 활용할 수 있습니다.
249+
250+
실행 예시:
251+
lang2sql run-streamlit-docker
252+
"""
253+
254+
port = int(os.environ.get("STREAMLIT_SERVER_PORT", "8501"))
255+
logger.info("Executing 'run-streamlit-docker' on port %d...", port)
256+
run_streamlit_command(port)
257+
258+
241259
@cli.command(name="query")
242260
@click.argument("question", type=str)
243261
@click.option(

docker-compose.yml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
services:
22
streamlit:
3+
hostname: streamlit
4+
container_name: streamlit
35
build: .
46
ports:
57
- "8501:8501"
@@ -8,21 +10,24 @@ services:
810
env_file:
911
- .env
1012
environment:
11-
- DATABASE_URL=postgresql://postgres:password@db:5432/streamlit_db
13+
- STREAMLIT_SERVER_PORT=8501
14+
- DATABASE_URL=postgresql://pgvector:pgvector@pgvector:5432/streamlit
1215
depends_on:
13-
- db
16+
- pgvector
1417

15-
db:
18+
pgvector:
1619
image: pgvector/pgvector:pg17
17-
container_name: pgvector-db
20+
hostname: pgvector
21+
container_name: pgvector
1822
environment:
19-
POSTGRES_USER: postgres
20-
POSTGRES_PASSWORD: password
21-
POSTGRES_DB: streamlit_db
23+
POSTGRES_USER: pgvector
24+
POSTGRES_PASSWORD: pgvector
25+
POSTGRES_DB: streamlit
2226
ports:
2327
- "5432:5432"
2428
volumes:
2529
- pgdata:/var/lib/postgresql/data
2630
- ./postgres/schema.sql:/docker-entrypoint-initdb.d/schema.sql
31+
2732
volumes:
28-
pgdata:
33+
pgdata:

0 commit comments

Comments
 (0)