Spaces:
Paused
Paused
Upload 3 files
Browse files- Dockerfile +30 -0
- entrypoint.sh +79 -0
- index.html +17 -0
Dockerfile
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM alpine:latest
|
| 2 |
+
|
| 3 |
+
RUN apk add --no-cache ca-certificates curl unzip nginx su-exec
|
| 4 |
+
|
| 5 |
+
RUN adduser -D -u 1001 xray && \
|
| 6 |
+
mkdir -p /www /etc/xray \
|
| 7 |
+
/var/log/nginx \
|
| 8 |
+
/var/cache/nginx \
|
| 9 |
+
/var/lib/nginx/tmp \
|
| 10 |
+
/var/lib/nginx/logs \
|
| 11 |
+
/var/run/nginx \
|
| 12 |
+
/tmp/nginx && \
|
| 13 |
+
chown -R xray:xray /www /etc/xray /var/log/nginx /var/cache/nginx \
|
| 14 |
+
/var/lib/nginx /var/run/nginx /tmp/nginx /tmp
|
| 15 |
+
|
| 16 |
+
RUN mkdir /tmp/xray && \
|
| 17 |
+
curl -L -o /tmp/xray/xray.zip https://github.com/XTLS/Xray-core/releases/latest/download/Xray-linux-64.zip && \
|
| 18 |
+
unzip /tmp/xray/xray.zip -d /tmp/xray && \
|
| 19 |
+
mv /tmp/xray/xray /usr/local/bin/ai-core && \
|
| 20 |
+
chmod +x /usr/local/bin/ai-core && \
|
| 21 |
+
rm -rf /tmp/xray
|
| 22 |
+
|
| 23 |
+
COPY index.html /www/index.html
|
| 24 |
+
COPY entrypoint.sh /entrypoint.sh
|
| 25 |
+
RUN chmod +x /entrypoint.sh
|
| 26 |
+
|
| 27 |
+
USER xray
|
| 28 |
+
EXPOSE 7860
|
| 29 |
+
HEALTHCHECK --interval=30s --timeout=5s CMD wget --no-verbose --tries=1 --spider http://127.0.0.1:7860 || exit 1
|
| 30 |
+
ENTRYPOINT ["/entrypoint.sh"]
|
entrypoint.sh
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/sh
|
| 2 |
+
set -e
|
| 3 |
+
|
| 4 |
+
if [ -z "$UUID" ]; then
|
| 5 |
+
echo "❌ UUID را در Variables تعریف کنید!"
|
| 6 |
+
exit 1
|
| 7 |
+
fi
|
| 8 |
+
|
| 9 |
+
WSPATH=${WSPATH:-/api/v1/aichatbot}
|
| 10 |
+
|
| 11 |
+
cat > /etc/xray/config.json << EOF
|
| 12 |
+
{
|
| 13 |
+
"log": {"loglevel": "warning"},
|
| 14 |
+
"inbounds": [{
|
| 15 |
+
"port": 9000,
|
| 16 |
+
"listen": "127.0.0.1",
|
| 17 |
+
"protocol": "vless",
|
| 18 |
+
"settings": {
|
| 19 |
+
"clients": [{"id": "${UUID}"}], # flow رو حذف کن
|
| 20 |
+
"decryption": "none"
|
| 21 |
+
},
|
| 22 |
+
"streamSettings": {
|
| 23 |
+
"network": "ws",
|
| 24 |
+
"wsSettings": {"path": "${WSPATH}"}
|
| 25 |
+
}
|
| 26 |
+
}],
|
| 27 |
+
"outbounds": [{"protocol": "freedom"}]
|
| 28 |
+
}
|
| 29 |
+
EOF
|
| 30 |
+
|
| 31 |
+
echo "✅ دمو AI راهاندازی شد | Path: ${WSPATH}"
|
| 32 |
+
|
| 33 |
+
cat > /tmp/nginx.conf << EOF
|
| 34 |
+
pid /tmp/nginx.pid;
|
| 35 |
+
|
| 36 |
+
events { worker_connections 1024; }
|
| 37 |
+
|
| 38 |
+
http {
|
| 39 |
+
client_body_temp_path /tmp/nginx/client_body 1 2;
|
| 40 |
+
proxy_temp_path /tmp/nginx/proxy;
|
| 41 |
+
fastcgi_temp_path /tmp/nginx/fastcgi;
|
| 42 |
+
uwsgi_temp_path /tmp/nginx/uwsgi;
|
| 43 |
+
scgi_temp_path /tmp/nginx/scgi;
|
| 44 |
+
|
| 45 |
+
server {
|
| 46 |
+
listen 7860 default_server;
|
| 47 |
+
server_name _;
|
| 48 |
+
|
| 49 |
+
access_log /var/log/nginx/access.log;
|
| 50 |
+
error_log /var/log/nginx/error.log warn;
|
| 51 |
+
|
| 52 |
+
location / {
|
| 53 |
+
root /www;
|
| 54 |
+
index index.html;
|
| 55 |
+
try_files \$uri \$uri/ =404;
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
location ${WSPATH} {
|
| 59 |
+
proxy_pass http://127.0.0.1:9000;
|
| 60 |
+
proxy_http_version 1.1;
|
| 61 |
+
proxy_set_header Upgrade \$http_upgrade;
|
| 62 |
+
proxy_set_header Connection "upgrade";
|
| 63 |
+
proxy_set_header Host \$host;
|
| 64 |
+
proxy_set_header X-Real-IP \$remote_addr;
|
| 65 |
+
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
|
| 66 |
+
proxy_set_header X-Forwarded-Proto \$scheme;
|
| 67 |
+
proxy_set_header Origin "https://chat.openai.com"; # برای obfuscation اضافی
|
| 68 |
+
proxy_read_timeout 86400;
|
| 69 |
+
}
|
| 70 |
+
}
|
| 71 |
+
}
|
| 72 |
+
EOF
|
| 73 |
+
|
| 74 |
+
echo "nginx.conf ساخته شد با WSPATH: ${WSPATH}"
|
| 75 |
+
grep "location" /tmp/nginx.conf
|
| 76 |
+
|
| 77 |
+
ai-core run -config /etc/xray/config.json &
|
| 78 |
+
|
| 79 |
+
exec nginx -c /tmp/nginx.conf -g "daemon off;"
|
index.html
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="fa" dir="rtl">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<title>AI Streaming Chat • Persian AI Demo</title>
|
| 6 |
+
<style>body{font-family: system-ui; background: #0f0f0f; color: #fff; text-align: center; padding: 50px;} h1{color:#00ff9d;} .chat{max-width:600px;margin:40px auto;}</style>
|
| 7 |
+
</head>
|
| 8 |
+
<body>
|
| 9 |
+
<h1>🚀 Persian AI Streaming Demo</h1>
|
| 10 |
+
<p>این یک دمو آزمایشی از چت استریمینگ مبتنی بر WebSocket است</p>
|
| 11 |
+
<div class="chat">
|
| 12 |
+
<p>برای تست دمو، روی دکمه زیر کلیک کنید (فقط UI است)</p>
|
| 13 |
+
<button onclick="alert('در نسخه واقعی AI جواب میده! 😊')">ارسال پیام آزمایشی</button>
|
| 14 |
+
</div>
|
| 15 |
+
<p style="font-size:12px;opacity:0.6;">Powered by Hugging Face • Real-time AI</p>
|
| 16 |
+
</body>
|
| 17 |
+
</html>
|