File size: 1,067 Bytes
727262d
1912e5c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
FROM docker.io/soulter/astrbot:latest

USER root

# 安装 nginx
RUN apt-get update && apt-get install -y nginx && rm -rf /var/lib/apt/lists/*

# 配置 nginx(核心:/ws 转发到 6199,其他转发到 6185)
RUN echo 'server { \
    listen 7860; \
    client_max_body_size 50M; \
    \
    location /health { \
        return 200 "OK\n"; \
        add_header Content-Type text/plain; \
    } \
    \
    location /ws { \
        proxy_pass http://127.0.0.1:6199; \
        proxy_http_version 1.1; \
        proxy_set_header Upgrade $http_upgrade; \
        proxy_set_header Connection "upgrade"; \
        proxy_set_header Host $host; \
        proxy_read_timeout 86400; \
    } \
    \
    location / { \
        proxy_pass http://127.0.0.1:6185; \
        proxy_set_header Host $host; \
        proxy_set_header X-Real-IP $remote_addr; \
    } \
}' > /etc/nginx/sites-enabled/default

# 启动脚本
RUN echo '#!/bin/bash\n\
nginx &\n\
cd /AstrBot && python main.py\n\
' > /entrypoint.sh && chmod +x /entrypoint.sh

EXPOSE 7860

ENTRYPOINT ["/entrypoint.sh"]