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
13 changes: 6 additions & 7 deletions AI/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
FROM python:3.12-slim
FROM python:3.10-slim

WORKDIR /app

# 1. requirements 설치 (컨텍스트 = AI 이므로, AI/requirements.txt 기준)
# 1. 라이브러리 설치
COPY requirements.txt /app/requirements.txt
RUN pip install --no-cache-dir -r requirements.txt

# 2. AI 디렉토리 내용물을 /app 루트에 그대로 복사
# => /app/libs/core/pipeline.py 이런 구조가 됨
# 2. 소스 코드 복사
COPY . /app

# 3. 파이썬 모듈 검색 경로에 /app 추가
# 3. 환경 변수 설정
ENV PYTHONPATH=/app

# 4. libs.core.pipeline 모듈을 "패키지로" 실행
CMD ["python", "-m", "libs.core.pipeline"]
# 4. 실행 명령어 (데이터 수집 -> 분석 루틴 순차 실행)
CMD ["/bin/sh", "-c", "python modules/data_collector/run.py && python pipelines/daily_routine.py"]
Comment on lines +1 to +16
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

컨테이너가 root 권한으로 실행됩니다

현재 Dockerfile에는 USER 설정이 없어 기본 root로 실행됩니다. 운영 환경 기준으로 non-root 실행 전환이 필요합니다.

제안 수정안
 FROM python:3.10-slim
 
 WORKDIR /app
 
 # 1. 라이브러리 설치
 COPY requirements.txt /app/requirements.txt
 RUN pip install --no-cache-dir -r requirements.txt
 
 # 2. 소스 코드 복사
 COPY . /app
+RUN groupadd -r app && useradd -r -g app app \
+    && chown -R app:app /app
 
 # 3. 환경 변수 설정
 ENV PYTHONPATH=/app
+USER app
 
 # 4. 실행 명령어 (데이터 수집 -> 분석 루틴 순차 실행)
 CMD ["/bin/sh", "-c", "python modules/data_collector/run.py && python pipelines/daily_routine.py"]
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
FROM python:3.10-slim
WORKDIR /app
# 1. requirements 설치 (컨텍스트 = AI 이므로, AI/requirements.txt 기준)
# 1. 라이브러리 설치
COPY requirements.txt /app/requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
# 2. AI 디렉토리 내용물을 /app 루트에 그대로 복사
# => /app/libs/core/pipeline.py 이런 구조가 됨
# 2. 소스 코드 복사
COPY . /app
# 3. 파이썬 모듈 검색 경로에 /app 추가
# 3. 환경 변수 설정
ENV PYTHONPATH=/app
# 4. libs.core.pipeline 모듈을 "패키지로" 실행
CMD ["python", "-m", "libs.core.pipeline"]
# 4. 실행 명령어 (데이터 수집 -> 분석 루틴 순차 실행)
CMD ["/bin/sh", "-c", "python modules/data_collector/run.py && python pipelines/daily_routine.py"]
FROM python:3.10-slim
WORKDIR /app
# 1. 라이브러리 설치
COPY requirements.txt /app/requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
# 2. 소스 코드 복사
COPY . /app
RUN groupadd -r app && useradd -r -g app app \
&& chown -R app:app /app
# 3. 환경 변수 설정
ENV PYTHONPATH=/app
USER app
# 4. 실행 명령어 (데이터 수집 -> 분석 루틴 순차 실행)
CMD ["/bin/sh", "-c", "python modules/data_collector/run.py && python pipelines/daily_routine.py"]
🧰 Tools
🪛 Trivy (0.69.1)

[error] 1-1: Image user should not be 'root'

Specify at least 1 USER command in Dockerfile with non-root user as argument

Rule: DS-0002

Learn more

(IaC/Dockerfile)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@AI/Dockerfile` around lines 1 - 16, The Dockerfile currently runs containers
as root; create and use a non-root user by adding steps that: create a
group/user (e.g., addgroup --system app && adduser --system --ingroup app app or
use useradd), chown the WORKDIR (/app) and any runtime directories to that user
(chown -R app:app /app), and set USER app before the CMD so the existing CMD
["... python modules/data_collector/run.py && python
pipelines/daily_routine.py"] runs as the non-root user; update lines around
WORKDIR, COPY, and CMD to include these user creation, chown, and USER
instructions.

34 changes: 34 additions & 0 deletions AI/config/watchlist.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"tickers": [
"NVDA",
"TSLA",
"MSFT",
"MU",
"AAPL",
"AMZN",
"GOOGL",
"AMD",
"META",
"PLTR",
"GOOG",
"AVGO",
"WMT",
"INTC",
"LLY",
"ORCL",
"PANW",
"BKNG",
"JPM",
"XOM",
"AMAT",
"V",
"WDC",
"NFLX",
"APP",
"CRWD",
"JNJ",
"CRM",
"BAC",
"COIN"
]
}
15 changes: 5 additions & 10 deletions AI/libs/database/fetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,17 @@ def fetch_macro_indicators(

return df

def fetch_market_breadth(
start_date: str,
db_name: str = "db"
) -> pd.DataFrame:
"""
[공통] 시장 건전성 지표 (Market Breadth)
"""
def fetch_market_breadth(start_date: str, db_name: str = "db"):
engine = get_engine(db_name)
query = text("""
SELECT date,
advance_decline_ratio, fear_greed_index,
new_highs, new_lows, above_ma200_pct
nh_nl_index, -- 긴 이름 대신 실제 DB 컬럼명 사용
ma200_pct
FROM public.market_breadth
WHERE date >= :start_date
ORDER BY date ASC;
ORDER BY date ASC
""")
# ... 이하 로직 동일

with engine.connect() as conn:
df = pd.read_sql(query, conn, params={"start_date": start_date})
Expand Down
Loading