mirror of
https://github.com/letian1650/N3RD.git
synced 2025-01-25 04:05:17 +08:00
183 lines
8.0 KiB
Markdown
183 lines
8.0 KiB
Markdown
|
#### 基于 [ZeroTermux](http://file.nokia.press/ZeroTermux-0.118.36.2.apk) 搭建
|
|||
|
###### qq官群1:714730084
|
|||
|
###### qq官群3:878847174
|
|||
|
##### [加群链接生成器](https://qun.qq.com/join.html)
|
|||
|
##### [git图标生成器](https://github.com/badges/shields)
|
|||
|
#### 教程开始
|
|||
|
###### 特殊-termux直装(由于termux的Python最低版本是3.10,会导致此项目无法获取首页推荐,但是其他性能方面非常牛叉)
|
|||
|
```shell
|
|||
|
apt install libxml2 libxslt -y
|
|||
|
apt install python3
|
|||
|
```
|
|||
|
###### 注意:termux初始自带python版本>=3.11的务必注释requirements.txt里的gevent再进行pip3 install -r requirements.txt
|
|||
|
|
|||
|
##### 特殊-docker直装(支持amd64/armv7/arm64)
|
|||
|
##### 不知道自己架构的通过arch命令查看
|
|||
|
###### 可以通过点此下载获得最小必要文件压缩包
|
|||
|
[蓝奏云下载](https://wwi.lanzoup.com/igPCG0dlqouf)
|
|||
|
|
|||
|
##### 三架构自动识别(测试功能)
|
|||
|
```shell
|
|||
|
docker run -it -p 5705:5705 -p 9001:9001 --restart=always --name drpy -d hjdhnx/drpy
|
|||
|
```
|
|||
|
|
|||
|
##### amd64/x86架构(主流设备)
|
|||
|
```shell
|
|||
|
docker run -it -p 5705:5705 -p 9001:9001 --restart=always --name drpy -d hjdhnx/drpy:amd64-v3.9.0
|
|||
|
```
|
|||
|
##### armv7架构(树莓派,机顶盒,软路由等)
|
|||
|
```shell
|
|||
|
docker run -it -p 5705:5705 -p 9001:9001 --restart=always --name drpy -d hjdhnx/drpy:armv7-v3.9.0
|
|||
|
```
|
|||
|
##### arm64架构(部分服务器)
|
|||
|
```shell
|
|||
|
docker run -it -p 5705:5705 -p 9001:9001 --restart=always --name drpy -d hjdhnx/drpy:arm64-v3.9.0
|
|||
|
```
|
|||
|
#### 补充说明(2022/10/19)
|
|||
|
据说群晖搭建docker加上参数--net=host 可以局域网ip访问docker容器服务
|
|||
|
由于3.9版本以上镜像引入了quickjs库,这个库官方编译版在armv7上无法正常运行
|
|||
|
armv7架构的朋友需要在项目根目录执行以下两条命令然后重启9001服务
|
|||
|
```shell
|
|||
|
pip3 uninstall quickjs
|
|||
|
pip3 install ./whl/quickjs-1.19.2-cp37-cp37m-linux_armv7l.whl
|
|||
|
```
|
|||
|
|
|||
|
##### 上面代码如果成功了下面都可以忽略
|
|||
|
#### 端口映射参数,三种架构通用
|
|||
|
```shell
|
|||
|
-v /home/pywork/dr_py:/root/sd/pywork/dr_py
|
|||
|
```
|
|||
|
```shell
|
|||
|
# 运行容器-小白只需要这一条命令(存在问题是不能在远程面板上正确获取配置地址和进程管理地址,但自己知道地址就不影响使用,可进入容器自行修改config)
|
|||
|
docker run -it -p 5705:5705 -p 9001:9001 --restart=always --name drpy -d hjdhnx/drpy:amd64-v3.9.0
|
|||
|
# 稍微懂一点可以运行下面的操作
|
|||
|
先把本项目拷贝到 /home/pywork/dr_py
|
|||
|
docker run -it -p 5705:5705 -p 9001:9001 -v /home/pywork/dr_py:/root/sd/pywork/dr_py --restart=always --name drpy -d hjdhnx/drpy:amd64-v3.9.0
|
|||
|
# 进入容器然后修改config.py文件改配置里面自己的远程地址等信息,改完退出容器再重启容器(或者通过进程管理9001端口在线重启flask服务)
|
|||
|
docker exec -it drpy bash
|
|||
|
vi ./base/config.py
|
|||
|
|
|||
|
如果不提供外部地址,请把这个设置为True,否则视频播放不正常
|
|||
|
PLAY_DISABLE = True # 全局禁用播放解析
|
|||
|
如果提供了外部播放地址必改这三个:
|
|||
|
PLAY_DISABLE = False # 全局禁用播放解析
|
|||
|
LAZYPARSE_MODE = 2 # 播放解析模式(0 本地 1 局域网 2远程 仅在全局禁用为False的时候生效)
|
|||
|
PLAY_URL = 'http://你的主页服务地址' # 匹配远程解析服务器链接 远程接口主页地址,后面不能有/
|
|||
|
:wq
|
|||
|
# docker run -it -p 5705:5705 -p 9001:9001 --name drpy drpy /bin/bash
|
|||
|
```
|
|||
|
#### termux容器ubutnu1804内安装(此方法请无视上方代码)
|
|||
|
1. 准备工作-termux通过tome搭建完整的ubuntu1804系统(基于proot容器技术)
|
|||
|
ZeroTermux左侧边栏按住手指右滑出现操作面板
|
|||
|
点击面板的切换源-北京源并确定,之后出现的任何提示都回车或者y确定
|
|||
|
再次进入面板,手指上拉滑到侧边栏下方的MOE全能并点击,之后各种一路回车或者确定
|
|||
|
然后跟着提示一步步安装proot-ubutun1804系统并不需要gui界面
|
|||
|
完毕后输入debian进入系统后才进行如下操作进行搭建项目(exit命令可以退出Ubuntu1804并回到termux)
|
|||
|
2. ubuntu1804换源及python换源和依赖安装
|
|||
|
手机浏览器访问: [https://mirrors.bfsu.edu.cn/help/ubuntu-ports/](https://mirrors.bfsu.edu.cn/help/ubuntu-ports/)
|
|||
|
选择ubuntu版本为1804,并复制其中的源地址,或者用下面的源代码也行
|
|||
|
```shell
|
|||
|
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
|
|||
|
deb https://mirrors.bfsu.edu.cn/ubuntu-ports/ bionic main restricted universe multiverse
|
|||
|
# deb-src https://mirrors.bfsu.edu.cn/ubuntu-ports/ bionic main restricted universe multiverse
|
|||
|
deb https://mirrors.bfsu.edu.cn/ubuntu-ports/ bionic-updates main restricted universe multiverse
|
|||
|
# deb-src https://mirrors.bfsu.edu.cn/ubuntu-ports/ bionic-updates main restricted universe multiverse
|
|||
|
deb https://mirrors.bfsu.edu.cn/ubuntu-ports/ bionic-backports main restricted universe multiverse
|
|||
|
# deb-src https://mirrors.bfsu.edu.cn/ubuntu-ports/ bionic-backports main restricted universe multiverse
|
|||
|
deb https://mirrors.bfsu.edu.cn/ubuntu-ports/ bionic-security main restricted universe multiverse
|
|||
|
# deb-src https://mirrors.bfsu.edu.cn/ubuntu-ports/ bionic-security main restricted universe multiverse
|
|||
|
|
|||
|
# 预发布软件源,不建议启用
|
|||
|
# deb https://mirrors.bfsu.edu.cn/ubuntu-ports/ bionic-proposed main restricted universe multiverse
|
|||
|
# deb-src https://mirrors.bfsu.edu.cn/ubuntu-ports/ bionic-proposed main restricted universe multiverse
|
|||
|
```
|
|||
|
然后换源可能需要用到下面的命令:
|
|||
|
```shell
|
|||
|
vi /etc/apt/sources.list # 编辑源列表
|
|||
|
dd # 在非输入模式下,vim中输入dd可以删除整行
|
|||
|
i # 进入vim的编辑插入模式,记得复制粘贴源进入
|
|||
|
:wq # 保存
|
|||
|
apt update # 更新软件包列表
|
|||
|
apt upgrade # 升级本地软件包
|
|||
|
```
|
|||
|
换源完毕后进行安装项目需要的相关环境
|
|||
|
```shell
|
|||
|
apt install net-tools # ifconfig查Ip命令需要
|
|||
|
apt install python3-pip # python3依赖管理器,装依赖需要
|
|||
|
pip3 install -i https://mirrors.cloud.tencent.com/pypi/simple --upgrade pip # 用腾讯源临时升级pip
|
|||
|
pip config set global.index-url https://mirrors.cloud.tencent.com/pypi/simple # python换腾讯源
|
|||
|
|
|||
|
```
|
|||
|
然后把dr_py项目搞到内存卡以下目录:
|
|||
|
/storage/emulated/0/Download/pywork/dr_py
|
|||
|
cd 到该目录进行安装依赖:
|
|||
|
```shell
|
|||
|
cd /sd/pywork/dr_py
|
|||
|
pip3 install -r requirements.txt
|
|||
|
```
|
|||
|
3. 运行dr_py项目
|
|||
|
两种方法,一条命令对应一种
|
|||
|
```shell
|
|||
|
python3 app.py # 需要shell上运行调试,并且也可以 nohup python3 app.py &
|
|||
|
. ./app.sh 0
|
|||
|
#. <(cat app.sh) # 用于生产环境正式运行,更加强大的进程启动和在线日志
|
|||
|
```
|
|||
|
4. termux配置启动命令
|
|||
|
如果在debian里面记得先 exit回到termux里
|
|||
|
```shell
|
|||
|
apt install openssh vim -y
|
|||
|
vi ~/.bashrc
|
|||
|
|
|||
|
echo "用户:"$(whoami)
|
|||
|
|
|||
|
if pgrep -x "sshd" >/dev/null
|
|||
|
then
|
|||
|
echo "sshd运行中..."
|
|||
|
else
|
|||
|
sshd
|
|||
|
echo "自动启动sshd"
|
|||
|
fi
|
|||
|
:wq
|
|||
|
echo "debian" >> ~/.bashrc
|
|||
|
```
|
|||
|
这套命令配置完了下次打开termux会自动进入debian虚拟机(ubuntu1804)
|
|||
|
|
|||
|
5. 启动成功访问查看
|
|||
|
[本地地址](http://localhost:5705)
|
|||
|
[进程管理地址](http://localhost:9001)
|
|||
|
```shell
|
|||
|
开发者构建指南:
|
|||
|
#apt-get install language-pack-zh-hans
|
|||
|
cat /etc/issue
|
|||
|
locale -a
|
|||
|
|
|||
|
# 构建容器-给开发者用的,小白不需要
|
|||
|
# docker build -f dockerfile -t hjdhnx/drpy .
|
|||
|
# docker build -f dockerfile -t hjdhnx/drpy:mini .
|
|||
|
# docker buildx build --platform arm64 -f dockerfile -t hjdhnx/drpy:mini_arm64 --push .
|
|||
|
# docker push hjdhnx/drpy
|
|||
|
# 教程 https://www.cnblogs.com/wuyoucao/p/16461988.html
|
|||
|
# https://blog.csdn.net/u014110320/article/details/124406628
|
|||
|
mkdir -p ~/.docker/cli-plugins
|
|||
|
mv buildx-v0.8.2.linux-xxx ~/.docker/cli-plugins/docker-buildx
|
|||
|
chmod +x ~/.docker/cli-plugins/docker-buildx
|
|||
|
systemctl daemon-reload
|
|||
|
systemctl restart docker
|
|||
|
docker buildx version
|
|||
|
docker buildx ls
|
|||
|
vi /etc/docker/daemon.json
|
|||
|
"experimental": true
|
|||
|
# 教程 https://blog.csdn.net/u012586326/article/details/125589644
|
|||
|
# DOCKER_BUILDKIT=1
|
|||
|
# 创建builder
|
|||
|
# docker buildx create --use --name mybuilder
|
|||
|
# docker buildx use mybuilder
|
|||
|
|
|||
|
# build镜像
|
|||
|
# docker buildx build --platform linux/amd64,linux/arm64 --push -f dockerfile -t hjdhnx/drpy:mini_arm64 .
|
|||
|
# docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -f dockerfile -t hjdhnx/drpy:mini_arm64 .
|
|||
|
|
|||
|
# arch 看架构
|
|||
|
```
|
|||
|
|