diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..16a37ba --- /dev/null +++ b/.dockerignore @@ -0,0 +1,21 @@ +# Docker 무시 파일 +# 빌드 시 컨테이너에 복사하지 않을 파일들 + +.git +.gitignore +.idea +.vscode +.venv +__pycache__ +*.pyc +*.pyo +*.pyd +.DS_Store +.python-version + +# 데이터 폴더는 볼륨으로 마운트 +data/ + +# 개발용 파일 +*.md +*.log diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a994a4a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,44 @@ +# FlaskFarm Docker Image +# Ubuntu 22.04 + Python 3.10 for sc module support on ARM64/x86_64 Linux + +FROM python:3.10-slim-bullseye + +LABEL maintainer="yommi" +LABEL description="FlaskFarm with sc module support" + +# Install system dependencies +RUN apt-get update && apt-get install -y --no-install-recommends \ + ffmpeg \ + git \ + curl \ + gcc \ + python3-dev \ + && rm -rf /var/lib/apt/lists/* + +# Set working directory +WORKDIR /app + +# Copy requirements first for layer caching +COPY ff_3_10_requirements.txt . + +# Install Python dependencies (skip FlaskFarm package - running from source) +RUN grep -v "FlaskFarm" ff_3_10_requirements.txt > requirements_docker.txt \ + && pip install --no-cache-dir -r requirements_docker.txt \ + && pip install --no-cache-dir curl_cffi yt-dlp loguru + +# Copy FlaskFarm application +COPY . . + +# Expose port +EXPOSE 9099 + +# Environment variables +ENV PYTHONUNBUFFERED=1 +ENV TZ=Asia/Seoul + +# Health check +HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ + CMD curl -f http://localhost:9099/ || exit 1 + +# Run FlaskFarm +CMD ["python", "main.py"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..7bb7969 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,23 @@ +# FlaskFarm Docker Compose +# Usage: +# docker compose up -d # 시작 +# docker compose down # 중지 +# docker compose logs -f # 로그 보기 + +services: + flaskfarm: + build: . + container_name: flaskfarm + restart: unless-stopped + ports: + - "9099:9099" + volumes: + # FlaskFarm data 폴더 (DB, 설정, 다운로드 등) + - ./data:/app/data + # 플러그인 폴더 (외부 마운트) + - ../ff_dev_plugins:/app/plugins + environment: + - TZ=Asia/Seoul + - PYTHONUNBUFFERED=1 + # M1/M2 Mac에서 ARM64 Linux 이미지 사용 + platform: linux/arm64 diff --git a/lib/plugin/create_plugin.py b/lib/plugin/create_plugin.py index 68e0788..5547140 100644 --- a/lib/plugin/create_plugin.py +++ b/lib/plugin/create_plugin.py @@ -25,6 +25,7 @@ class PluginBase(object): def __init__(self, setting): try: + logger1.debug(f"[DEBUG] PluginBase init for {setting.get('filepath')}") is_system = ('system' == os.path.basename(os.path.dirname(setting['filepath']))) self.status = "" self.setting = setting @@ -41,6 +42,7 @@ class PluginBase(object): self.logger = F.get_logger(self.package_name) self.blueprint = Blueprint(self.package_name, self.package_name, url_prefix=f'/{self.package_name}', template_folder=os.path.join(os.path.dirname(setting['filepath']), 'templates'), static_folder=os.path.join(os.path.dirname(setting['filepath']), 'static')) self.menu = setting['menu'] + logger1.debug(f"[DEBUG] Menu set for {self.package_name}: {self.menu}") self.setting_menu = setting.get('setting_menu', None) self.ModelSetting = None diff --git a/main.py b/main.py index 3263cab..b135ce6 100644 --- a/main.py +++ b/main.py @@ -33,11 +33,11 @@ try: package_name = "python-socketio" version = importlib.metadata.version(package_name) -# 개선 (비동기 + 로깅) -if int(version.replace(".", "")) < 580: - import subprocess - subprocess.Popen(["pip", "install", "--upgrade", package_name], - stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + # 개선 (비동기 + 로깅) + if int(version.replace(".", "")) < 580: + import subprocess + subprocess.Popen(["pip", "install", "--upgrade", package_name], + stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) except Exception: pass