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

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +51 -10
Dockerfile CHANGED
@@ -12,27 +12,68 @@ RUN apt-get update && apt-get install -y \
12
  fonts-wqy-zenhei \
13
  && rm -rf /var/lib/apt/lists/*
14
 
15
- # 设置端口
16
  ENV SERVER_PORT=7860
 
17
 
18
- # 信任所有主机
19
- RUN sed -i 's/trust.host=.*/trust.host=default/g' \
20
- /opt/kkFileView-4.1.0/config/application.properties || \
21
- echo "trust.host=default" >> /opt/kkFileView-4.1.0/config/application.properties
 
 
22
 
23
  # 创建启动脚本
24
  RUN printf '#!/bin/bash\n\
25
  echo "=== Starting kkFileView on Hugging Face Spaces ==="\n\
26
- echo "Trust host configuration:"\n\
27
- grep trust.host /opt/kkFileView-4.1.0/config/application.properties || echo "Not found"\n\
 
 
 
 
 
 
 
 
 
28
  echo "Starting Xvfb..."\n\
29
  Xvfb :99 -screen 0 1024x768x24 -ac +extension GLX +render -noreset &\n\
30
  export DISPLAY=:99\n\
31
  sleep 3\n\
 
32
  echo "Starting kkFileView..."\n\
33
- cd /opt/kkFileView-4.1.0\n\
34
- bin/startup.sh\n\
35
- tail -f log/kkFileView.log\n' > /start.sh && \
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  chmod +x /start.sh
37
 
38
  EXPOSE 7860
 
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