Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files1 unmodified line23456786 unmodified lines151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465661 unmodified line686970711 unmodified lineUSER root# 安装依赖RUN apt-get update && apt-get install -y \xvfb \libxrender1 \6 unmodified lines# 添加执行权限RUN chmod -R 755 /opt/kkFileView-*/bin/# 先查看目录结构,找到配置文件RUN echo "=== Searching for kkFileView installation ===" && \ls -la /opt/ && \echo "" && \echo "=== Searching for config directory ===" && \find /opt -type d -name "config" && \echo "" && \echo "=== Searching for application.properties ===" && \find /opt -name "application.properties" -type f# 自动查找并修改配置文件RUN CONFIG_FILE=$(find /opt -name "application.properties" -type f | head -n 1) && \if [ -n "$CONFIG_FILE" ]; then \echo "Found config file at: $CONFIG_FILE" && \sed -i '/trust.host/d' "$CONFIG_FILE" && \echo "" >> "$CONFIG_FILE" && \echo "# Trust all hosts for Hugging Face Spaces" >> "$CONFIG_FILE" && \echo "trust.host = default" >> "$CONFIG_FILE" && \echo "" >> "$CONFIG_FILE" && \echo "# Port configuration" >> "$CONFIG_FILE" && \echo "server.port = 7860" >> "$CONFIG_FILE" && \echo "Configuration updated successfully:" && \tail -10 "$CONFIG_FILE"; \else \echo "WARNING: application.properties not found, will use environment variables" && \echo "Creating config directory..." && \mkdir -p /opt/kkFileView-4.1.0/config && \cat > /opt/kkFileView-4.1.0/config/application.properties << 'EOFCONFIG' && \server.port = 7860trust.host = defaultcache.enabled = trueoffice.preview.switch.disabled = falseEOFCONFIGecho "Created new config file" && \cat /opt/kkFileView-4.1.0/config/application.properties; \fi# 启动脚本RUN echo '#!/bin/bash' > /start.sh && \echo 'echo "=== kkFileView Startup ==="' >> /start.sh && \echo 'echo "Configuration:"' >> /start.sh && \echo 'find /opt -name "application.properties" -exec cat {} \;' >> /start.sh && \echo 'echo ""' >> /start.sh && \echo 'Xvfb :99 -screen 0 1024x768x24 &' >> /start.sh && \echo 'export DISPLAY=:99' >> /start.sh && \echo 'sleep 2' >> /start.sh && \echo 'cd /opt/kkFileView-4.1.0' >> /start.sh && \echo 'bash /opt/kkFileView-4.1.0/bin/startup.sh' >> /start.sh && \echo 'tail -f /opt/kkFileView-4.1.0/log/*.log' >> /start.sh && \1 unmodified lineEXPOSE 7860CMD ["/start.sh"]1 unmodified line2345676 unmodified lines14151617181920212223242526272829303132333435363738394041424344454647484950511 unmodified line535455561 unmodified lineUSER rootRUN apt-get update && apt-get install -y \xvfb \libxrender1 \6 unmodified lines# 添加执行权限RUN chmod -R 755 /opt/kkFileView-*/bin/# 创建配置目录(如果不存在)RUN mkdir -p /opt/kkFileView-4.1.0/config# 使用 cat 创建配置文件(正确的方式)RUN cat > /opt/kkFileView-4.1.0/config/application.properties << 'EOF'# kkFileView configuration for Hugging Face Spacesserver.port=7860# Trust host configuration - CORRECT KEY NAMEpreview.trust.host=default# Cache settingscache.enabled=true# Office previewoffice.preview.switch.disabled=falseEOF# 验证配置文件RUN echo "=== Configuration file created ===" && \cat /opt/kkFileView-4.1.0/config/application.properties# 启动脚本RUN echo '#!/bin/bash' > /start.sh && \echo 'echo "=== kkFileView Configuration ==="' >> /start.sh && \echo 'cat /opt/kkFileView-4.1.0/config/application.properties' >> /start.sh && \echo 'echo ""' >> /start.sh && \echo 'echo "Starting Xvfb..."' >> /start.sh && \echo 'Xvfb :99 -screen 0 1024x768x24 &' >> /start.sh && \echo 'export DISPLAY=:99' >> /start.sh && \echo 'sleep 2' >> /start.sh && \echo 'echo "Starting kkFileView..."' >> /start.sh && \echo 'cd /opt/kkFileView-4.1.0' >> /start.sh && \echo 'bash /opt/kkFileView-4.1.0/bin/startup.sh' >> /start.sh && \echo 'tail -f /opt/kkFileView-4.1.0/log/*.log' >> /start.sh && \1 unmodified lineEXPOSE 7860CMD ["/start.sh"]
Dockerfile+25-40