diff --git a/CaddyfileDev b/CaddyfileDev index dc9ee4e..b357642 100644 --- a/CaddyfileDev +++ b/CaddyfileDev @@ -5,170 +5,207 @@ handle_path /android-chrome-192x192.png { - root * ./static/android-chrome-192x192.png + root * /static/android-chrome-192x192.png file_server } + handle_path /android-chrome-512x512.png { - root * ./static/android-chrome-512x512.png + root * /static/android-chrome-512x512.png file_server } + handle_path /apple-touch-icon.png { - root * ./static/apple-touch-icon.png + root * /static/apple-touch-icon.png file_server } + handle_path /browserconfig.xml { - root * ./static/browserconfig.xml + root * /static/browserconfig.xml file_server } + handle_path /favicon-16x16.png { - root * ./static/favicon-16x16.png + root * /static/favicon-16x16.png file_server } + handle_path /favicon-32x32.png { - root * ./static/favicon-32x32.png + root * /static/favicon-32x32.png file_server } + handle_path /favicon.ico { - root * ./static/favicon.ico + root * /static/favicon.ico file_server } + handle_path /humans.txt { - root * ./static/humans.txt + root * /static/humans.txt file_server } + handle_path /mstile-144x144.png { - root * ./static/mstile-144x144.png + root * /static/mstile-144x144.png file_server } + handle_path /mstile-150x150.png { - root * ./static/mstile-150x150.png + root * /static/mstile-150x150.png file_server } + handle_path /mstile-310x150.png { - root * ./static/mstile-310x150.png + root * /static/mstile-310x150.png file_server } + handle_path /mstile-310x310.png { - root * ./static/mstile-310x310.png + root * /static/mstile-310x310.png file_server } + handle_path /mstile-70x70.png { - root * ./static/mstile-70x70.png + root * /static/mstile-70x70.png file_server } + handle_path /robots.txt { - root * ./static/robots.txt + root * /static/robots.txt file_server } + handle_path /safari-pinned-tab.svg { - root * ./static/safari-pinned-tab.svg + root * /static/safari-pinned-tab.svg file_server } + handle_path /security.txt { - root * ./static/security.txt + root * /static/security.txt file_server } + handle_path /site.webmanifest { - root * ./static/site.webmanifest + root * /static/site.webmanifest file_server } + handle_path /sitemap.xml { - root * ./static/sitemap.xml + root * /static/sitemap.xml file_server } + handle_path /websocket { respond "Access denied" 403 } + handle_path /meta.json { respond "Access denied" 403 } + handle_path /cdn-cgi/challenge-platform/scripts/jsd/main.js { respond "Access denied" 403 } + handle_path /cdn-cgi/rum { respond "Access denied" 403 } + handle_path /graphql/websocket { respond "Access denied" 403 } + handle_path /onboarding/* { respond "Access denied" 403 } + handle_path /wp-* { respond "Access denied" 403 } + handle_path /.env { respond "Access denied" 403 } + handle_path /api* { respond "Access denied" 403 } + handle_path /apple-touch-icon-precomposed.png { respond "Access denied" 403 } + handle_path /rss.xml { respond "Access denied" 403 } + handle_path /.git/* { respond "Access denied" 403 } + handle_path /apple-touch-icon-120x120.png { respond "Access denied" 403 } + handle_path /apple-touch-icon-120x120-precomposed.png { respond "Access denied" 403 } + handle_path /apple-touch-icon-152x152.png { respond "Access denied" 403 } + handle_path /apple-touch-icon-152x152-precomposed.png { respond "Access denied" 403 } + handle_path /.well-known/* { respond "Access denied" 403 } + handle_path /cdn-cgi/challenge-platform/h/b/orchestrate/chl_page/v1 { respond "Access denied" 403 } + handle_path /cdn-cgi/challenge-platform/h/g/orchestrate/chl_page/v1 { respond "Access denied" 403 } + route /* { reverse_proxy web:7080 diff --git a/CaddyfileProd b/CaddyfileProd index 89003aa..2ee0f4d 100644 --- a/CaddyfileProd +++ b/CaddyfileProd @@ -6,170 +6,207 @@ freedium.cfd { handle_path /android-chrome-192x192.png { - root * ./static/android-chrome-192x192.png + root * /static/android-chrome-192x192.png file_server } + handle_path /android-chrome-512x512.png { - root * ./static/android-chrome-512x512.png + root * /static/android-chrome-512x512.png file_server } + handle_path /apple-touch-icon.png { - root * ./static/apple-touch-icon.png + root * /static/apple-touch-icon.png file_server } + handle_path /browserconfig.xml { - root * ./static/browserconfig.xml + root * /static/browserconfig.xml file_server } + handle_path /favicon-16x16.png { - root * ./static/favicon-16x16.png + root * /static/favicon-16x16.png file_server } + handle_path /favicon-32x32.png { - root * ./static/favicon-32x32.png + root * /static/favicon-32x32.png file_server } + handle_path /favicon.ico { - root * ./static/favicon.ico + root * /static/favicon.ico file_server } + handle_path /humans.txt { - root * ./static/humans.txt + root * /static/humans.txt file_server } + handle_path /mstile-144x144.png { - root * ./static/mstile-144x144.png + root * /static/mstile-144x144.png file_server } + handle_path /mstile-150x150.png { - root * ./static/mstile-150x150.png + root * /static/mstile-150x150.png file_server } + handle_path /mstile-310x150.png { - root * ./static/mstile-310x150.png + root * /static/mstile-310x150.png file_server } + handle_path /mstile-310x310.png { - root * ./static/mstile-310x310.png + root * /static/mstile-310x310.png file_server } + handle_path /mstile-70x70.png { - root * ./static/mstile-70x70.png + root * /static/mstile-70x70.png file_server } + handle_path /robots.txt { - root * ./static/robots.txt + root * /static/robots.txt file_server } + handle_path /safari-pinned-tab.svg { - root * ./static/safari-pinned-tab.svg + root * /static/safari-pinned-tab.svg file_server } + handle_path /security.txt { - root * ./static/security.txt + root * /static/security.txt file_server } + handle_path /site.webmanifest { - root * ./static/site.webmanifest + root * /static/site.webmanifest file_server } + handle_path /sitemap.xml { - root * ./static/sitemap.xml + root * /static/sitemap.xml file_server } + handle_path /websocket { respond "Access denied" 403 } + handle_path /meta.json { respond "Access denied" 403 } + handle_path /cdn-cgi/challenge-platform/scripts/jsd/main.js { respond "Access denied" 403 } + handle_path /cdn-cgi/rum { respond "Access denied" 403 } + handle_path /graphql/websocket { respond "Access denied" 403 } + handle_path /onboarding/* { respond "Access denied" 403 } + handle_path /wp-* { respond "Access denied" 403 } + handle_path /.env { respond "Access denied" 403 } + handle_path /api* { respond "Access denied" 403 } + handle_path /apple-touch-icon-precomposed.png { respond "Access denied" 403 } + handle_path /rss.xml { respond "Access denied" 403 } + handle_path /.git/* { respond "Access denied" 403 } + handle_path /apple-touch-icon-120x120.png { respond "Access denied" 403 } + handle_path /apple-touch-icon-120x120-precomposed.png { respond "Access denied" 403 } + handle_path /apple-touch-icon-152x152.png { respond "Access denied" 403 } + handle_path /apple-touch-icon-152x152-precomposed.png { respond "Access denied" 403 } + handle_path /.well-known/* { respond "Access denied" 403 } + handle_path /cdn-cgi/challenge-platform/h/b/orchestrate/chl_page/v1 { respond "Access denied" 403 } + handle_path /cdn-cgi/challenge-platform/h/g/orchestrate/chl_page/v1 { respond "Access denied" 403 } + route /* { reverse_proxy web:7080 diff --git a/DockerfileHealthcare b/DockerfileHealthcare deleted file mode 100644 index e0b5ddb..0000000 --- a/DockerfileHealthcare +++ /dev/null @@ -1,9 +0,0 @@ -FROM python:3.12.3 - -RUN pip install docker requests[socks] loguru --no-cache-dir - -COPY scripts/ /scripts/ - -# RUN chmod +x /scripts/service_up.py - -CMD [ "python3", "/scripts/service_up.py" ] \ No newline at end of file diff --git a/README.md b/README.md index 42e9a2b..04125d0 100644 --- a/README.md +++ b/README.md @@ -63,4 +63,18 @@ sudo docker-compose -f docker-compose-dev.yml up And now you can access local instance of Freedium by opening browser and type `http://localhost:6752`. ## TODO: + - Integrate library notifiers - https://github.com/liiight/notifiers +- Do not use 'shturman/dante' image, because it is does not have updates for a long time. (Probably) Use https://hub.docker.com/r/vimagick/dante/ + +## Roadmap + +- [ ] Speed up parser logic, port to Cython or rewrite to Golang +- [ ] Make parse Medium format directly to Markdown, not HTML, in order to make it more universal. This helps to generate RSS feeds, PDF, HTML. + OR we need write separate parser for different formats, like PDF, Markdown, etc. +- [ ] Add more services than just a Medium +- [ ] Rewrite frontend to Svelte +- [ ] Move frontend to Cloudflare Pages +- [ ] Integrate Grafana/Prometheus to monitor our services +- [ ] Add more metrics to our services to have ability to monitor it +- [ ] Make able translate posts to different languages using translatepy library diff --git a/database-lib/database_lib/main.py b/database-lib/database_lib/main.py index cb26330..bd14ebc 100644 --- a/database-lib/database_lib/main.py +++ b/database-lib/database_lib/main.py @@ -7,11 +7,15 @@ from typing import Union, Optional from abc import ABC, abstractmethod import psycopg2 -import sqlite_zstd import uuid from loguru import logger from psycopg2.extras import execute_batch +try: + import sqlite_zstd +except ImportError: + sqlite_zstd = None + class CacheData: __slots__ = ("data",) @@ -94,7 +98,11 @@ class SQLiteCacheBackend(AbstractCacheBackend): self.cursor = self.connection.cursor() if self.zstd_enabled: + if sqlite_zstd is None: + raise ValueError("sqlite_zstd library not found.") + sqlite_zstd.load(self.connection) + self.enable_zstd() def ensure_connection(self): if self.connection is None or self.cursor is None: @@ -117,9 +125,6 @@ class SQLiteCacheBackend(AbstractCacheBackend): return [CacheResponse(key, value) for key, value in self.cursor] def enable_zstd(self): - if not self.zstd_enabled: - raise ValueError("Can't use zstd compression. Please install 'sqlite_zstd' package") - self.ensure_connection() with self.connection: try: diff --git a/database-lib/requirements.txt b/database-lib/requirements.txt index 1187b1c..44d03e5 100644 --- a/database-lib/requirements.txt +++ b/database-lib/requirements.txt @@ -1,4 +1,4 @@ loguru==0.6.0 psycopg2-binary==2.9.9 -sqlite-zstd-build +# sqlite-zstd-build # git+https://github.com/phiresky/sqlite-zstd.git#egg=sqlite_zstd&subdirectory=python diff --git a/scripts/disable_redis.sh b/scripts/disable_redis.sh deleted file mode 100755 index 361465d..0000000 --- a/scripts/disable_redis.sh +++ /dev/null @@ -1,3 +0,0 @@ -sudo systemctl status redis -sudo systemctl stop redis -sudo systemctl disable redis diff --git a/scripts/generate_caddy_rules.py b/scripts/generate_caddy_rules.py index da269b4..5788720 100644 --- a/scripts/generate_caddy_rules.py +++ b/scripts/generate_caddy_rules.py @@ -4,6 +4,7 @@ from typing import List, Dict from jinja2 import Template # Constants +APP_ROOT = "/static" STATIC_DIR = "./static" ACCESS_DENIED_PATHS: List[str] = [ "websocket", @@ -41,12 +42,12 @@ def generate_static_file_rules(files: List[str]) -> List[str]: template = Template( """ handle_path /{{ file }} { - root * ./static/{{ file }} + root * {{ app_root }}/{{ file }} file_server } """ ) - return [template.render(file=file) for file in files] + return [template.render(file=file, app_root=APP_ROOT) for file in files] def generate_access_denied_rules(paths: List[str]) -> List[str]: diff --git a/scripts/start_maintance.sh b/scripts/start_maintance.sh deleted file mode 100755 index b1188d8..0000000 --- a/scripts/start_maintance.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -arch=$(lscpu | grep Architecture | awk {'print $2'}) -echo $arch - -redis-cli flushall -./bin/$arch/caddy run --config ./CaddyfileMaintance \ No newline at end of file