Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files51 unmodified lines52535455555657585960616162636411 unmodified lines767778797980818245 unmodified lines12812913013113113213313413413513613713813914014114214314414514618 unmodified lines16516616716816917017117217317417517617717817918018118218318418518618718818919018219119219319418419519618619719819920020118920220320419220520620720820919721021121221321421521621721821922022122222322422522651 unmodified lines chmod -R 755 /var/log/kkfileview /opt/kkFileView
# 4. Nginx 配置RUN rm -rf /etc/nginx/sites-enabled/* /etc/nginx/conf.d/* && \RUN rm -rf /etc/nginx/sites-enabled/* /etc/nginx/conf.d/* /etc/nginx/nginx.conf && \ printf 'worker_processes 2;\n\worker_cpu_affinity 01 10;\n\worker_priority -5;\n\worker_rlimit_nofile 65535;\n\\n\error_log /var/log/nginx/error.log warn;\n\error_log /dev/stderr warn;\n\pid /var/run/nginx.pid;\n\\n\events {\n\11 unmodified lines '"'"'$status $body_bytes_sent "$http_referer" '"'"'\n\ '"'"'"$http_user_agent" rt=$request_time uct="$upstream_connect_time"'"'"';\n\ \n\ access_log /var/log/nginx/access.log main;\n\ access_log /dev/stdout main;\n\ \n\ sendfile on;\n\ tcp_nopush on;\n\45 unmodified lines proxy_pass http://kkfileview;\n\ proxy_http_version 1.1;\n\ proxy_set_header Connection "";\n\ proxy_set_header Host $http_host;\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 $scheme;\n\ proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;\n\ proxy_set_header X-Forwarded-Host $host;\n\ proxy_set_header X-Forwarded-Port $server_port;\n\ \n\ proxy_buffering on;\n\ proxy_buffer_size 16k;\n\ proxy_buffers 8 16k;\n\ proxy_read_timeout 300s;\n\ \n\ proxy_redirect off;\n\ }\n\ \n\ location /health {\n\18 unmodified linesset -e\n\\n\echo "=== Starting KKFileView Optimized for HuggingFace Spaces ==="\n\echo "Date: $(date)"\n\echo "Environment: HuggingFace Spaces (2 vCPU + 16GB RAM)"\n\\n\: "${AUTH_USERNAME:?AUTH_USERNAME is required}"\n\: "${AUTH_PASSWORD:?AUTH_PASSWORD is required}"\n\\n\echo "Creating htpasswd file for user: $AUTH_USERNAME"\n\htpasswd -cb /etc/nginx/.htpasswd "$AUTH_USERNAME" "$AUTH_PASSWORD"\n\\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 on DISPLAY=:99"\n\\n\STARTUP_SCRIPT=$(find /opt -name "startup.sh" -o -name "kkFileView" | grep "bin/" | head -n 1)\n\if [ -z "$STARTUP_SCRIPT" ]; then\n\ echo "ERROR: KKFileView startup script not found!"\n\ exit 1\n\fi\n\echo "Found KKFileView startup script: $STARTUP_SCRIPT"\n\\n\echo "Starting KKFileView on port 8012..."\n\echo "JVM Configuration: $JAVA_OPTS"\n\echo "JVM Configuration:"\n\echo "$JAVA_OPTS" | tr " " "\\n" | grep -E "^-" | head -20\n\\n\if [[ "$STARTUP_SCRIPT" == *".sh" ]]; then\n\ bash "$STARTUP_SCRIPT" 2>&1 | tee /var/log/kkfileview/app.log &\n\ bash "$STARTUP_SCRIPT" 2>&1 &\n\else\n\ "$STARTUP_SCRIPT" --server.port=8012 2>&1 | tee /var/log/kkfileview/app.log &\n\ "$STARTUP_SCRIPT" --server.port=8012 2>&1 &\n\fi\n\KKFILEVIEW_PID=$!\n\echo "KKFileView started with PID: $KKFILEVIEW_PID"\n\\n\echo "Waiting for KKFileView to start..."\n\echo "Waiting for KKFileView to start (max 60 seconds)..."\n\for i in {1..30}; do\n\ if curl -s http://127.0.0.1:8012 >/dev/null 2>&1; then\n\ echo "✓ KKFileView is ready!"\n\ echo "✓ KKFileView is ready on port 8012!"\n\ break\n\ fi\n\ if [ $i -eq 30 ]; then\n\ echo "ERROR: KKFileView failed to start within 60 seconds"\n\ cat /var/log/kkfileview/app.log\n\ echo "Checking if process is still running..."\n\ if ps -p $KKFILEVIEW_PID > /dev/null; then\n\ echo "Process is running but not responding"\n\ else\n\ echo "Process has died"\n\ fi\n\ exit 1\n\ fi\n\ echo "Waiting... ($i/30)"\n\ sleep 2\n\done\n\\n\echo "Starting Nginx on port 7860..."\n\echo "Nginx will log to stdout/stderr"\n\nginx -g "daemon off;"\n' > /start.sh && \ chmod +x /start.sh
Dockerfile+31-11