48 lines
1.1 KiB
Docker
48 lines
1.1 KiB
Docker
FROM python:3.10-slim
|
|
|
|
# 작업 디렉토리 설정
|
|
WORKDIR /app
|
|
|
|
# 시스템 패키지 설치
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
build-essential \
|
|
gcc \
|
|
libsqlite3-dev \
|
|
libssl-dev \
|
|
libffi-dev \
|
|
libbz2-dev \
|
|
libreadline-dev \
|
|
libncurses5-dev \
|
|
libgdbm-dev \
|
|
liblzma-dev \
|
|
libtk8.6 \
|
|
tk8.6-dev \
|
|
tcl8.6-dev \
|
|
wget \
|
|
curl \
|
|
unzip \
|
|
git \
|
|
cron \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# requirements 설치
|
|
COPY requirements.txt ./
|
|
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
# 앱 전체 복사
|
|
COPY . .
|
|
|
|
# 환경 변수 설정
|
|
ENV PYTHONUNBUFFERED=1
|
|
|
|
# 크론 작업 등록: 매일 11시에 daily_run.py 실행
|
|
RUN echo "0 11 * * * python /app/daily_run.py >> /var/log/cron.log 2>&1" > /etc/cron.d/daily-cron \
|
|
&& chmod 0644 /etc/cron.d/daily-cron \
|
|
&& crontab /etc/cron.d/daily-cron
|
|
|
|
# 로그 파일 생성
|
|
RUN touch /var/log/cron.log
|
|
|
|
# 컨테이너 시작 시 cron 실행 + file_watch.py 실행 + 로그 출력 유지
|
|
CMD cron && python lib/file_watch.py & tail -f /var/log/cron.log
|