瀏覽代碼

ttrss:24.12-7b727156 add opencc-api

John 10 月之前
父節點
當前提交
3ef4f59050

+ 1 - 1
.github/workflows/tt-rss.yml

@@ -63,5 +63,5 @@ jobs:
           username: ${{ secrets.DOCKER_USERNAME }}
           password: ${{ secrets.DOCKER_PASSWORD }}
           repository: johngong/tt-rss
-          short-description: Tiny Tiny RSS:plugins-${{ env.TTRSS_VER }},集成postgres数据库,mercury-parser-api及一些常用插件
+          short-description: Tiny Tiny RSS:plugins-${{ env.TTRSS_VER }},集成postgres数据库,mercury-parser-api,opencc-api,及一些常用插件
           readme-filepath: ./tt-rss-plugins/README.md

+ 27 - 9
tt-rss-plugins/Dockerfile

@@ -1,13 +1,22 @@
 FROM node:18.20.4-alpine3.20 as mercury-parser-api-build
+
+RUN apk add --no-cache git python3 build-base \
 # install mercury-parser-api
-RUN apk add --no-cache git \
-&& npm install --prefix /usr/local/mercury-parser-api git+https://github.com/HenryQW/mercury-parser-api.git
+&& npm install --prefix /usr/local/mercury-parser-api git+https://github.com/HenryQW/mercury-parser-api.git \
+&& sed -i 's/env.PORT/env.MERCURY_PORT/' /usr/local/mercury-parser-api/node_modules/mercury-parser-api/config.js \
+# install OpenCC.henry.wang
+&& npm install --prefix /usr/local/OpenCC.henry.wang git+https://github.com/BYVoid/OpenCC.git \
+&& npm install --prefix /usr/local/OpenCC.henry.wang express \
+&& npm install --prefix /usr/local/OpenCC.henry.wang git+https://github.com/HenryQW/OpenCC.henry.wang.git \
+&& sed -i 's/env.PORT/env.OPENCC_PORT/' /usr/local/OpenCC.henry.wang/node_modules/opencc.henry.wang/bin/www \
+&& sed -i 's/3000/4000/' /usr/local/OpenCC.henry.wang/node_modules/opencc.henry.wang/bin/www
+
 
 FROM ghcr.io/gshang2017/postgres:latest
 
 ARG S6_VER=3.2.0.2
-ARG TTRSS_VER=24.11-4dfa7a66
-ARG GIT_COMMIT_SHA=4dfa7a666acd8c33ddce769b82dd121849208f1d
+ARG TTRSS_VER=24.12-7b727156
+ARG GIT_COMMIT_SHA=7b727156780236cb639c52e45d07cc80c1f2b0d3
 
 ENV UID=1000
 ENV GID=1000
@@ -28,18 +37,26 @@ ENV TZ=Asia/Shanghai
 ENV TTRSS_ALLOW_PORTS=80,443
 ENV TTRSS_UPDATE_AUTO=true
 ENV TTRSS_CADDY_PORT=80
+ENV ENABLE_MERCURY=true
+ENV MERCURY_PORT=3000
+ENV ENABLE_OPENCC=false
+ENV OPENCC_PORT=4000
+ENV PGPORT=5432
+ENV PHP_LISTEN_PORT=9000
 ENV POSTGRES_DB_DUMP=false
 ENV POSTGRES_DB_RESTORE=false
 ENV S6_CMD_WAIT_FOR_SERVICES_MAXTIME=0
 
 COPY --chmod=755 root /
 COPY --from=mercury-parser-api-build --chmod=755 /usr/local/mercury-parser-api /usr/local/mercury-parser-api
+COPY --from=mercury-parser-api-build --chmod=755 /usr/local/OpenCC.henry.wang /usr/local/OpenCC.henry.wang
+COPY --from=mercury-parser-api-build --chmod=755 /usr/local/bin/node /usr/local/bin/node
 
 # install php tt-rss caddy git [npm nodejs]-mercury-parser-api
-RUN apk add --no-cache bash shadow tzdata git npm nodejs ca-certificates caddy dumb-init postgresql-client musl-locales \
+RUN apk add --no-cache bash shadow tzdata git ca-certificates caddy dumb-init postgresql-client musl-locales \
 						php83 php83-fpm php83-phar php83-sockets php83-pecl-apcu php83-pdo php83-gd php83-pgsql php83-pdo_pgsql php83-xmlwriter php83-opcache \
 						php83-mbstring php83-intl php83-xml php83-curl php83-simplexml php83-session php83-tokenizer php83-dom php83-fileinfo php83-ctype \
