Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files10 unmodified lines1112131415163 unmodified lines2021222324252612 unmodified lines394041424344456 unmodified lines525354555657585 unmodified lines6465666768697012 unmodified lines83848586878889909192932 unmodified lines9697989910010110210310410510632 unmodified lines13914014114214314414514614714814915015115215315415515610 unmodified lineslibfreetype6 \fontconfig \fonts-wqy-zenhei \&& rm -rf /var/lib/apt/lists/* \&& fc-cache -fv3 unmodified linesENV AUTH_USERNAME=adminENV AUTH_PASSWORD=yourpassword# 3. JVM配置# - 堆内存: 4GB# - G1GC: 低延迟垃圾回收# - 元空间: 256MB12 unmodified lines-Dserver.tomcat.accept-count=50 \-Dserver.tomcat.max-connections=200"# 4. 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\location ~ ^/(demo|file|static)/ {\n\auth_basic off;\n\proxy_pass http://127.0.0.1:8012;\n\5 unmodified linesproxy_read_timeout 300s;\n\}\n\\n\# 反向代理到\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. 启动脚本RUN printf '#!/bin/bash\n\set -e\n\\n\echo "=== Starting KKFileView (EPS 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\echo "Starting Xvfb..."\n\Xvfb :99 -screen 0 1024x768x24 >/dev/null 2>&1 &\n\export DISPLAY=:99\n\sleep 2\n\\n\# 启动 KKFileView\n\echo "Starting KKFileView on port 8012..."\n\32 unmodified linessleep 2\n\done\n\\n\# 启动 Nginx\n\echo "Starting Nginx on port 7860..."\n\nginx -g "daemon off;"\n' > /start.sh && \chmod +x /start.sh# 6. 健康检查HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \CMD curl -f http://localhost:7860/health || exit 1# 7. 暴露端口EXPOSE 7860# 8. 启动命令ENTRYPOINT []CMD ["/start.sh"]10 unmodified lines111213141516171819203 unmodified lines2425262728293012 unmodified lines43444546474849505152535455566 unmodified lines636465666768695 unmodified lines7576777879808112 unmodified lines9495969798991001011021031042 unmodified lines10710810911011111211311411511611711811912012112212312412512612712812913013132 unmodified lines16416516616716816917017117217317417517617717817918018118218318418518610 unmodified lineslibfreetype6 \fontconfig \fonts-wqy-zenhei \libreoffice \libreoffice-writer \libreoffice-calc \libreoffice-impress \&& rm -rf /var/lib/apt/lists/* \&& fc-cache -fv3 unmodified linesENV AUTH_USERNAME=adminENV AUTH_PASSWORD=yourpassword# 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/# 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\location ~ ^/(demo|file|static)/ {\n\auth_basic off;\n\proxy_pass http://127.0.0.1:8012;\n\5 unmodified linesproxy_read_timeout 300s;\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# 6. 启动脚本RUN printf '#!/bin/bash\n\set -e\n\\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\# 创建文件存储目录\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 linessleep 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# 7. 健康检查HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \CMD curl -f http://localhost:7860/health || exit 1# 8. 暴露端口EXPOSE 7860# 9. 启动命令ENTRYPOINT []CMD ["/start.sh"]
Dockerfile+40-10