Skip to content

Commit 1a403a5

Browse files
committed
hotfix: cron 환경변수 전파 문제 해결
- entrypoint.sh에서 docker 환경변수를 crontab에 직접 주입 - load_dotenv 제거 (docker-compose env_file로 충분) - crontab 동적 생성으로 변경 (빌드타임 → 런타임) - BATCH_API_URL=None 에러 해결
1 parent 409dfd8 commit 1a403a5

File tree

5 files changed

+19
-7
lines changed

5 files changed

+19
-7
lines changed

Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ RUN python -m playwright install chromium
1515

1616
COPY . .
1717

18-
RUN chmod 0644 crontab
19-
RUN crontab crontab
18+
# crontab은 entrypoint.sh에서 환경변수와 함께 동적 생성
19+
# RUN chmod 0644 crontab
20+
# RUN crontab crontab
2021

2122
COPY entrypoint.sh /app/entrypoint.sh
2223
RUN chmod +x /app/entrypoint.sh

core/delivery/batch.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,3 @@ def complete_batch(self, batch_id: int, total_count: int, completed_at: str, err
5454
logger.info("[배치 종료 (성공)] Batch ID: %s, Total: %s개 수집 완료!", batch_id, total_count)
5555
except Exception as e:
5656
logger.error("[배치 종료 통보 실패] Batch ID: %s, Error: %s", batch_id, e, exc_info=True)
57-

entrypoint.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,19 @@ else
4141
echo "[entrypoint] 필수 상태 키 확인됨 (${REQUIRED_PLATFORM_KEYS}). 바로 cron 시작."
4242
fi
4343

44+
echo "[entrypoint] cron 환경변수 주입 중..."
45+
cat >> /tmp/crontab_with_env <<EOF
46+
# 환경변수 (Docker .env에서 로드)
47+
BATCH_API_URL=${BATCH_API_URL}
48+
AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
49+
AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
50+
AWS_S3_BUCKET=${AWS_S3_BUCKET}
51+
AWS_REGION=${AWS_REGION:-ap-northeast-2}
52+
REQUIRED_PLATFORM_KEYS=${REQUIRED_PLATFORM_KEYS}
53+
54+
EOF
55+
56+
crontab /tmp/crontab_with_env
57+
echo "[entrypoint] crontab 등록 완료. cron 데몬 시작..."
58+
4459
cron -f

initial_load.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
from concurrent.futures import ThreadPoolExecutor, as_completed
55
from datetime import datetime
66

7-
from dotenv import load_dotenv
8-
97
from core.backup_handler import backup_raw_data
108
from core.config import (CHUNK_SIZE, INITIAL_MAX_SCROLLS, MAX_WORKERS,
119
STATE_FILE_PATH)
@@ -14,8 +12,6 @@
1412
from core.state_manager import StateManager
1513
from crawlers.musinsa import MusinsaCrawler
1614

17-
load_dotenv()
18-
1915
def seed_initial_data():
2016
logger.info("[초기로드] Playwright Chromium 설치 확인...")
2117
try:

main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from datetime import datetime
22
import subprocess
3+
34
from core.config import STATE_FILE_PATH
45
from core.state_manager import StateManager
56
from core.delivery import get_delivery

0 commit comments

Comments
 (0)