-						php83-json php83-iconv php83-pcntl php83-posix php83-zip php83-exif php83-openssl php83-pecl-xdebug \
+						php83-json php83-iconv php83-pcntl php83-posix php83-zip php83-exif php83-openssl php83-pecl-xdebug python3 \
 && apk add --no-cache --virtual ttrssdep clang15 llvm15 build-base \
 # install s6-overlay
 && if [ "$(uname -m)" = "x86_64" ];then s6_arch=x86_64;elif [ "$(uname -m)" = "aarch64" ];then s6_arch=aarch64;elif [ "$(uname -m)" = "armv7l" ];then s6_arch=arm; fi \
@@ -51,8 +68,6 @@ RUN apk add --no-cache bash shadow tzdata git npm nodejs ca-certificates caddy d
 && tar -C / -Jxpf /tmp/s6-overlay-symlinks-noarch.tar.xz \
 && wget -P /tmp https://github.com/just-containers/s6-overlay/releases/download/v${S6_VER}/s6-overlay-symlinks-arch.tar.xz \
 && tar -C / -Jxpf /tmp/s6-overlay-symlinks-arch.tar.xz \
-# install mercury-parser-api
-# && npm install --prefix /usr/local/mercury-parser-api git+https://github.com/HenryQW/mercury-parser-api.git \
 # install zhparser
 && wget http://www.xunsearch.com/scws/down/scws-1.2.3.tar.bz2 \
 && tar -xf scws-1.2.3.tar.bz2 \
@@ -91,6 +106,8 @@ RUN apk add --no-cache bash shadow tzdata git npm nodejs ca-certificates caddy d
 && git clone --depth 1 https://github.com/DigitalDJ/tinytinyrss-fever-plugin /usr/local/tt-rss/defaults/plugins.local/fever \
 # install af-readability
 && git clone --depth 1 https://git.tt-rss.org/fox/ttrss-af-readability.git /usr/local/tt-rss/defaults/plugins.local/af_readability \
+# install opencc
+&& git clone --depth 1 https://github.com/HenryQW/ttrss_opencc.git /usr/local/tt-rss/defaults/plugins.local/opencc \
 # install themes
 # install tt-rss-feedly-theme
 && git clone -b dist --depth 1 https://github.com/levito/tt-rss-feedly-theme.git /usr/local/tt-rss/defaults/themes.local/tt-rss-feedly-theme \
@@ -99,11 +116,12 @@ RUN apk add --no-cache bash shadow tzdata git npm nodejs ca-certificates caddy d
 && git config --global --add safe.directory /config/plugins.local/mercury_fulltext \
 && git config --global --add safe.directory /config/plugins.local/feediron \
 && git config --global --add safe.directory /config/plugins.local/fever \
