Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files123459 unmodified lines151617181920212223241 unmodified line262728293031323334353637383940414243444546474849505152535455FROM yimik/kkfileview:latestUSER root# 安装依赖9 unmodified lines# 添加执行权限RUN chmod -R 755 /opt/kkFileView-*/bin/# 修改配置文件RUN CONFIG_FILE="/opt/kkFileView-4.1.0/config/application.properties" && \if [ -f "$CONFIG_FILE" ]; then \echo "Modifying config file..." && \sed -i '/trust.host/d' "$CONFIG_FILE" && \echo "" >> "$CONFIG_FILE" && \echo "# Trust all hosts for Hugging Face Spaces" >> "$CONFIG_FILE" && \1 unmodified lineecho "" >> "$CONFIG_FILE" && \echo "# Port configuration" >> "$CONFIG_FILE" && \echo "server.port = 7860" >> "$CONFIG_FILE" && \echo "Configuration updated successfully" && \tail -10 "$CONFIG_FILE"; \else \echo "ERROR: Config file not found at $CONFIG_FILE" && \exit 1; \fi# 启动脚本RUN echo '#!/bin/bash' > /start.sh && \echo 'echo "=== kkFileView Configuration ==="' >> /start.sh && \echo 'grep -E "trust.host|server.port" /opt/kkFileView-4.1.0/config/application.properties || echo "Config not found"' >> /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 'echo ""' >> /start.sh && \echo 'echo "Service started. Access at: http://localhost:7860"' >> /start.sh && \echo 'tail -f /opt/kkFileView-4.1.0/log/*.log' >> /start.sh && \chmod +x /start.shEXPOSE 7860CMD ["/start.sh"]12345679 unmodified lines17181920212223242526272829303132333435361 unmodified line383940414243444546474849505152535455565758596061626364656667686970717273FROM yimik/kkfileview:latestFROM keking/kkfileview:4.1.0USER root# 安装依赖9 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" && \1 unmodified lineecho "" >> "$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 && \chmod +x /start.shEXPOSE 7860CMD ["/start.sh"]
Dockerfile+32-14