This commit is contained in:
Stille 2022-07-16 17:15:44 +08:00
parent 7600cc68dd
commit 602b728942
7 changed files with 122 additions and 5 deletions

18
sub/Dockerfile Normal file
View File

@ -0,0 +1,18 @@
FROM node:14-alpine AS build
LABEL maintainer="Stille <stille@ioiox.com>"
ENV SUBCONVERTER_VERSION=v0.7.2
WORKDIR /
RUN apk add --no-cache bash git curl zip
RUN if [ "$(uname -m)" = "x86_64" ]; then export PLATFORM=linux64 ; else if [ "$(uname -m)" = "aarch64" ]; then export PLATFORM=aarch64 ; fi fi \
&& wget https://github.com/tindy2013/subconverter/releases/download/${SUBCONVERTER_VERSION}/subconverter_${PLATFORM}.tar.gz \
&& tar xzf subconverter_${PLATFORM}.tar.gz
RUN git clone https://github.com/stilleshan/subweb app
RUN cd /app && npm install && npm run build
FROM nginx:1.16-alpine
COPY --from=build /app/dist /usr/share/nginx/html
COPY --from=build /subconverter /base
COPY . /app
EXPOSE 80
CMD [ "sh", "-c", "/app/start.sh" ]

34
sub/README.md Normal file
View File

@ -0,0 +1,34 @@
# sub
GitHub [stilleshan/dockerfiles](https://github.com/stilleshan/dockerfiles)
Docker [stilleshan/sub](https://hub.docker.com/r/stilleshan/sub)
> *docker image support for X86 and ARM*
## 简介
基于 subweb 和 subconverter 前后端整合容器,支持自定义配置.
## 部署
**注意,本项目必须搭配域名反代使用.**
### docker
```shell
docker run -d --name subweb --restart always \
-p 18080:80 \
-v /PATH/subweb/conf:/usr/share/nginx/html/conf \
stilleshan/sub
```
修改挂载路径,根据需求自行修改`config.js`中的相关配置.
推荐使用`nginx`配置域名反向代理至`18080`端口.
`subconverter`同样支持挂载外部配置文件,参考容器内部路径:`/base/snippets/rulesets.txt`.
### docker compose
下载 [docker-compose.yml](https://raw.githubusercontent.com/stilleshan/dockerfiles/main/sub/docker-compose.yml) 执行以下命令启动:
```shell
docker-compose up -d
```
## 参考
[stilleshan/subweb](https://github.com/stilleshan/subweb)
[stilleshan/subconverter](https://github.com/stilleshan/subconverter)

16
sub/config.js Normal file
View File

@ -0,0 +1,16 @@
window.config = {
siteName: 'Subconverter Web',
apiUrl: 'http://127.0.0.1:25500',
menuItem: [
{
title: '首页',
link: '/',
target: '',
},
{
title: 'GitHub',
link: 'https://github.com/stilleshan/subweb',
target: '_blank',
},
],
};

10
sub/docker-compose.yml Normal file
View File

@ -0,0 +1,10 @@
version: "3"
services:
subconverter:
image: stilleshan/sub
container_name: sub
ports:
- 18080:80
volumes:
- ./conf:/usr/share/nginx/html/conf
restart: always

31
sub/start.sh Executable file
View File

@ -0,0 +1,31 @@
#/bin/sh
if [ ! -f /usr/share/nginx/html/conf/config.js ]; then
cp /app/config.js /usr/share/nginx/html/conf
fi
if [ $API_URL ]; then
echo "当前 API 地址为: $API_URL"
sed -i "s#http://127.0.0.1:25500#$API_URL#g" /usr/share/nginx/html/conf/config.js
else
echo "当前为默认本地 API 地址: http://127.0.0.1:25500"
echo "如需修改请在容器启动时使用 -e API_URL='https://sub.ops.ci' 传递环境变量"
fi
if [ $SITE_NAME ]; then
sed -i "s#Subconverter Web#$SITE_NAME#g" /usr/share/nginx/html/conf/config.js
fi
nohup /base/subconverter & echo "启动成功"
sed -i '$d' /etc/nginx/conf.d/default.conf
sed -i '$d' /etc/nginx/conf.d/default.conf
sed -i '$d' /etc/nginx/conf.d/default.conf
cat >> /etc/nginx/conf.d/default.conf <<EOF
location /sub {
proxy_redirect off;
proxy_pass http://127.0.0.1:25500;
}
}
EOF
nginx -g "daemon off;"

View File

@ -16,6 +16,7 @@ Docker [stilleshan/subconverter](https://hub.docker.com/r/stilleshan/subconverte
*`前后端示例,可以直接使用.`*
## 更新
- **2022-07-16** 新增 [stilleshan/sub](https://github.com/stilleshan/dockerfiles/tree/main/sub) subweb + subconverter 合并进阶版.
- **2022-07-04** 新增 [stilleshan/subweb](https://github.com/stilleshan/subweb) 前端项目.
- **2022-04-03** 更新`v0.7.2`版 docker 镜像
- **2021-12-20** 更新优化规则和分组
@ -36,7 +37,11 @@ docker run -d --name=subconverter --restart=always -p 25500:25500 stilleshan/su
docker-compose up -d
```
### subweb + subconverter 合并进阶版
详情查看 [stilleshan/sub](https://github.com/stilleshan/dockerfiles/tree/main/sub)
## 链接
- [GitHub - stilleshan/subweb](https://github.com/stilleshan/subweb)
- [GitHub - stilleshan/subconverter](https://github.com/stilleshan/subconverter)
- [GitHub - tindy2013/subconverter](https://github.com/tindy2013/subconverter)
- [stilleshan/sub](https://github.com/stilleshan/dockerfiles/tree/main/sub)
- [stilleshan/subweb](https://github.com/stilleshan/subweb)
- [stilleshan/subconverter](https://github.com/stilleshan/subconverter)
- [tindy2013/subconverter](https://github.com/tindy2013/subconverter)

View File

@ -46,7 +46,10 @@ docker run -d --name subweb --restart always \
访问 `http://127.0.0.1:18080`
> *推荐使用 nginx 反向代理部署*
### subweb + subconverter 合并进阶版
详情查看 [stilleshan/sub](https://github.com/stilleshan/dockerfiles/tree/main/sub)
## 链接
- [GitHub - stilleshan/subweb](https://github.com/stilleshan/subweb)
- [GitHub - stilleshan/subconverter](https://github.com/stilleshan/subconverter)
- [stilleshan/sub](https://github.com/stilleshan/dockerfiles/tree/main/sub)
- [stilleshan/subweb](https://github.com/stilleshan/subweb)
- [stilleshan/subconverter](https://github.com/stilleshan/subconverter)