Add readflow node

This commit is contained in:
2023-05-21 18:03:08 +02:00
parent aa8990e1c7
commit 6e78335f5d

145
20230520112339-readflow.org Normal file
View File

@@ -0,0 +1,145 @@
:PROPERTIES:
:ID: af021596-3d07-42bf-9131-0c203ac1c26f
:mtime: 20230521180253
:ctime: 20230520112339
:END:
#+title: readflow
* Introduction
Sauvegarde de page web pour lecture offline.
* Installation
** API
*** Build
#+BEGIN_SRC shell
cd /opt/
git clone https://github.com/ncarlier/readflow.git readflow
cd readflow
git submodule init
git submodule update
make
#+END_SRC
*** Configuration
**** Préparation des variables d'environnement
Contenu du fichier ~env~:
#+BEGIN_SRC shell
export READFLOW_DB="postgres://<db_user>:<db_pass>@localhost/readflow"
export READFLOW_LISTEN_ADDR="localhost:8010"
export READFLOW_LISTEN_METRICS=
export READFLOW_AUTHN="https://login.adrien.run/realms/readings"
export READFLOW_PUBLIC_URL="https://readflow.adrien.run"
export READFLOW_SECRET_SALT="<salt>"
export READFLOW_BLOCK_LIST=
export READFLOW_BROKER_URI=
export READFLOW_WEB_SCRAPER_URL=
export READFLOW_IMAGE_PROXY_URL=
export READFLOW_AVATAR_PROVIDER=
export READFLOW_SECRETS_ENGINE_PROVIDER=
export READFLOW_SENTRY_DSN=
export READFLOW_POCKET_CONSUMER_KEY=
export REACT_APP_API_ROOT="/api"
export REACT_APP_AUTHORITY="https://login.adrien.run/realms/readings"
export REACT_APP_CLIENT_ID="readflow"
export REACT_APP_REDIRECT_URL="https://readflow.adrien.run/login"
#+END_SRC
**** Substitution des variables du fichier de configuration
#+BEGIN_SRC shell
source ./env
envsubst < ./readflow.toml > ./config.toml
#+END_SRC
*** Exécution
#+BEGIN_SRC shell
./release/readflow -config ./config.toml
#+END_SRC
Ou
#+BEGIN_SRC shell
cat >/lib/systemd/system/readflow.service <<EOF
[Unit]
Description=Readflow service
[Service]
User=readflow
ExecStart=/opt/readflow/release/readflow -config /opt/readflow/config.toml
ExecReload=/bin/kill -HUP $MAINPID
Restart=always
RestartSec=3
SyslogIdentifier=readflow
[Install]
WantedBy=multi-user.target
EOF
#+END_SRC
#+BEGIN_SRC shell
adduser --system --no-create-home --disabled-password --disabled-login readflow
systemctl enable readflow
systemctl start readflow
#+END_SRC
** Webclient
#+BEGIN_SRC shell
n lts # Require a up to date node version
npm install --legacy-peer-deps
npm run build
#+END_SRC
** Nginx
#+BEGIN_SRC conf
server {
server_name readflow.adrien.run;
listen 443 ssl http2;
listen [::]:443 ssl http2;
# SSL configuration
include /etc/nginx/ssl.conf;
ssl_certificate /etc/letsencrypt/live/readflow.adrien.run/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/readflow.adrien.run/privkey.pem;
# Logging configuration
access_log /var/log/nginx/readflow.access.log;
error_log /var/log/nginx/readflow.error.log;
gzip on;
gzip_static on; # allows pre-serving of .gz file if it exists
gzip_disable "msie6"; # Disable for user-agent Internet explorer 6. Not supported.
gzip_proxied any; # enable gzip for all proxied requests
gzip_buffers 16 8k; # number and size of buffers to compress a response
gzip_http_version 1.1;
gzip_min_length 256; # Only gzip files of size in bytes
gzip_types text/plain text/css text/html application/javascript application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/vnd.ms-fontobject application/x-font-ttf font/opentype image/svg+xml image/x-icon;
gunzip on;
add_header 'Access-Control-Allow-Origin' 'https://login.adrien.run';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
location /api {
rewrite /api/(.*) /$1 break;
proxy_redirect off;
proxy_pass http://127.0.0.1:8010;
}
location / {
try_files $uri $uri/ /index.html;
root /opt/readflow/ui/build;
}
}
server {
server_name readflow.adrien.run;
listen 80;
listen [::]:80;
if ($host = readflow.adrien.run) {
return 301 https://$host$request_uri;
}
return 404;
}
#+END_SRC
* Références
* [[https://github.com/ncarlier/readflow][Readflow - Github]]
* [[https://github.com/ncarlier/readflow/issues/48][Can a simple tutorial be provided for non-professionals #48 - Github]]