From 893c0bbffdcad83f796e85e7468535008721f801 Mon Sep 17 00:00:00 2001 From: Opnxng Date: Sun, 26 May 2024 11:55:58 +0800 Subject: [PATCH] Priviblur: implemented PussTheCat image and Redis cache --- config-tasks/priviblur.yaml | 10 ++++++ templates/compose/priviblur.yaml.j2 | 26 +++++++++++++++- templates/conf/config.toml.j2 | 47 ++++++++++++++++++----------- 3 files changed, 65 insertions(+), 18 deletions(-) diff --git a/config-tasks/priviblur.yaml b/config-tasks/priviblur.yaml index 5dd489c..84f2702 100644 --- a/config-tasks/priviblur.yaml +++ b/config-tasks/priviblur.yaml @@ -5,3 +5,13 @@ owner: 1000 group: 1000 mode: 0755 + + - name: Create valkey-data directory + ansible.builtin.file: + path: "{{ docker_dir }}/priviblur/valkey-data" + state: directory + owner: 999 + group: 1000 + mode: 0755 + become: true + diff --git a/templates/compose/priviblur.yaml.j2 b/templates/compose/priviblur.yaml.j2 index 7d9f40c..3644dcb 100644 --- a/templates/compose/priviblur.yaml.j2 +++ b/templates/compose/priviblur.yaml.j2 @@ -3,7 +3,7 @@ version: '3.7' services: priviblur: container_name: priviblur - image: git.opnxng.com/opnxng/priviblur:latest + image: quay.io/pussthecatorg/priviblur security_opt: - no-new-privileges environment: @@ -19,6 +19,30 @@ services: networks: - priviblur + priviblur-redis: + container_name: priviblur-redis + image: docker.io/valkey/valkey:alpine + command: valkey-server --save 30 1 --loglevel warning + security_opt: + - no-new-privileges + environment: + #- PUID=1000 + #- PGID=1000 + - TZ=Asia/Singapore + volumes: + - {{ docker_dir }}/priviblur/valkey-data:/data + user: "999:1000" + read_only: true + cap_drop: + - ALL + cap_add: + - SETGID + - SETUID + - DAC_OVERRIDE + restart: unless-stopped + networks: + - priviblur + networks: priviblur: name: priviblur diff --git a/templates/conf/config.toml.j2 b/templates/conf/config.toml.j2 index 08f1979..987d80b 100644 --- a/templates/conf/config.toml.j2 +++ b/templates/conf/config.toml.j2 @@ -1,26 +1,38 @@ # Controls deployment options [deployment] -# host = "127.0.0.1" - host = "0.0.0.0" + host = "0.0.0.0" # Set to 127.0.0.1 if you use a reverse proxy, or access it locally port = 8000 # Amount of worker Priviblur instances to spawn. Increases speed significantly. # workers = 1 - # # If you're running Priviblur behind a remote proxy, one or more of the following must be set - # # can also be set via env variables by captialzing and prefixing with PRIVIBLUR_ - # # - # # For more information see - # # https://sanic.dev/en/guide/advanced/proxy-headers.html - # # - # # Default: None - # # - # forwarded_secret = - # real_ip_header = - # proxies_count = -# Controls behaviors pertaining to the way Priviblur requests Tumblr -[priviblur_backend] +# # Controls redis cache options +# # Ignore to disable the cache +# # +# # To enable caching, Redis is required, you then have to uncomment "url" and set it accordingly. Every other options in this section will use their default value (indicated next to them) if they are kept commented out. +[cache] + + # For docker use the following: + url = "redis://priviblur-redis:6379" + + # Number of seconds to cache poll results from active polls + cache_active_poll_results_for = 3600 + + # Number of seconds to cache poll results from expired polls + cache_expired_poll_results_for = 86400 + + # Number of seconds to cache feed (explore, search, etc) results for + cache_feed_for = 3600 + + # Number of seconds to cache blog feed (blog posts, blog search, blog tagged posts, etc) results for + cache_blog_feed_for = 3600 + + # Number of seconds to cache individual posts for + cache_blog_post_for = 300 + +# # Controls behaviors pertaining to the way Priviblur requests Tumblr +# [priviblur_backend] # # Timeout for requests to Tumblr's API # main_response_timeout = 10 @@ -32,7 +44,7 @@ # # Use Python's numerical logging levels # https://docs.python.org/3/howto/logging.html#logging-levels -[logging] +# [logging] # # Sanic (Server)'s logging level' # sanic_logging_level = 30 @@ -42,6 +54,7 @@ # # Priviblur extractor's logging level # priviblur_extractor_logging_level = 20 -[misc] + +# [misc] # # Enable sanic's dev mode # dev_mode = false