diff --git a/build/Dockerfile b/build/Dockerfile index 4b18f23..699a0e2 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -1,6 +1,7 @@ -FROM ubuntu:22.04 +FROM python:3.10-slim -ENV DEBIAN_FRONTEND=noninteractive +# 작업 디렉토리 설정 +WORKDIR /app # 시스템 패키지 설치 RUN apt-get update && apt-get install -y --no-install-recommends \ @@ -11,7 +12,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ libffi-dev \ libbz2-dev \ libreadline-dev \ - libsqlite3-dev \ libncurses5-dev \ libgdbm-dev \ liblzma-dev \ @@ -22,40 +22,26 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ curl \ unzip \ git \ + cron \ && rm -rf /var/lib/apt/lists/* -# 작업 디렉토리 -WORKDIR /app +# requirements 설치 +COPY requirements.txt ./ +RUN pip install --no-cache-dir -r requirements.txt -# 애플리케이션 소스 복사 -COPY ../app ./app -COPY ../conf ./conf -COPY ../lib ./lib -COPY ../data ./data -COPY requirements.txt . +# 앱 전체 복사 +COPY . . -# tkcalendar, customtkinter GUI 라이브러리 의존성 -RUN pip install --no-cache-dir \ - tkcalendar \ - customtkinter +# 환경 변수 설정 +ENV PYTHONUNBUFFERED=1 -# pip 패키지 설치 (필요한 모든 모듈 명시) -RUN pip install --no-cache-dir \ - sqlalchemy \ - pandas \ - prophet \ - statsmodels \ - scikit-learn \ - numpy \ - requests \ - pyyaml \ - google-analytics-data \ - lxml \ - mysql-connector-python \ - pymysql +# 크론 작업 등록: 매일 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 -# 포트 오픈 -EXPOSE 5000 +# 로그 파일 생성 +RUN touch /var/log/cron.log -# 기본 실행 명령 -CMD ["python3", "app/app.py"] \ No newline at end of file +# 컨테이너 시작 시 cron 실행 + file_watch.py 실행 + 로그 출력 유지 +CMD cron && python lib/file_watch.py & tail -f /var/log/cron.log diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..1323511 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,13 @@ +services: + fg-static: + container_name: fg-static + build: + context: . + dockerfile: build/Dockerfile + image: reg.firstgarden.co.kr/fg-static:latest + volumes: + - ./data:/app/data + - ./conf:/app/conf + environment: + - TZ=Asia/Seoul + restart: unless-stopped