Files
Telegram-Panel/Dockerfile.local
meoacgx 7997b25fc6 feat: 完整支持 tdata 压缩包导入并修复会话校验链路
- 导入链路新增 tdata 识别:Zip 无 .json 时自动识别 tdata 目录并进入专用导入流程

- 新增 TdataSessionBridge:调用 Node + @mtcute/convert 将 tdata 转为 Telethon session_string,再写入 WTelegram session

- 修复 tdata 二次读取失败:ImportFromSessionFileAsync 增加 sessionKey 参数,tdata 导入时传入 apiHash,避免出现 Session exists but user not logged in

- 强化登录态判定:SessionImporter 在 client.User 为空时补充 Users_GetUsers(Self) 兜底查询

- Docker 运行时改造:Dockerfile/Dockerfile.local 改为多阶段拷贝 Node 运行时并预装 @mtcute 依赖,规避 apt 源不可达导致的构建失败

- 导入页面文案更新:明确支持 tdata 包结构及全局 ApiId/ApiHash 前置要求
2026-03-02 23:07:52 +08:00

42 lines
1.6 KiB
Docker
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
COPY . .
RUN dotnet restore "TelegramPanel.sln"
RUN dotnet publish "src/TelegramPanel.Web/TelegramPanel.Web.csproj" -c Release -o /app/publish --no-restore
# tdata 运行时依赖(避免在容器内通过 apt 安装 Node
FROM node:20-bookworm-slim AS tdata-runtime
WORKDIR /opt/telegram-panel-tdata-runtime
RUN printf '{\n "name": "telegram-panel-tdata-runtime",\n "private": true,\n "type": "module"\n}\n' > package.json \
&& npm install --silent @mtcute/convert @mtcute/node
# 说明:
# - 正常生产部署建议使用 mcr.microsoft.com/dotnet/aspnet:8.0 作为运行时镜像(更小)
# - 若当前网络环境导致 Docker/WSL 无法拉取 aspnet 镜像,可临时使用本文件(运行时使用 sdk 镜像)
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS final
WORKDIR /app
ENV ASPNETCORE_URLS=http://+:5000
ENV TELEGRAM_PANEL_TDATA_RUNTIME_DIR=/app/tdata-runtime
EXPOSE 5000
# 持久化目录:/data通过 docker-compose 挂载)
# - 数据库:/data/telegram-panel.db
# - session/data/sessions/
# - 本地配置:/data/appsettings.local.jsonUI 保存 Telegram ApiId/ApiHash/同步开关等)
# - 后台密码:/data/admin_auth.json
RUN mkdir -p /data /data/sessions /data/logs \
&& rm -rf /app/logs \
&& ln -s /data/logs /app/logs \
&& ln -s /data/appsettings.local.json /app/appsettings.local.json || true
COPY --from=build /app/publish .
COPY --from=tdata-runtime /usr/local /usr/local
COPY --from=tdata-runtime /opt/telegram-panel-tdata-runtime /app/tdata-runtime
RUN node -v && npm -v
ENTRYPOINT ["dotnet", "TelegramPanel.Web.dll"]