+&& git config --global --add safe.directory /config/plugins.local/opencc \
 && git config --global --add safe.directory /usr/local/tt-rss/defaults/themes.local/tt-rss-feedly-theme \
 #clear
 && apk del ttrssdep \
 && rm -rf /var/cache/apk/* /tmp/* /scws*
 
 VOLUME /config
-EXPOSE 80 3000 5432
+EXPOSE 80 3000 4000 5432
 ENTRYPOINT [ "/init" ]

+ 25 - 3
tt-rss-plugins/README.md

@@ -9,6 +9,8 @@
 [https://git.tt-rss.org/fox/tt-rss.git](https://git.tt-rss.org/fox/tt-rss.git "https://git.tt-rss.org/fox/tt-rss.git")  
 [https://github.com/docker-library/postgres](https://github.com/docker-library/postgres "https://github.com/docker-library/postgres")   
 [https://github.com/HenryQW/mercury-parser-api](https://github.com/HenryQW/mercury-parser-api "https://github.com/HenryQW/mercury-parser-api")  
+[https://github.com/HenryQW/OpenCC.henry.wang](https://github.com/HenryQW/OpenCC.henry.wang "https://github.com/HenryQW/OpenCC.henry.wang")  
+[https://github.com/HenryQW/ttrss_opencc](https://github.com/HenryQW/ttrss_opencc "https://github.com/HenryQW/ttrss_opencc")  
 [https://github.com/HenryQW/mercury_fulltext](https://github.com/HenryQW/mercury_fulltext "https://github.com/HenryQW/mercury_fulltext")  
 [https://github.com/feediron/ttrss_plugin-feediron](https://github.com/feediron/ttrss_plugin-feediron "https://github.com/feediron/ttrss_plugin-feediron")     
 [https://github.com/DigitalDJ/tinytinyrss-fever-plugin](https://github.com/DigitalDJ/tinytinyrss-fever-plugin "https://github.com/DigitalDJ/tinytinyrss-fever-plugin")      
@@ -19,7 +21,7 @@
 
 |名称|版本|说明|
 |:-|:-|:-|
-|ttrss|plugins-24.11-4dfa7a66|amd64;arm64v8;arm32v7,集成postgres数据库(PostgreSQL-14.1),mercury-parser-api及一些常用插件|
+|ttrss|plugins-24.12-7b727156|amd64;arm64v8;arm32v7,集成postgres数据库(PostgreSQL-14.1),mercury-parser-api,opencc-api,及一些常用插件|
 
 #### 版本升级注意:
 
@@ -65,6 +67,7 @@
            -p 80:80 \
            -p 5432:5432 \
            -p 3000:3000 \
+           -p 4000:4000 \
            -v /配置文件位置:/config  \
            -v /PostgreSQL存储数据的位置:/var/lib/postgresql/data  \
            -e UID=1000  \
@@ -103,6 +106,7 @@
 | `-p 80:80` |tt-rss服务器web端口; 默认用户名:admin,默认密码:password|
 | `-p 5432:5432` |PostgreSQL服务器端口|
 | `-p 3000:3000` |mercury-parser-api 服务端口|
+| `-p 4000:4000` |opencc-api 服务端口|
 | ` -v /配置文件位置:/config` |tt-rss配置文件位置|
 | `-v /PostgreSQL存储数据的位置:/var/lib/postgresql/data` |PostgreSQL存储数据的位置|
 | `-e UID=1000` |uid设置,默认为1000,不支持设定为0|
@@ -124,6 +128,12 @@
 | `-e TTRSS_ALLOW_PORTS=80,443` |ttrss可订阅的端口,如需1200,可替换80,443为1200|
 | `-e TTRSS_UPDATE_AUTO=true` |自动更新tt-rss(true\|false),默认开启此功能|
 | `-e TTRSS_CADDY_PORT=80` |tt-rss访问及caddy端口,无需更改|
+| `-e ENABLE_MERCURY=true` |(true\|false)mercury-parser-api服务,默认开启|
+| `-e MERCURY_PORT=3000` |mercury-parser-api监听端口,无需更改|
+| `-e ENABLE_OPENCC=false` |(true\|false)opencc-api服务,默认关闭|
+| `-e OPENCC_PORT=4000` |opencc-api服务监听端口,无需更改|
+| `-e PGPORT=5432` |PostgreSQL监听端口,无需更改|
+| `-e PHP_LISTEN_PORT=9000` |PHP监听端口,无需更改|
 | `-e POSTGRES_DB_DUMP=false` |PostgreSQL备份(true\|false),不能与还原同时使用,仅启动时执行|
 | `-e POSTGRES_DB_RESTORE=false` |PostgreSQL还原(true\|false),不能与备份同时使用,仅启动时执行|
 
@@ -142,7 +152,8 @@
 |:-|:-|
 | `本地端口1:80` |tt-rss服务器web端口; 默认用户名:admin,默认密码:password|
 | `本地端口2:3000` |mercury-parser-api 服务端口|
-| `本地端口3:5432` |postgres数据库服务端口|
+| `本地端口3:4000` |opencc-api 服务端口|
+| `本地端口4:5432` |postgres数据库服务端口|
 
 3. 环境变量:
 
@@ -167,6 +178,12 @@
 | `TTRSS_ALLOW_PORTS=80,443` |ttrss可订阅的端口,如需1200,可替换80,443为1200|
 | `TTRSS_UPDATE_AUTO=true` |自动更新tt-rss(true\|false),默认开启此功能|
 | `TTRSS_CADDY_PORT=80` |tt-rss访问及caddy端口,无需更改|
+| `ENABLE_MERCURY=true` |(true\|false)mercury-parser-api服务,默认开启|
+| `MERCURY_PORT=3000` |mercury-parser-api监听端口,无需更改|
+| `ENABLE_OPENCC=false` |(true\|false)opencc-api服务,默认关闭|
+| `OPENCC_PORT=4000` |opencc-api服务监听端口,无需更改|
+| `PGPORT=5432` |PostgreSQL监听端口,无需更改|
+| `PHP_LISTEN_PORT=9000` |PHP监听端口,无需更改|
 | `POSTGRES_DB_DUMP=false` |PostgreSQL备份(true\|false),不能与还原同时使用,仅启动时执行|
 | `POSTGRES_DB_RESTORE=false` |PostgreSQL还原(true\|false),不能与备份同时使用,仅启动时执行|
 
@@ -175,7 +192,12 @@
 * mercury_fulltext:
 
   1. 偏好设置启用插件
-  2. 信息源栏 Mercury Fulltext settings 填入 [ip:本地端口2](ip:本地端口2)
+  2. 供稿栏 Mercury Fulltext settings 填入 [ip:本地端口2](ip:本地端口2)
+
+* opencc:
+
+  1. 偏好设置启用插件
+  2. 供稿栏 opencc settings 填入 [ip:本地端口3](ip:本地端口3)
 
 ### 中文搜索设置:
 

+ 1 - 1
tt-rss-plugins/root/etc/caddy/caddy.conf

@@ -8,6 +8,6 @@
 :{$TTRSS_CADDY_PORT} {
   root *  /usr/local/tt-rss/app
   encode gzip
-  php_fastcgi 127.0.0.1:9000
+  php_fastcgi 127.0.0.1:{$PHP_LISTEN_PORT}
   file_server
 }

+ 9 - 0
tt-rss-plugins/root/etc/cont-init.d/tt-rss.sh

@@ -75,6 +75,10 @@ fi
 if [ ! -d "/config/plugins.local/af_readability" ]; then
   cp -rf /usr/local/tt-rss/defaults/plugins.local/af_readability /config/plugins.local/
 fi
+#检查opencc plugins
+if [ ! -d "/config/plugins.local/opencc" ]; then
+  cp -rf /usr/local/tt-rss/defaults/plugins.local/opencc /config/plugins.local/
+fi
 
 #检查templates.local文件夹位置
 if [ ! -d "/config/templates.local" ]; then
@@ -166,6 +170,11 @@ if [ -n "$POSTGRES_GID" ] && [ -n "$POSTGRES_UID" ]; then
   fi
 fi
 
+#修改php监听端口
+if [ "$PHP_LISTEN_PORT" != "$(grep -E  "^listen = 127.0.0.1" /etc/php83/php-fpm.d/www.conf|awk -F: '{print $2}')" ]; then
+  sed -i -e "s/^listen = 127.0.0.1.*/listen = 127.0.0.1:$PHP_LISTEN_PORT/" /etc/php83/php-fpm.d/www.conf
+fi
+
 #更改文件夹权限
 chown -R ttrss:ttrss /config/
 chown -R ttrss:ttrss /usr/local/tt-rss/

