Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files10 unmodified lines111213141516171819203 unmodified lines242526232728293012 unmodified lines4344454647484950515242535455566 unmodified lines63646555666768695 unmodified lines757677677879808112 unmodified lines94959686979899100901011021031042 unmodified lines1071081099911011111211311411511611711811912012112212312412512612712812913013132 unmodified lines16416516616716816917017117217317417517614717717817918015118118218315418418518610 unmodified lines libfreetype6 \ fontconfig \ fonts-wqy-zenhei \ libreoffice \ libreoffice-writer \ libreoffice-calc \ libreoffice-impress \ && rm -rf /var/lib/apt/lists/* \ && fc-cache -fv
3 unmodified linesENV AUTH_USERNAME=adminENV AUTH_PASSWORD=yourpassword
# 3. JVM配置# 3. JVM 配置# - 堆内存: 4GB# - G1GC: 低延迟垃圾回收# - 元空间: 256MB12 unmodified lines-Dserver.tomcat.accept-count=50 \-Dserver.tomcat.max-connections=200"
# 4. LibreOffice 配置ENV office.plugin.server.ports=2001,2002,2003,2004,2005ENV office.plugin.task.timeout=5mENV office.preview.type=pdfENV office.timeout=300000ENV file.dir=/opt/kkFileView/file/
# 4. Nginx 配置# 5. Nginx 配置RUN rm -rf /etc/nginx/sites-enabled/* /etc/nginx/conf.d/* && \ printf 'server {\n\ listen 7860 default_server;\n\6 unmodified lines # 文件上传限制\n\ client_max_body_size 500M;\n\ \n\ # 静态文件目录\n\ # 静态文件目录)\n\ location ~ ^/(demo|file|static)/ {\n\ auth_basic off;\n\ proxy_pass http://127.0.0.1:8012;\n\5 unmodified lines proxy_read_timeout 300s;\n\ }\n\ \n\ # 反向代理到\n\ # 反向代理到 KKFileView\n\ location / {\n\ proxy_pass http://127.0.0.1:8012;\n\ proxy_set_header Host $http_host;\n\12 unmodified lines }\n\}\n' > /etc/nginx/conf.d/kkfileview.conf
# 5. 启动脚本# 6. 启动脚本RUN printf '#!/bin/bash\n\set -e\n\\n\echo "=== Starting KKFileView (EPS Fix) for HuggingFace Spaces ==="\n\echo "=== Starting KKFileView (EPS + CAD Fix) for HuggingFace Spaces ==="\n\\n\# 查找 KKFileView 启动脚本\n\STARTUP_SCRIPT=$(find /opt -name "startup.sh" -o -name "kkFileView" | grep "bin/" | head -n 1)\n\2 unmodified lines# 生成 htpasswd 文件\n\htpasswd -cb /etc/nginx/.htpasswd "$AUTH_USERNAME" "$AUTH_PASSWORD"\n\\n\# 启动 Xvfb(虚拟显示)\n\# 创建文件存储目录\n\mkdir -p /opt/kkFileView/file\n\chmod 755 /opt/kkFileView/file\n\\n\# 启动 Xvfb\n\echo "Starting Xvfb..."\n\Xvfb :99 -screen 0 1024x768x24 >/dev/null 2>&1 &\n\export DISPLAY=:99\n\sleep 2\n\echo "✓ Xvfb started on DISPLAY=:99"\n\\n\# 启动 LibreOffice 进程池\n\echo "Starting LibreOffice process pool..."\n\for port in 2001 2002 2003 2004 2005; do\n\ soffice --headless --accept="socket,host=127.0.0.1,port=$port;urp;" --nofirststartwizard >/dev/null 2>&1 &\n\ echo " - LibreOffice process started on port $port"\n\done\n\sleep 3\n\echo "✓ LibreOffice process pool ready"\n\\n\# 启动 KKFileView\n\echo "Starting KKFileView on port 8012..."\n\32 unmodified lines sleep 2\n\done\n\\n\# 验证 LibreOffice 进程池\n\echo "Verifying LibreOffice process pool..."\n\LIBREOFFICE_COUNT=$(ps aux | grep soffice | grep -v grep | wc -l)\n\echo " - LibreOffice processes running: $LIBREOFFICE_COUNT"\n\\n\# 启动 Nginx\n\echo "Starting Nginx on port 7860..."\n\nginx -g "daemon off;"\n' > /start.sh && \ chmod +x /start.sh
# 6. 健康检查# 7. 健康检查HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \ CMD curl -f http://localhost:7860/health || exit 1
# 7. 暴露端口# 8. 暴露端口EXPOSE 7860
# 8. 启动命令# 9. 启动命令ENTRYPOINT []CMD ["/start.sh"]Dockerfile+40-10