File size: 1,964 Bytes
d2e0457
e4cf850
919170c
bbf8af3
ffca0b3
919170c
 
 
 
 
 
ffca0b3
e4cf850
919170c
2fc6c9d
ffca0b3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7f342f8
e4cf850
 
 
ffca0b3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
FROM yimik/kkfileview:latest

USER root

# 安装依赖
RUN apt-get update && apt-get install -y \
    xvfb \
    libxrender1 \
    libxext6 \
    && rm -rf /var/lib/apt/lists/*

# 环境变量
ENV SERVER_PORT=7860

# 添加执行权限
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" && \
        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 "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.sh

EXPOSE 7860

CMD ["/start.sh"]