+ 5 - 1
tt-rss-plugins/root/etc/services.d/mercury/run

@@ -1,4 +1,8 @@
 #! /usr/bin/with-contenv bash
 
 #启动 mercury api
-exec s6-setuidgid ttrss node /usr/local/mercury-parser-api/node_modules/mercury-parser-api/index.js
+if [ $ENABLE_MERCURY == "true" ]; then
+	exec s6-setuidgid ttrss node /usr/local/mercury-parser-api/node_modules/mercury-parser-api/index.js
+esle
+	exit 0
+fi

+ 8 - 0
tt-rss-plugins/root/etc/services.d/opencc/run

@@ -0,0 +1,8 @@
+#! /usr/bin/with-contenv bash
+
+#启动 opencc api
+if [ $ENABLE_OPENCC == "true" ]; then
+	exec s6-setuidgid ttrss node /usr/local/OpenCC.henry.wang/node_modules/opencc.henry.wang/bin/www
+esle
+	exit 0
+fi

+ 3 - 0
tt-rss-plugins/root/usr/local/tt-rss/defaults/updatett-rss.sh

@@ -36,6 +36,9 @@ if [ "$TTRSS_UPDATE_AUTO" == "true" ]; then
   # update plugin fever
   cd /usr/local/tt-rss/app/plugins.local/fever
   git pull --shallow-since=$(echo "`git show --pretty=format:"%ct" | head -1`-86400" | date -d @`bc` "+%Y-%m-%d")
+  # update plugin opencc
+  cd /usr/local/tt-rss/app/plugins.local/opencc
+  git pull --shallow-since=$(echo "`git show --pretty=format:"%ct" | head -1`-86400" | date -d @`bc` "+%Y-%m-%d")
   # update plugin feedly-theme
   cd /usr/local/tt-rss/defaults/themes.local/tt-rss-feedly-theme
   Oldversion="`git rev-parse HEAD`"