dragg2 commited on
Commit
ffca0b3
·
verified ·
1 Parent(s): 2fc6c9d

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +38 -64
Dockerfile CHANGED
@@ -2,80 +2,54 @@ FROM yimik/kkfileview:latest
2
 
3
  USER root
4
 
 
5
  RUN apt-get update && apt-get install -y \
6
  xvfb \
7
  libxrender1 \
8
  libxext6 \
9
- libxi6 \
10
- libgconf-2-4 \
11
- fonts-wqy-microhei \
12
- fonts-wqy-zenhei \
13
  && rm -rf /var/lib/apt/lists/*
14
 
15
- # 设置端口和信任主机
16
  ENV SERVER_PORT=7860
17
- ENV TRUST_HOST=default
18
 
19
  # 添加执行权限
20
- RUN chmod +x /opt/kkFileView-*/bin/*.sh
21
-
22
- # 查找并修改配置文件
23
- RUN find /opt/kkFileView-* -name "application.properties" -type f -exec sed -i 's/trust.host=.*/trust.host=default/g' {} \; || \
24
- find /opt/kkFileView-* -name "application.properties" -type f -exec sh -c 'echo "trust.host=default" >> {}' \;
25
-
26
- # 创建启动脚本
27
- RUN printf '#!/bin/bash\n\
28
- echo "=== Starting kkFileView on Hugging Face Spaces ==="\n\
29
- echo "Port: $SERVER_PORT"\n\
30
- echo "Trust Host: $TRUST_HOST"\n\
31
- \n\
32
- # 查找配置文件并显示\n\
33
- CONFIG_FILE=$(find /opt/kkFileView-* -name "application.properties" -type f | head -n 1)\n\
34
- if [ -n "$CONFIG_FILE" ]; then\n\
35
- echo "Config file: $CONFIG_FILE"\n\
36
- echo "Trust host setting:"\n\
37
- grep -i "trust.host" "$CONFIG_FILE" || echo "trust.host not found in config"\n\
38
- fi\n\
39
- \n\
40
- echo "Starting Xvfb..."\n\
41
- Xvfb :99 -screen 0 1024x768x24 -ac +extension GLX +render -noreset &\n\
42
- export DISPLAY=:99\n\
43
- sleep 3\n\
44
- \n\
45
- echo "Starting kkFileView..."\n\
46
- KKVIEW_DIR=$(find /opt -maxdepth 1 -type d -name "kkFileView-*" | head -n 1)\n\
47
- if [ -z "$KKVIEW_DIR" ]; then\n\
48
- echo "Error: kkFileView directory not found"\n\
49
- exit 1\n\
50
- fi\n\
51
- \n\
52
- echo "kkFileView directory: $KKVIEW_DIR"\n\
53
- cd "$KKVIEW_DIR"\n\
54
- \n\
55
- # 使用绝对路径启动\n\
56
- if [ -f "$KKVIEW_DIR/bin/startup.sh" ]; then\n\
57
- echo "Executing: $KKVIEW_DIR/bin/startup.sh"\n\
58
- bash "$KKVIEW_DIR/bin/startup.sh"\n\
59
- else\n\
60
- echo "Error: startup.sh not found at $KKVIEW_DIR/bin/startup.sh"\n\
61
- ls -la "$KKVIEW_DIR/bin/"\n\
62
- exit 1\n\
63
- fi\n\
64
- \n\
65
- # 等待服务启动\n\
66
- sleep 5\n\
67
- \n\
68
- # 查找并跟踪日志\n\
69
- LOG_FILE=$(find "$KKVIEW_DIR" -name "kkFileView.log" -o -name "*.log" | head -n 1)\n\
70
- if [ -n "$LOG_FILE" ]; then\n\
71
- echo "Following log: $LOG_FILE"\n\
72
- tail -f "$LOG_FILE"\n\
73
- else\n\
74
- echo "Log file not found, keeping container alive..."\n\
75
- sleep infinity\n\
76
- fi\n' > /start.sh && \
77
  chmod +x /start.sh
78
 
79
  EXPOSE 7860
80
 
81
- CMD ["/start.sh"]
 
2
 
3
  USER root
4
 
5
+ # 安装依赖
6
  RUN apt-get update && apt-get install -y \
7
  xvfb \
8
  libxrender1 \
9
  libxext6 \
 
 
 
 
10
  && rm -rf /var/lib/apt/lists/*
11
 
12
+ # 环境变量
13
  ENV SERVER_PORT=7860
 
14
 
15
  # 添加执行权限
16
+ RUN chmod -R 755 /opt/kkFileView-*/bin/
17
+
18
+ # 修改配置文件
19
+ RUN CONFIG_FILE="/opt/kkFileView-4.1.0/config/application.properties" && \
20
+ if [ -f "$CONFIG_FILE" ]; then \
21
+ echo "Modifying config file..." && \
22
+ sed -i '/trust.host/d' "$CONFIG_FILE" && \
23
+ echo "" >> "$CONFIG_FILE" && \
24
+ echo "# Trust all hosts for Hugging Face Spaces" >> "$CONFIG_FILE" && \
25
+ echo "trust.host = default" >> "$CONFIG_FILE" && \
26
+ echo "" >> "$CONFIG_FILE" && \
27
+ echo "# Port configuration" >> "$CONFIG_FILE" && \
28
+ echo "server.port = 7860" >> "$CONFIG_FILE" && \
29
+ echo "Configuration updated successfully" && \
30
+ tail -10 "$CONFIG_FILE"; \
31
+ else \
32
+ echo "ERROR: Config file not found at $CONFIG_FILE" && \
33
+ exit 1; \
34
+ fi
35
+
36
+ # 启动脚本
37
+ RUN echo '#!/bin/bash' > /start.sh && \
38
+ echo 'echo "=== kkFileView Configuration ==="' >> /start.sh && \
39
+ echo 'grep -E "trust.host|server.port" /opt/kkFileView-4.1.0/config/application.properties || echo "Config not found"' >> /start.sh && \
40
+ echo 'echo ""' >> /start.sh && \
41
+ echo 'echo "Starting Xvfb..."' >> /start.sh && \
42
+ echo 'Xvfb :99 -screen 0 1024x768x24 &' >> /start.sh && \
43
+ echo 'export DISPLAY=:99' >> /start.sh && \
44
+ echo 'sleep 2' >> /start.sh && \
45
+ echo 'echo "Starting kkFileView..."' >> /start.sh && \
46
+ echo 'cd /opt/kkFileView-4.1.0' >> /start.sh && \
47
+ echo 'bash /opt/kkFileView-4.1.0/bin/startup.sh' >> /start.sh && \
48
+ echo 'echo ""' >> /start.sh && \
49
+ echo 'echo "Service started. Access at: http://localhost:7860"' >> /start.sh && \
50
+ echo 'tail -f /opt/kkFileView-4.1.0/log/*.log' >> /start.sh && \
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  chmod +x /start.sh
52
 
53
  EXPOSE 7860
54
 
55
+ CMD ["/start.sh"]