feat: Add Docker support and debug logging for plugin initialization.

This commit is contained in:
2026-01-01 22:57:40 +09:00
parent 97d203cb86
commit 3a9765f7ea
5 changed files with 95 additions and 5 deletions

21
.dockerignore Normal file
View File

@@ -0,0 +1,21 @@
# Docker 무시 파일
# 빌드 시 컨테이너에 복사하지 않을 파일들
.git
.gitignore
.idea
.vscode
.venv
__pycache__
*.pyc
*.pyo
*.pyd
.DS_Store
.python-version
# 데이터 폴더는 볼륨으로 마운트
data/
# 개발용 파일
*.md
*.log

44
Dockerfile Normal file
View File

@@ -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"]

23
docker-compose.yml Normal file
View File

@@ -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

View File

@@ -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

10
main.py
View File

@@ -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