From c08558604caa553d37ab12460a50ffc2de40399c Mon Sep 17 00:00:00 2001 From: sillyboy110 <1521925504@qq.com> Date: Mon, 21 Aug 2023 19:23:34 +0800 Subject: [PATCH 1/8] Update Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 2e36450..94429e9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,7 +11,7 @@ RUN apt-get install -y python3 python3-pip python3-virtualenv nginx supervisor # Setup flask application RUN mkdir -p /app COPY . /app -RUN pip install -r /app/requirements.txt -i https://mirrors.aliyun.com/pypi/simple +RUN pip install -r /app/requirements.txt RUN pip install gunicorn # RUN pip install git+https://github.com/getsyncr/notion-sdk.git From f5ba72d32e19d7d39251c8ced0df3e843c52dde9 Mon Sep 17 00:00:00 2001 From: sillyboy110 <1521925504@qq.com> Date: Mon, 21 Aug 2023 19:24:27 +0800 Subject: [PATCH 2/8] Update Dockerfile --- Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 94429e9..6f84791 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,6 @@ MAINTAINER Hiller Liao ENV DEBIAN_FRONTEND noninteractive -RUN apt-get update RUN apt-get install -y python3 python3-pip python3-virtualenv nginx supervisor # Setup flask application From 4e6d70a9fcd436a4719dfc46b3a69a348e7cb972 Mon Sep 17 00:00:00 2001 From: sillyboy110 <1521925504@qq.com> Date: Tue, 22 Aug 2023 00:57:02 +0800 Subject: [PATCH 3/8] Update Dockerfile --- Dockerfile | 38 ++++++++++++-------------------------- 1 file changed, 12 insertions(+), 26 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6f84791..250a04e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,29 +1,15 @@ -# nginx-gunicorn-flask - -FROM ubuntu:latest -MAINTAINER Hiller Liao - -ENV DEBIAN_FRONTEND noninteractive - -RUN apt-get install -y python3 python3-pip python3-virtualenv nginx supervisor - -# Setup flask application -RUN mkdir -p /app -COPY . /app -RUN pip install -r /app/requirements.txt +# syntax=docker/dockerfile:1.2 +FROM python:3.11-alpine AS build +WORKDIR /app +COPY requirements.txt ./ +RUN --no-cache pip install -r requirements.txt +COPY . . RUN pip install gunicorn -# RUN pip install git+https://github.com/getsyncr/notion-sdk.git - -# Setup nginx -RUN rm /etc/nginx/sites-enabled/default -COPY flask.conf /etc/nginx/sites-available/ -RUN ln -s /etc/nginx/sites-available/flask.conf /etc/nginx/sites-enabled/flask.conf -RUN echo "daemon off;" >> /etc/nginx/nginx.conf -# Setup supervisord -RUN mkdir -p /var/log/supervisor -COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf -COPY gunicorn.conf /etc/supervisor/conf.d/gunicorn.conf +FROM python:3.11-alpine AS runtime +WORKDIR /app +COPY --from=build /app . +USER 1000:1000 -# Start processes -CMD ["/usr/bin/supervisord"] +EXPOSE 8080 +CMD ["gunicorn", "-w", "4", "-b", ":8080", "app:app"] From 45ebd057fe587574db187446811234fe5905e39b Mon Sep 17 00:00:00 2001 From: sillyboy110 <1521925504@qq.com> Date: Tue, 22 Aug 2023 09:07:10 +0800 Subject: [PATCH 4/8] Update Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 250a04e..6be7a0f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,4 +12,4 @@ COPY --from=build /app . USER 1000:1000 EXPOSE 8080 -CMD ["gunicorn", "-w", "4", "-b", ":8080", "app:app"] +CMD ["gunicorn", "-w", "4", "-b", ":5000", "app:app"] From 5bd7ec09f77e7da59c5735f4bb3f9ebffbea0518 Mon Sep 17 00:00:00 2001 From: sillyboy110 <1521925504@qq.com> Date: Tue, 22 Aug 2023 09:32:29 +0800 Subject: [PATCH 5/8] Update Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 6be7a0f..c5131e5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,5 +11,5 @@ WORKDIR /app COPY --from=build /app . USER 1000:1000 -EXPOSE 8080 +EXPOSE 5000 CMD ["gunicorn", "-w", "4", "-b", ":5000", "app:app"] From 2ed2f54aeb5d76084349ce3b1ea4d0306c87f573 Mon Sep 17 00:00:00 2001 From: sillyboy110 <1521925504@qq.com> Date: Tue, 22 Aug 2023 10:03:44 +0800 Subject: [PATCH 6/8] Update Dockerfile --- Dockerfile | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index c5131e5..33fade1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,27 @@ -# syntax=docker/dockerfile:1.2 FROM python:3.11-alpine AS build + WORKDIR /app -COPY requirements.txt ./ -RUN --no-cache pip install -r requirements.txt + +COPY requirements.txt ./ +RUN pip install -r requirements.txt + COPY . . RUN pip install gunicorn FROM python:3.11-alpine AS runtime -WORKDIR /app + +WORKDIR /app + +# 复制并安装gunicorn +COPY --from=build /app/requirements.txt . +RUN pip install -r requirements.txt +RUN pip install Flask-Caching + +# 复制应用代码 COPY --from=build /app . + +# 设置用户和端口 USER 1000:1000 +EXPOSE 5000 -EXPOSE 5000 -CMD ["gunicorn", "-w", "4", "-b", ":5000", "app:app"] +ENTRYPOINT ["gunicorn", "-w", "4", "-b", ":5000", "main:app"] From 3e3bc851dddb0bab54785cb669372726cab1a106 Mon Sep 17 00:00:00 2001 From: sillyboy110 <1521925504@qq.com> Date: Tue, 22 Aug 2023 12:17:05 +0800 Subject: [PATCH 7/8] Update main.py --- rsshub/blueprints/main.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/rsshub/blueprints/main.py b/rsshub/blueprints/main.py index cdcc2f8..cebf149 100644 --- a/rsshub/blueprints/main.py +++ b/rsshub/blueprints/main.py @@ -20,7 +20,7 @@ def feeds(): @bp.app_template_global() -def filter_content(ctx): +def filter_content_bak(ctx): include_title = request.args.get('include_title') include_description = request.args.get('include_description') exclude_title = request.args.get('exclude_title') @@ -35,6 +35,25 @@ def filter_content(ctx): ctx = ctx.copy() ctx['items'] = items return ctx +def filter_content(ctx): + items = ctx['items'].copy() + if 'include_title' in request.args: + include_titles = request.args['include_title'].split('|') + items = [item for item in items if any(title in item['title'] for title in include_titles)] + if 'exclude_title' in request.args: + exclude_titles = request.args['exclude_title'].split('|') + items = [item for item in items if all(title not in item['title'] for title in exclude_titles)] + if 'include_description' in request.args: + include_description = request.args['include_description'].split('|') + items = [item for item in items if any(description in item['description'] for description in include_description)] + if 'exclude_description' in request.args: + exclude_description = request.args['exclude_description'].split('|') + items = [item for item in items if all(description not in item['description'] for description in exclude_description)] + if 'limit' in request.args: + items = items[:int(request.args['limit'])] + ctx = ctx.copy() + ctx['items'] = items + return ctx @@ -320,4 +339,4 @@ def tadoku_books(category=''): def rss_filter(): from rsshub.spiders.rssfilter.filter import ctx feed_url = request.args.get("feed") - return render_template('main/atom.xml', **filter_content(ctx(feed_url))) \ No newline at end of file + return render_template('main/atom.xml', **filter_content(ctx(feed_url))) From 567f437cd960e8ea43be68aedba5c17a8c28221b Mon Sep 17 00:00:00 2001 From: sillyboy110 <1521925504@qq.com> Date: Tue, 22 Aug 2023 12:17:57 +0800 Subject: [PATCH 8/8] Update main.py --- rsshub/blueprints/main.py | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/rsshub/blueprints/main.py b/rsshub/blueprints/main.py index cebf149..2fa116a 100644 --- a/rsshub/blueprints/main.py +++ b/rsshub/blueprints/main.py @@ -20,21 +20,6 @@ def feeds(): @bp.app_template_global() -def filter_content_bak(ctx): - include_title = request.args.get('include_title') - include_description = request.args.get('include_description') - exclude_title = request.args.get('exclude_title') - exclude_description = request.args.get('exclude_description') - limit = request.args.get('limit', type=int) - items = ctx['items'].copy() - items = [item for item in items if include_title in item['title']] if include_title else items - items = [item for item in items if include_description in item['description']] if include_description else items - items = [item for item in items if exclude_title not in item['title']] if exclude_title else items - items = [item for item in items if exclude_description not in item['description']] if exclude_description else items - items = items[:limit] if limit else items - ctx = ctx.copy() - ctx['items'] = items - return ctx def filter_content(ctx): items = ctx['items'].copy() if 'include_title' in request.args: