File size: 3,687 Bytes
a136b43 06bdb05 a136b43 06bdb05 a136b43 06bdb05 a136b43 06bdb05 a136b43 | 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 43 44 45 46 47 48 49 50 51 52 53 54 | FROM node:18-alpine
# 安装必要的工具
RUN apk add --no-cache git shadow
# 克隆酒馆的代码
RUN git clone https://github.com/SillyTavern/SillyTavern.git /app
WORKDIR /app
# 安装依赖
RUN npm install --only=production
# ==========================================
# 🛡️ 注入防伪防盗版前端遮罩(强力DOM守护版)
# ==========================================
# 1. 创建独立的动态守护脚本,放入静态资源目录
RUN echo "(() => { \
if (localStorage.getItem('hide_anti_piracy')) return; \
const injectLayer = () => { \
if (document.getElementById('anti-piracy-layer')) return; \
const layer = document.createElement('div'); \
layer.id = 'anti-piracy-layer'; \
layer.style = 'position:fixed;top:0;left:0;width:100vw;height:100vh;background:rgba(0,0,0,0.9);z-index:9999999;display:flex;justify-content:center;align-items:center;backdrop-filter:blur(8px);color:white;font-family:sans-serif;text-align:center;'; \
layer.innerHTML = \`<div style=\"background:#222;padding:30px;border-radius:12px;box-shadow:0 8px 32px rgba(0,0,0,0.6);max-width:450px;width:90%;border:2px solid #ff4d4d;\"><h2 style=\"color:#ff4d4d;margin-top:0;\">⚠️ 免费开源防伪声明</h2><p style=\"font-size:14px;line-height:1.6;text-align:left;\">本项目由 <b>GitHub @bainiao0706</b> 倾心免费开源!<br>官方地址: <a href=\"https://github.com/bainiao0706/-sillytavern-\" target=\"_blank\" style=\"color:#4da6ff;text-decoration:none;\">github.com/bainiao0706/-sillytavern-</a><br><br><b>【严厉警告】</b><br>本项目完全免费!任何在闲鱼、淘宝、付费社群内向您收费贩卖此教程或代搭建服务的行为,均属于<b>欺诈盗用</b>!请立刻投诉并向平台申请退款!</p><div style=\"display:flex;gap:10px;justify-content:center;margin-top:20px;\"><button id=\"btn-go-git\" style=\"background:#4da6ff;color:white;border:none;padding:10px 16px;font-size:14px;border-radius:6px;cursor:pointer;font-weight:bold;\">去GitHub仓库</button><button id=\"btn-close-once\" style=\"background:#666;color:white;border:none;padding:10px 16px;font-size:14px;border-radius:6px;cursor:pointer;font-weight:bold;\">直接进入</button><button id=\"btn-never-show\" style=\"background:#ff4d4d;color:white;border:none;padding:10px 16px;font-size:14px;border-radius:6px;cursor:pointer;font-weight:bold;\">不再提示</button></div></div>\`; \
document.documentElement.appendChild(layer); \
document.getElementById('btn-go-git').onclick = () => window.open('https://github.com/bainiao0706/-sillytavern-', '_blank'); \
document.getElementById('btn-close-once').onclick = () => layer.remove(); \
document.getElementById('btn-never-show').onclick = () => { localStorage.setItem('hide_anti_piracy', 'true'); layer.remove(); observer.disconnect(); }; \
}; \
const observer = new MutationObserver(() => injectLayer()); \
observer.observe(document.documentElement, { childList: true, subtree: true }); \
if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', injectLayer); } else { injectLayer(); } \
})();" > /app/public/anti-piracy.js && \
sed -i 's|<head>|<head><script src="./anti-piracy.js"></script>|g' /app/public/index.html
ENV BACKGROUND_COLOR=black
ENV NODE_ENV=production
# 写入配置,使用时修改用户名和密码
RUN printf "port: 7860\n\
listen: true\n\
whitelistMode: false\n\
basicAuthMode: true\n\
basicAuthUser:\n\
username: \"用户名\"\n\
password: \"密码\"\n\
trustProxy: true\n" > config.yaml
# 端口号
EXPOSE 7860
# 酒馆,启动!
CMD ["node", "server.js"] |