Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files1 unmodified line2345678910111213141516171819202122232425262728299 unmodified lines39404142434445464748495051525354555657585960616263646566676869707172737475767778791 unmodified lineUSER root# 安装 Nginx、xvfb 和密码工具RUN apt-get update && apt-get install -y \nginx \apache2-utils \xvfb \&& rm -rf /var/lib/apt/lists/*ENV SERVER_PORT=8012ENV KKFILEVIEW_SECURITY_TRUST_HOST=defaultENV AUTH_USERNAME=adminENV AUTH_PASSWORD=123456# 配置 NginxRUN rm -f /etc/nginx/sites-enabled/default && \printf 'server {\n\listen 7860;\n\server_name _;\n\\n\# 密码保护\n\auth_basic "kkFileView Access";\n\auth_basic_user_file /etc/nginx/.htpasswd;\n\\n\location / {\n\proxy_pass http://127.0.0.1:8012;\n\proxy_set_header Host $host;\n\9 unmodified linesRUN printf '#!/bin/bash\n\set -e\n\\n\echo "=== kkFileView with Password Protection ==="\n\echo ""\n\\n\# 创建密码文件\n\echo "Creating password file..."\n\htpasswd -cb /etc/nginx/.htpasswd "$AUTH_USERNAME" "$AUTH_PASSWORD"\n\echo "✓ Username: $AUTH_USERNAME"\n\echo "✓ Password: [HIDDEN]"\n\echo ""\n\\n\# 启动 Xvfb\n\echo "Starting Xvfb..."\n\Xvfb :99 -screen 0 1024x768x24 >/dev/null 2>&1 &\n\export DISPLAY=:99\n\sleep 2\n\echo "✓ Xvfb started"\n\echo ""\n\\n\# 启动 kkFileView(后台运行在 8012)\n\echo "Starting kkFileView on port 8012..."\n\/opt/kkFileView/bin/kkFileView --server.port=8012 >/tmp/kkfileview.log 2>&1 &\n\KKFILEVIEW_PID=$!\n\echo "✓ kkFileView PID: $KKFILEVIEW_PID"\n\\n\# 等待 kkFileView 启动\n\echo "Waiting for kkFileView to be ready..."\n\sleep 10\n\\n\# 启动 Nginx)\n\echo "Starting Nginx on port 7860..."\n\echo "✓ Ready! Access with username and password"\n\echo ""\n\nginx -g "daemon off;"\n' > /start.sh && \chmod +x /start.shEXPOSE 7860CMD ["/start.sh"]1 unmodified line23456789101112131415161718192021222324252627289 unmodified lines383940414243444546474849505152535455565758596061626364656667686970717273747576771 unmodified lineUSER root# 安装 Nginx, xvfb, curlRUN apt-get update && apt-get install -y \nginx \apache2-utils \xvfb \curl \&& rm -rf /var/lib/apt/lists/*# 环境变量ENV SERVER_PORT=8012ENV KKFILEVIEW_SECURITY_TRUST_HOST=defaultENV AUTH_USERNAME=adminENV AUTH_PASSWORD=yourpassword# 配置 Nginx (监听 7860 -> 转发 8012)RUN rm -f /etc/nginx/sites-enabled/default && \printf 'server {\n\listen 7860;\n\server_name _;\n\auth_basic "Restricted Access";\n\auth_basic_user_file /etc/nginx/.htpasswd;\n\location / {\n\proxy_pass http://127.0.0.1:8012;\n\proxy_set_header Host $host;\n\9 unmodified linesRUN printf '#!/bin/bash\n\set -e\n\\n\echo "=== Starting Services ==="\n\\n\# 1. 配置密码\n\echo "Configuring password..."\n\htpasswd -cb /etc/nginx/.htpasswd "$AUTH_USERNAME" "$AUTH_PASSWORD"\n\\n\# 2. 启动 Xvfb\n\echo "Starting Xvfb..."\n\Xvfb :99 -screen 0 1024x768x24 >/dev/null 2>&1 &\n\export DISPLAY=:99\n\sleep 2\n\\n\# 3. 启动 kkFileView\n\echo "Starting kkFileView backend on 8012..."\n\# 将日志重定向到文件,避免干扰控制台,同时后台运行\n\/opt/kkFileView/bin/kkFileView --server.port=8012 > /var/log/kkfileview.log 2>&1 &\n\\n\# 4. 等待 kkFileView 启动\n\echo "Waiting for backend to be ready..."\n\for i in {1..60}; do\n\if curl -s http://127.0.0.1:8012 > /dev/null; then\n\echo "✓ Backend is ready!"\n\break\n\fi\n\echo "Waiting... ($i/60)"\n\sleep 2\n\done\n\\n\# 5. 启动 Nginx\n\echo "Starting Nginx on 7860..."\n\nginx -g "daemon off;"\n' > /start.sh && \chmod +x /start.shEXPOSE 7860ENTRYPOINT []CMD ["/start.sh"]
Dockerfile+27-29