dragg2 commited on
Commit
6c2df06
·
verified ·
1 Parent(s): ffca0b3

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +32 -14
Dockerfile CHANGED
@@ -1,5 +1,7 @@
1
  FROM yimik/kkfileview:latest
2
 
 
 
3
  USER root
4
 
5
  # 安装依赖
@@ -15,10 +17,20 @@ ENV SERVER_PORT=7860
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" && \
@@ -26,30 +38,36 @@ RUN CONFIG_FILE="/opt/kkFileView-4.1.0/config/application.properties" && \
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"]
 
1
  FROM yimik/kkfileview:latest
2
 
3
+ FROM keking/kkfileview:4.1.0
4
+
5
  USER root
6
 
7
  # 安装依赖
 
17
  # 添加执行权限
18
  RUN chmod -R 755 /opt/kkFileView-*/bin/
19
 
20
+ # 先查看目录结构,找到配置文件
21
+ RUN echo "=== Searching for kkFileView installation ===" && \
22
+ ls -la /opt/ && \
23
+ echo "" && \
24
+ echo "=== Searching for config directory ===" && \
25
+ find /opt -type d -name "config" && \
26
+ echo "" && \
27
+ echo "=== Searching for application.properties ===" && \
28
+ find /opt -name "application.properties" -type f
29
+
30
+ # 自动查找并修改配置文件
31
+ RUN CONFIG_FILE=$(find /opt -name "application.properties" -type f | head -n 1) && \
32
+ if [ -n "$CONFIG_FILE" ]; then \
33
+ echo "Found config file at: $CONFIG_FILE" && \
34
  sed -i '/trust.host/d' "$CONFIG_FILE" && \
35
  echo "" >> "$CONFIG_FILE" && \
36
  echo "# Trust all hosts for Hugging Face Spaces" >> "$CONFIG_FILE" && \
 
38
  echo "" >> "$CONFIG_FILE" && \
39
  echo "# Port configuration" >> "$CONFIG_FILE" && \
40
  echo "server.port = 7860" >> "$CONFIG_FILE" && \
41
+ echo "Configuration updated successfully:" && \
42
  tail -10 "$CONFIG_FILE"; \
43
  else \
44
+ echo "WARNING: application.properties not found, will use environment variables" && \
45
+ echo "Creating config directory..." && \
46
+ mkdir -p /opt/kkFileView-4.1.0/config && \
47
+ cat > /opt/kkFileView-4.1.0/config/application.properties << 'EOFCONFIG' && \
48
+ server.port = 7860
49
+ trust.host = default
50
+ cache.enabled = true
51
+ office.preview.switch.disabled = false
52
+ EOFCONFIG
53
+ echo "Created new config file" && \
54
+ cat /opt/kkFileView-4.1.0/config/application.properties; \
55
  fi
56
 
57
  # 启动脚本
58
  RUN echo '#!/bin/bash' > /start.sh && \
59
+ echo 'echo "=== kkFileView Startup ==="' >> /start.sh && \
60
+ echo 'echo "Configuration:"' >> /start.sh && \
61
+ echo 'find /opt -name "application.properties" -exec cat {} \;' >> /start.sh && \
62
  echo 'echo ""' >> /start.sh && \
 
63
  echo 'Xvfb :99 -screen 0 1024x768x24 &' >> /start.sh && \
64
  echo 'export DISPLAY=:99' >> /start.sh && \
65
  echo 'sleep 2' >> /start.sh && \
 
66
  echo 'cd /opt/kkFileView-4.1.0' >> /start.sh && \
67
  echo 'bash /opt/kkFileView-4.1.0/bin/startup.sh' >> /start.sh && \
 
 
68
  echo 'tail -f /opt/kkFileView-4.1.0/log/*.log' >> /start.sh && \
69
  chmod +x /start.sh
70
 
71
  EXPOSE 7860
72
 
73
+ CMD ["/start.sh"]