cloudpasteview / Dockerfile
dragg2's picture
Update Dockerfile
2fc6c9d verified
raw
history blame
2.31 kB
FROM yimik/kkfileview:latest
USER root
RUN apt-get update && apt-get install -y \
xvfb \
libxrender1 \
libxext6 \
libxi6 \
libgconf-2-4 \
fonts-wqy-microhei \
fonts-wqy-zenhei \
&& rm -rf /var/lib/apt/lists/*
# 设置端口和信任主机
ENV SERVER_PORT=7860
ENV TRUST_HOST=default
# 添加执行权限
RUN chmod +x /opt/kkFileView-*/bin/*.sh
# 查找并修改配置文件
RUN find /opt/kkFileView-* -name "application.properties" -type f -exec sed -i 's/trust.host=.*/trust.host=default/g' {} \; || \
find /opt/kkFileView-* -name "application.properties" -type f -exec sh -c 'echo "trust.host=default" >> {}' \;
# 创建启动脚本
RUN printf '#!/bin/bash\n\
echo "=== Starting kkFileView on Hugging Face Spaces ==="\n\
echo "Port: $SERVER_PORT"\n\
echo "Trust Host: $TRUST_HOST"\n\
\n\
# 查找配置文件并显示\n\
CONFIG_FILE=$(find /opt/kkFileView-* -name "application.properties" -type f | head -n 1)\n\
if [ -n "$CONFIG_FILE" ]; then\n\
echo "Config file: $CONFIG_FILE"\n\
echo "Trust host setting:"\n\
grep -i "trust.host" "$CONFIG_FILE" || echo "trust.host not found in config"\n\
fi\n\
\n\
echo "Starting Xvfb..."\n\
Xvfb :99 -screen 0 1024x768x24 -ac +extension GLX +render -noreset &\n\
export DISPLAY=:99\n\
sleep 3\n\
\n\
echo "Starting kkFileView..."\n\
KKVIEW_DIR=$(find /opt -maxdepth 1 -type d -name "kkFileView-*" | head -n 1)\n\
if [ -z "$KKVIEW_DIR" ]; then\n\
echo "Error: kkFileView directory not found"\n\
exit 1\n\
fi\n\
\n\
echo "kkFileView directory: $KKVIEW_DIR"\n\
cd "$KKVIEW_DIR"\n\
\n\
# 使用绝对路径启动\n\
if [ -f "$KKVIEW_DIR/bin/startup.sh" ]; then\n\
echo "Executing: $KKVIEW_DIR/bin/startup.sh"\n\
bash "$KKVIEW_DIR/bin/startup.sh"\n\
else\n\
echo "Error: startup.sh not found at $KKVIEW_DIR/bin/startup.sh"\n\
ls -la "$KKVIEW_DIR/bin/"\n\
exit 1\n\
fi\n\
\n\
# 等待服务启动\n\
sleep 5\n\
\n\
# 查找并跟踪日志\n\
LOG_FILE=$(find "$KKVIEW_DIR" -name "kkFileView.log" -o -name "*.log" | head -n 1)\n\
if [ -n "$LOG_FILE" ]; then\n\
echo "Following log: $LOG_FILE"\n\
tail -f "$LOG_FILE"\n\
else\n\
echo "Log file not found, keeping container alive..."\n\
sleep infinity\n\
fi\n' > /start.sh && \
chmod +x /start.sh
EXPOSE 7860
CMD ["/start.sh"]