# 使用官方轻量镜像 FROM alpine:latest # 设置工作目录 WORKDIR /app # 1. 安装基础工具 # 2. 直接从官方 GitHub 下载最新版 Xray 内核(最稳定,不会 404) # 3. 给予执行权限 RUN apk add --no-cache curl unzip && \ curl -L -o xray.zip https://github.com/XTLS/Xray-core/releases/latest/download/Xray-linux-64.zip && \ unzip xray.zip && \ chmod +x xray # 设置环境变量 (注意:等号前后绝对不能有空格) ENV PORT=7860 ENV UUID=ad8212ad-1a1a-111a-a111-111111111111 # 动态生成配置文件:VLESS + WebSocket 模式(HuggingFace 仅支持 WS 协议) RUN echo '{\ "log": {"loglevel": "none"},\ "inbounds": [{\ "port": 7860,\ "protocol": "vless",\ "settings": {\ "clients": [{"id": "'$UUID'"}],\ "decryption": "none"\ },\ "streamSettings": {\ "network": "ws",\ "wsSettings": {"path": "/"}\ }\ }],\ "outbounds": [{"protocol": "freedom"}]\ }' > config.json # 暴露端口 EXPOSE 7860 # 启动命令 CMD ["./xray", "-config", "config.json"]