Spaces:
Running
Running
File size: 2,402 Bytes
b063884 e4cf850 919170c bbf8af3 50ec61c 459e040 ec4776c fc0cce5 459e040 919170c 0f0189d 0c799ac 459e040 50ec61c 0c799ac 50ec61c 459e040 763ac4b 459e040 763ac4b fc0cce5 459e040 ec4776c 763ac4b 459e040 0f0189d 459e040 763ac4b 459e040 e7e4e66 50ec61c 0c799ac ae0ce11 459e040 ec4776c 459e040 50ec61c 459e040 50ec61c b39ad01 0c799ac 459e040 ae0ce11 50ec61c ec4776c 763ac4b 50ec61c 763ac4b 50ec61c 763ac4b 50ec61c ae0ce11 50ec61c ec4776c fc0cce5 ec4776c fc0cce5 0f0189d 50ec61c fc0cce5 459e040 19c209b e4cf850 fc0cce5 1930ef6 |
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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
FROM ymlisoft/kkfileview
USER root
# 安装工具
RUN apt-get update && apt-get install -y \
nginx \
apache2-utils \
xvfb \
net-tools \
curl \
&& rm -rf /var/lib/apt/lists/*
ENV SERVER_PORT=8012
ENV KKFILEVIEW_SECURITY_TRUST_HOST=default
ENV AUTH_USERNAME=admin
ENV AUTH_PASSWORD=yourpassword
# Nginx 配置
RUN rm -f /etc/nginx/sites-enabled/default && \
printf 'server {\n\
listen 7860 default_server;\n\
server_name _;\n\
\n\
auth_basic "Restricted Access";\n\
auth_basic_user_file /etc/nginx/.htpasswd;\n\
client_max_body_size 500M;\n\
\n\
location / {\n\
proxy_pass http://127.0.0.1:8012;\n\
proxy_set_header Host $host;\n\
proxy_set_header X-Real-IP $remote_addr;\n\
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n\
proxy_set_header X-Forwarded-Proto http;\n\
proxy_redirect off;\n\
proxy_buffering off;\n\
}\n\
}\n' > /etc/nginx/sites-available/kkfileview && \
ln -s /etc/nginx/sites-available/kkfileview /etc/nginx/sites-enabled/
# 启动脚本
RUN printf '#!/bin/bash\n\
set -e\n\
\n\
echo "=== Starting Secure kkFileView ==="\n\
\n\
# 1. 找启动脚本路径\n\
STARTUP_SCRIPT=$(find /opt -name "startup.sh" -o -name "kkFileView" | grep "bin/" | head -n 1)\n\
echo "Found startup script: $STARTUP_SCRIPT"\n\
\n\
# 2. 配置密码\n\
htpasswd -cb /etc/nginx/.htpasswd "$AUTH_USERNAME" "$AUTH_PASSWORD"\n\
\n\
# 3. 启动 Xvfb\n\
Xvfb :99 -screen 0 1024x768x24 >/dev/null 2>&1 &\n\
export DISPLAY=:99\n\
sleep 2\n\
\n\
# 4. 启动 kkFileView\n\
echo "Starting kkFileView on port 8012..."\n\
# 创建日志文件并开始后台 tail\n\
touch /var/log/kkfileview.log\n\
tail -f /var/log/kkfileview.log &\n\
\n\
if [[ "$STARTUP_SCRIPT" == *".sh" ]]; then\n\
bash "$STARTUP_SCRIPT" >> /var/log/kkfileview.log 2>&1 &\n\
else\n\
"$STARTUP_SCRIPT" --server.port=8012 >> /var/log/kkfileview.log 2>&1 &\n\
fi\n\
\n\
# 5. 等待端口\n\
echo "Waiting for backend..."\n\
for i in {1..60}; do\n\
if netstat -tuln | grep ":8012 " > /dev/null; then\n\
echo "✓ Port 8012 is ready!"\n\
break\n\
fi\n\
echo "Waiting... ($i/60)"\n\
sleep 2\n\
done\n\
\n\
# 6. 启动 Nginx\n\
echo "Starting Nginx on 7860..."\n\
nginx -g "daemon off;"\n' > /start.sh && \
chmod +x /start.sh
EXPOSE 7860
ENTRYPOINT []
CMD ["/start.sh"]
|