diff --git a/sub/Dockerfile b/sub/Dockerfile new file mode 100644 index 0000000..ad66630 --- /dev/null +++ b/sub/Dockerfile @@ -0,0 +1,18 @@ +FROM node:14-alpine AS build +LABEL maintainer="Stille " + +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" ] diff --git a/sub/README.md b/sub/README.md new file mode 100644 index 0000000..54d6afe --- /dev/null +++ b/sub/README.md @@ -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) diff --git a/sub/config.js b/sub/config.js new file mode 100644 index 0000000..5460480 --- /dev/null +++ b/sub/config.js @@ -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', + }, + ], +}; diff --git a/sub/docker-compose.yml b/sub/docker-compose.yml new file mode 100644 index 0000000..b30d63a --- /dev/null +++ b/sub/docker-compose.yml @@ -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 diff --git a/sub/start.sh b/sub/start.sh new file mode 100755 index 0000000..24a75e2 --- /dev/null +++ b/sub/start.sh @@ -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 < *推荐使用 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)