nas-tools older version 2.9.1
This commit is contained in:
parent
6eb79120ee
commit
79b88d8c4a
|
@ -0,0 +1,41 @@
|
|||
FROM alpine
|
||||
RUN apk add --no-cache libffi-dev \
|
||||
&& apk add --no-cache $(echo $(wget --no-check-certificate -qO- https://raw.githubusercontent.com/jxxghp/nas-tools/master/package_list.txt)) \
|
||||
&& ln -sf /usr/share/zoneinfo/${TZ} /etc/localtime \
|
||||
&& echo "${TZ}" > /etc/timezone \
|
||||
&& ln -sf /usr/bin/python3 /usr/bin/python \
|
||||
&& curl https://rclone.org/install.sh | bash \
|
||||
&& if [ "$(uname -m)" = "x86_64" ]; then ARCH=amd64; elif [ "$(uname -m)" = "aarch64" ]; then ARCH=arm64; fi \
|
||||
&& curl https://dl.min.io/client/mc/release/linux-${ARCH}/mc --create-dirs -o /usr/bin/mc \
|
||||
&& chmod +x /usr/bin/mc \
|
||||
&& pip install --upgrade pip setuptools wheel \
|
||||
&& pip install cython \
|
||||
&& pip install -r https://raw.githubusercontent.com/jxxghp/nas-tools/master/requirements.txt \
|
||||
&& apk del libffi-dev \
|
||||
&& npm install pm2 -g \
|
||||
&& rm -rf /tmp/* /root/.cache /var/cache/apk/*
|
||||
ENV LANG="C.UTF-8" \
|
||||
TZ="Asia/Shanghai" \
|
||||
NASTOOL_CONFIG="/config/config.yaml" \
|
||||
NASTOOL_AUTO_UPDATE=true \
|
||||
NASTOOL_CN_UPDATE=true \
|
||||
NASTOOL_VERSION=master \
|
||||
PS1="\u@\h:\w \$ " \
|
||||
REPO_URL="https://github.com/jxxghp/nas-tools.git" \
|
||||
PYPI_MIRROR="https://pypi.tuna.tsinghua.edu.cn/simple" \
|
||||
ALPINE_MIRROR="mirrors.ustc.edu.cn" \
|
||||
PUID=0 \
|
||||
PGID=0 \
|
||||
UMASK=000 \
|
||||
WORKDIR="/nas-tools"
|
||||
WORKDIR ${WORKDIR}
|
||||
RUN python_ver=$(python3 -V | awk '{print $2}') \
|
||||
&& echo "${WORKDIR}/" > /usr/lib/python${python_ver%.*}/site-packages/nas-tools.pth \
|
||||
&& echo 'fs.inotify.max_user_watches=524288' >> /etc/sysctl.conf \
|
||||
&& echo 'fs.inotify.max_user_instances=524288' >> /etc/sysctl.conf \
|
||||
&& git config --global pull.ff only \
|
||||
&& git clone -b master ${REPO_URL} ${WORKDIR} --depth=1 --recurse-submodule \
|
||||
&& git config --global --add safe.directory ${WORKDIR}
|
||||
EXPOSE 3000
|
||||
VOLUME ["/config"]
|
||||
ENTRYPOINT ["/nas-tools/docker/entrypoint.sh"]
|
|
@ -0,0 +1,41 @@
|
|||
FROM alpine
|
||||
RUN apk add --no-cache libffi-dev \
|
||||
&& apk add --no-cache $(echo $(wget --no-check-certificate -qO- https://raw.githubusercontent.com/jxxghp/nas-tools/dev/package_list.txt)) \
|
||||
&& ln -sf /usr/share/zoneinfo/${TZ} /etc/localtime \
|
||||
&& echo "${TZ}" > /etc/timezone \
|
||||
&& ln -sf /usr/bin/python3 /usr/bin/python \
|
||||
&& curl https://rclone.org/install.sh | bash \
|
||||
&& if [ "$(uname -m)" = "x86_64" ]; then ARCH=amd64; elif [ "$(uname -m)" = "aarch64" ]; then ARCH=arm64; fi \
|
||||
&& curl https://dl.min.io/client/mc/release/linux-${ARCH}/mc --create-dirs -o /usr/bin/mc \
|
||||
&& chmod +x /usr/bin/mc \
|
||||
&& pip install --upgrade pip setuptools wheel \
|
||||
&& pip install cython \
|
||||
&& pip install -r https://raw.githubusercontent.com/jxxghp/nas-tools/dev/requirements.txt \
|
||||
&& apk del libffi-dev \
|
||||
&& npm install pm2 -g \
|
||||
&& rm -rf /tmp/* /root/.cache /var/cache/apk/*
|
||||
ENV LANG="C.UTF-8" \
|
||||
TZ="Asia/Shanghai" \
|
||||
NASTOOL_CONFIG="/config/config.yaml" \
|
||||
NASTOOL_AUTO_UPDATE=true \
|
||||
NASTOOL_CN_UPDATE=true \
|
||||
NASTOOL_VERSION=dev \
|
||||
PS1="\u@\h:\w \$ " \
|
||||
REPO_URL="https://github.com/jxxghp/nas-tools.git" \
|
||||
PYPI_MIRROR="https://pypi.tuna.tsinghua.edu.cn/simple" \
|
||||
ALPINE_MIRROR="mirrors.ustc.edu.cn" \
|
||||
PUID=0 \
|
||||
PGID=0 \
|
||||
UMASK=000 \
|
||||
WORKDIR="/nas-tools"
|
||||
WORKDIR ${WORKDIR}
|
||||
RUN python_ver=$(python3 -V | awk '{print $2}') \
|
||||
&& echo "${WORKDIR}/" > /usr/lib/python${python_ver%.*}/site-packages/nas-tools.pth \
|
||||
&& echo 'fs.inotify.max_user_watches=524288' >> /etc/sysctl.conf \
|
||||
&& echo 'fs.inotify.max_user_instances=524288' >> /etc/sysctl.conf \
|
||||
&& git config --global pull.ff only \
|
||||
&& git clone -b dev ${REPO_URL} ${WORKDIR} --depth=1 --recurse-submodule \
|
||||
&& git config --global --add safe.directory ${WORKDIR}
|
||||
EXPOSE 3000
|
||||
VOLUME ["/config"]
|
||||
ENTRYPOINT ["/nas-tools/docker/entrypoint.sh"]
|
|
@ -0,0 +1,48 @@
|
|||
FROM alpine
|
||||
RUN apk add --no-cache libffi-dev \
|
||||
git \
|
||||
gcc \
|
||||
musl-dev \
|
||||
python3-dev \
|
||||
py3-pip \
|
||||
libxml2-dev \
|
||||
libxslt-dev \
|
||||
tzdata \
|
||||
su-exec \
|
||||
dumb-init \
|
||||
npm \
|
||||
&& ln -sf /usr/share/zoneinfo/${TZ} /etc/localtime \
|
||||
&& echo "${TZ}" > /etc/timezone \
|
||||
&& ln -sf /usr/bin/python3 /usr/bin/python \
|
||||
&& pip install --upgrade pip setuptools wheel \
|
||||
&& pip install cython \
|
||||
&& pip install -r https://raw.githubusercontent.com/jxxghp/nas-tools/master/requirements.txt \
|
||||
&& npm install pm2 -g \
|
||||
&& apk del --purge libffi-dev gcc musl-dev libxml2-dev libxslt-dev \
|
||||
&& pip uninstall -y cython \
|
||||
&& rm -rf /tmp/* /root/.cache /var/cache/apk/*
|
||||
ENV LANG="C.UTF-8" \
|
||||
TZ="Asia/Shanghai" \
|
||||
NASTOOL_CONFIG="/config/config.yaml" \
|
||||
NASTOOL_AUTO_UPDATE=false \
|
||||
NASTOOL_CN_UPDATE=true \
|
||||
NASTOOL_VERSION=lite \
|
||||
PS1="\u@\h:\w \$ " \
|
||||
REPO_URL="https://github.com/jxxghp/nas-tools.git" \
|
||||
PYPI_MIRROR="https://pypi.tuna.tsinghua.edu.cn/simple" \
|
||||
ALPINE_MIRROR="mirrors.ustc.edu.cn" \
|
||||
PUID=0 \
|
||||
PGID=0 \
|
||||
UMASK=000 \
|
||||
WORKDIR="/nas-tools"
|
||||
WORKDIR ${WORKDIR}
|
||||
RUN python_ver=$(python3 -V | awk '{print $2}') \
|
||||
&& echo "${WORKDIR}/" > /usr/lib/python${python_ver%.*}/site-packages/nas-tools.pth \
|
||||
&& echo 'fs.inotify.max_user_watches=524288' >> /etc/sysctl.conf \
|
||||
&& echo 'fs.inotify.max_user_instances=524288' >> /etc/sysctl.conf \
|
||||
&& git config --global pull.ff only \
|
||||
&& git clone -b master ${REPO_URL} ${WORKDIR} --depth=1 --recurse-submodule \
|
||||
&& git config --global --add safe.directory ${WORKDIR}
|
||||
EXPOSE 3000
|
||||
VOLUME ["/config"]
|
||||
ENTRYPOINT ["/nas-tools/docker/entrypoint.sh"]
|
|
@ -0,0 +1,19 @@
|
|||
version: "3"
|
||||
services:
|
||||
nas-tools:
|
||||
image: jxxghp/nas-tools:latest
|
||||
ports:
|
||||
- 3000:3000 # 默认的webui控制端口
|
||||
volumes:
|
||||
- ./config:/config # 冒号左边请修改为你想保存配置的路径
|
||||
- /你的媒体目录:/你想设置的容器内能见到的目录 # 媒体目录,多个目录需要分别映射进来,需要满足配置文件说明中的要求
|
||||
environment:
|
||||
- PUID=0 # 想切换为哪个用户来运行程序,该用户的uid
|
||||
- PGID=0 # 想切换为哪个用户来运行程序,该用户的gid
|
||||
- UMASK=000 # 掩码权限,默认000,可以考虑设置为022
|
||||
- NASTOOL_AUTO_UPDATE=false # 如需在启动容器时自动升级程程序请设置为true
|
||||
#- REPO_URL=https://ghproxy.com/https://github.com/jxxghp/nas-tools.git # 当你访问github网络很差时,可以考虑解释本行注释
|
||||
restart: always
|
||||
network_mode: bridge
|
||||
hostname: nas-tools
|
||||
container_name: nas-tools
|
|
@ -0,0 +1,100 @@
|
|||
#!/bin/sh
|
||||
|
||||
cd ${WORKDIR}
|
||||
if [ "${NASTOOL_AUTO_UPDATE}" = "true" ]; then
|
||||
if [ ! -s /tmp/requirements.txt.sha256sum ]; then
|
||||
sha256sum requirements.txt > /tmp/requirements.txt.sha256sum
|
||||
fi
|
||||
if [ ! -s /tmp/third_party.txt.sha256sum ]; then
|
||||
sha256sum third_party.txt > /tmp/third_party.txt.sha256sum
|
||||
fi
|
||||
if [ "${NASTOOL_VERSION}" != "lite" ]; then
|
||||
if [ ! -s /tmp/package_list.txt.sha256sum ]; then
|
||||
sha256sum package_list.txt > /tmp/package_list.txt.sha256sum
|
||||
fi
|
||||
fi
|
||||
echo "更新程序..."
|
||||
git remote set-url origin "${REPO_URL}" &> /dev/null
|
||||
echo "windows/" > .gitignore
|
||||
if [ "${NASTOOL_VERSION}" == "dev" ]; then
|
||||
branch="dev"
|
||||
else
|
||||
branch="master"
|
||||
fi
|
||||
git clean -dffx
|
||||
git fetch --depth 1 origin ${branch}
|
||||
git reset --hard origin/${branch}
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "更新成功..."
|
||||
# Python依赖包更新
|
||||
hash_old=$(cat /tmp/requirements.txt.sha256sum)
|
||||
hash_new=$(sha256sum requirements.txt)
|
||||
if [ "${hash_old}" != "${hash_new}" ]; then
|
||||
echo "检测到requirements.txt有变化,重新安装依赖..."
|
||||
if [ "${NASTOOL_CN_UPDATE}" = "true" ]; then
|
||||
pip install --upgrade pip setuptools wheel -i "${PYPI_MIRROR}"
|
||||
pip install -r requirements.txt -i "${PYPI_MIRROR}"
|
||||
else
|
||||
pip install --upgrade pip setuptools wheel
|
||||
pip install -r requirements.txt
|
||||
fi
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "无法安装依赖,请更新镜像..."
|
||||
else
|
||||
echo "依赖安装成功..."
|
||||
sha256sum requirements.txt > /tmp/requirements.txt.sha256sum
|
||||
hash_old=$(cat /tmp/third_party.txt.sha256sum)
|
||||
hash_new=$(sha256sum third_party.txt)
|
||||
if [ "${hash_old}" != "${hash_new}" ]; then
|
||||
echo "检测到third_party.txt有变化,更新第三方组件..."
|
||||
git submodule update --init --recursive
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "无法更新第三方组件,请更新镜像..."
|
||||
else
|
||||
echo "第三方组件安装成功..."
|
||||
sha256sum third_party.txt > /tmp/third_party.txt.sha256sum
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
# 系统软件包更新
|
||||
if [ "${NASTOOL_VERSION}" != "lite" ]; then
|
||||
hash_old=$(cat /tmp/package_list.txt.sha256sum)
|
||||
hash_new=$(sha256sum package_list.txt)
|
||||
if [ "${hash_old}" != "${hash_new}" ]; then
|
||||
echo "检测到package_list.txt有变化,更新软件包..."
|
||||
if [ "${NASTOOL_CN_UPDATE}" = "true" ]; then
|
||||
sed -i "s/dl-cdn.alpinelinux.org/${ALPINE_MIRROR}/g" /etc/apk/repositories
|
||||
apk update -f
|
||||
fi
|
||||
apk add --no-cache libffi-dev
|
||||
apk add --no-cache $(echo $(cat package_list.txt))
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "无法更新软件包,请更新镜像..."
|
||||
else
|
||||
apk del libffi-dev
|
||||
echo "软件包安装成功..."
|
||||
sha256sum package_list.txt > /tmp/package_list.txt.sha256sum
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "更新失败,继续使用旧的程序来启动..."
|
||||
fi
|
||||
else
|
||||
echo "程序自动升级已关闭,如需自动升级请在创建容器时设置环境变量:NASTOOL_AUTO_UPDATE=true"
|
||||
fi
|
||||
|
||||
echo "以PUID=${PUID},PGID=${PGID}的身份启动程序..."
|
||||
|
||||
if [ "${NASTOOL_VERSION}" = "lite" ]; then
|
||||
mkdir -p /.pm2
|
||||
chown -R "${PUID}":"${PGID}" "${WORKDIR}" /config /.pm2
|
||||
else
|
||||
mkdir -p /.local
|
||||
mkdir -p /.pm2
|
||||
chown -R "${PUID}":"${PGID}" "${WORKDIR}" /config /usr/lib/chromium /.local /.pm2
|
||||
export PATH=${PATH}:/usr/lib/chromium
|
||||
fi
|
||||
umask "${UMASK}"
|
||||
exec su-exec "${PUID}":"${PGID}" "$(which dumb-init)" "$(which pm2-runtime)" start run.py -n NAStool --interpreter python3
|
|
@ -0,0 +1,93 @@
|
|||
## 特点
|
||||
|
||||
- 基于alpine实现,镜像体积小;
|
||||
|
||||
- 镜像层数少;
|
||||
|
||||
- 支持 amd64/arm64 架构;
|
||||
|
||||
- 重启即可更新程序,如果依赖有变化,会自动尝试重新安装依赖,若依赖自动安装不成功,会提示更新镜像;
|
||||
|
||||
- 可以以非root用户执行任务,降低程序权限和潜在风险;
|
||||
|
||||
- 可以设置文件掩码权限umask。
|
||||
|
||||
- lite 版本不包含浏览器内核及xvfb,不支持浏览器仿真;不支持Rclone/Minio转移方式;不支持复杂依赖变更时的自动安装升级;但是体积更小。
|
||||
|
||||
## 创建
|
||||
|
||||
**注意**
|
||||
|
||||
- 媒体目录的设置必须符合 [配置说明](https://github.com/jxxghp/nas-tools#%E9%85%8D%E7%BD%AE) 的要求。
|
||||
|
||||
- umask含义详见:http://www.01happy.com/linux-umask-analyze 。
|
||||
|
||||
- 创建后请根据 [配置说明](https://github.com/jxxghp/nas-tools#%E9%85%8D%E7%BD%AE) 及该文件本身的注释,修改`config/config.yaml`,修改好后再重启容器,最后访问`http://<ip>:<web_port>`。
|
||||
|
||||
**docker cli**
|
||||
|
||||
```
|
||||
docker run -d \
|
||||
--name nas-tools \
|
||||
--hostname nas-tools \
|
||||
-p 3000:3000 `# 默认的webui控制端口` \
|
||||
-v $(pwd)/config:/config `# 冒号左边请修改为你想在主机上保存配置文件的路径` \
|
||||
-v /你的媒体目录:/你想设置的容器内能见到的目录 `# 媒体目录,多个目录需要分别映射进来` \
|
||||
-e PUID=0 `# 想切换为哪个用户来运行程序,该用户的uid,详见下方说明` \
|
||||
-e PGID=0 `# 想切换为哪个用户来运行程序,该用户的gid,详见下方说明` \
|
||||
-e UMASK=000 `# 掩码权限,默认000,可以考虑设置为022` \
|
||||
-e NASTOOL_AUTO_UPDATE=false `# 如需在启动容器时自动升级程程序请设置为true` \
|
||||
-e NASTOOL_CN_UPDATE=false `# 如果开启了容器启动自动升级程序,并且网络不太友好时,可以设置为true,会使用国内源进行软件更新` \
|
||||
jxxghp/nas-tools
|
||||
```
|
||||
|
||||
如果你访问github的网络不太好,可以考虑在创建容器时增加设置一个环境变量`-e REPO_URL="https://ghproxy.com/https://github.com/jxxghp/nas-tools.git" \`。
|
||||
|
||||
**docker-compose**
|
||||
|
||||
新建`docker-compose.yaml`文件如下,并以命令`docker-compose up -d`启动。
|
||||
|
||||
```
|
||||
version: "3"
|
||||
services:
|
||||
nas-tools:
|
||||
image: jxxghp/nas-tools:latest
|
||||
ports:
|
||||
- 3000:3000 # 默认的webui控制端口
|
||||
volumes:
|
||||
- ./config:/config # 冒号左边请修改为你想保存配置的路径
|
||||
- /你的媒体目录:/你想设置的容器内能见到的目录 # 媒体目录,多个目录需要分别映射进来,需要满足配置文件说明中的要求
|
||||
environment:
|
||||
- PUID=0 # 想切换为哪个用户来运行程序,该用户的uid
|
||||
- PGID=0 # 想切换为哪个用户来运行程序,该用户的gid
|
||||
- UMASK=000 # 掩码权限,默认000,可以考虑设置为022
|
||||
- NASTOOL_AUTO_UPDATE=false # 如需在启动容器时自动升级程程序请设置为true
|
||||
- NASTOOL_CN_UPDATE=false # 如果开启了容器启动自动升级程序,并且网络不太友好时,可以设置为true,会使用国内源进行软件更新
|
||||
#- REPO_URL=https://ghproxy.com/https://github.com/jxxghp/nas-tools.git # 当你访问github网络很差时,可以考虑解释本行注释
|
||||
restart: always
|
||||
network_mode: bridge
|
||||
hostname: nas-tools
|
||||
container_name: nas-tools
|
||||
```
|
||||
|
||||
## 后续如何更新
|
||||
|
||||
- 正常情况下,如果设置了`NASTOOL_AUTO_UPDATE=true`,重启容器即可自动更新nas-tools程序。
|
||||
|
||||
- 设置了`NASTOOL_AUTO_UPDATE=true`时,如果启动时的日志提醒你 "更新失败,继续使用旧的程序来启动...",请再重启一次,如果一直都报此错误,请改善你的网络。
|
||||
|
||||
- 设置了`NASTOOL_AUTO_UPDATE=true`时,如果启动时的日志提醒你 "无法安装依赖,请更新镜像...",则需要删除旧容器,删除旧镜像,重新pull镜像,再重新创建容器。
|
||||
|
||||
## 关于PUID/PGID的说明
|
||||
|
||||
- 如在使用诸如emby、jellyfin、plex、qbittorrent、transmission、deluge、jackett、sonarr、radarr等等的docker镜像,请保证创建本容器时的PUID/PGID和它们一样。
|
||||
|
||||
- 在docker宿主上,登陆媒体文件所有者的这个用户,然后分别输入`id -u`和`id -g`可获取到uid和gid,分别设置为PUID和PGID即可。
|
||||
|
||||
- `PUID=0` `PGID=0`指root用户,它拥有最高权限,若你的媒体文件的所有者不是root,不建议设置为`PUID=0` `PGID=0`。
|
||||
|
||||
## 如果要硬连接如何映射
|
||||
|
||||
参考下图,由imogel@telegram制作。
|
||||
|
||||
![如何映射](volume.png)
|
Binary file not shown.
After Width: | Height: | Size: 40 KiB |
Loading…
Reference in New Issue