RSS-Bridge / rss-bridge

The RSS feed for websites missing it
https://rss-bridge.org/bridge01/
The Unlicense
7.21k stars 1.03k forks source link

How to Add whitelist.txt to docker image #1955

Closed luckyankit closed 2 years ago

luckyankit commented 3 years ago

How can I add whitelist.txt or enable bridges via variables in docker settings?

I installed rss-bridge docker https://hub.docker.com/r/rssbridge/rss-bridge by searching inside plesk control panel and just ran it. It works great but I have no way to enable more bridges nor I have any setting to change the cache period. Is it possible to enable this via variables as shown in the screenshot. variables

sabberworm commented 3 years ago

You could add the whitelist outside the container and add a volume mapping for it. The path inside the container is /app/whitelist.txt. So you would add: /path/to/your/whitelist.txt:/app/whitelist.txt as a volume mapping.

luckyankit commented 3 years ago

Like this? It didn't work. image

luckyankit commented 3 years ago

I also tried the complete path (/var/www/vhosts/whitelist.txt:/app/whitelist.txt) with nothing on the Host and Plesk just removed the path while saving changes. image

luckyankit commented 3 years ago

Also anything for the cache issue?

em92 commented 3 years ago

image

This is definitely not correct way to map volume. On you previous screenshot - it is correct.

Anyway, have you restarted docker container after mapping volume?

ghost commented 3 years ago

I faced this same issue when I used rss-bridge on my raspberry pi. Docker volumes are supposed to be directories, into which you'll store file that you want to be permanent, NOT files. For this configuration to work, you must stop and remove the container entirely, and create beforehand the "whitelist.txt" file where the volume mapping is expecting to find it. Only then, this mapping will work. So, you have to be able to create stuff, via command line or smth, if you have access to that, otherwise you're out of luck. FWIW, I just tested my theory and if there is no "whitelist.txt" beforehand, docker will simply create a "whitelist.txt" directory, which is useless.

luckyankit commented 3 years ago

I have SSH access. Can you please share commands/steps to create docker that way, please?

luckyankit commented 3 years ago

@em92 it doesn't work any way either. Restarted docker as well.

ghost commented 3 years ago

I can give you general ideas on how to do it, mainly because I haven't used plesk and I don't know exactly what sort of permissions it requires.

  1. Stop and remove completely the rss-bridge container via the plesk GUI.
  2. SInce it seems to install everything on /var/www/vhosts, then we'll create the file there. use the follwing command sudo nano /var/www/vhosts/whitelist.txt
  3. The text editor will open, and now type the bridges you want to enable (eg. Facebook), one bridge per line. Save and close from the text editor (ctrl+x, press yes both times)
  4. The file is ready, but the tricky part is to know which sort of permissions the file requires to be read by the docker container. Since it's being stored in the /var/www/ location, I'll guess that it needs to belongs to www-data, so we'll change the owner for the file: sudo chown www-data:www-data /var/www/vhosts/whitelist.txt
  5. Launch the docker container using the volume mapping you've used before.
  6. Now new bridges should be enabled.

If you want custom cache duration, you'll have to do a similar procedure with config.ini.php (copy the contents from config.default.ini.php: https://github.com/RSS-Bridge/rss-bridge/blob/master/config.default.ini.php) . To enable the corresponding option, follow the documentation. Hopefully that helps!

ikajdan commented 3 years ago

Little off-topic, but I came to similar conclusions as @maguilara in terms of using Docker volume. Although as a workaround one can build their own image based on rss-bridge:

FROM rssbridge/rss-bridge:latest

RUN mkdir /config && \
    cp /app/whitelist.default.txt /config/whitelist.txt && \
    ln -s /config/whitelist.txt /app/whitelist.txt && \
    chown -h www-data:www-data /app/whitelist.txt && \
    chown -R www-data:www-data /config

It creates /config directory and symlinks /app/whitelist.txt into it. Now it's possible to mount /config as a volume. Can somebody test if it works for them, so I can create PR? It seems to be backward compatible with current setup.

Bockiii commented 3 years ago

I thought about this for a while and tested @verahawk s solution but: I'm relatively sure that this is not possible in the current way rss-bridge is setup.

Mounting a folder will mount the host folder into the container. That means, all the jazz that you are doing in the dockerfile will just be overwritten with the empty, new .config folder on the host. There is no way (that I know of) to mount a folder from the host into the container that will mount it the other way.

What would be possible is to do that after the container was started. The /config folder would have been created by the volume mount and then the whitelist.txt is moved/copied into that folder. You would then see it on the host.

The problem is, that requires the file to be generated after the container started. I am not good enough with php to do that, but what would need to happen (and I actually like that idea) would be:

rss-bridge starts. Checks if there is a whitelist.txt where one would be (e.g /config/whitelist). If yes, use that. If not, generate the file by copying the whitelist.default.txt to that location.

I checked the bridgefactory.php and it already does the checking, it just doesnt do the default-copying. I assume @em92 would need to do that (or someone else with vastly more php knowledge than I have ;D )

If you establish the default-copy-to-/config/whitelist.txt, the solution would be to just mount that folder. I personally dont see any downside to this and only upsides. It is very much more userfriendly than the current solution since you have to generate the file on the host side first and if you are using docker on a NAS or so, you might not be linux-knowledgeable enough to do that.

ikajdan commented 3 years ago

Yep, my idea was rather a stopgap solution.

A better way of solving this, would be a possibility to configure RSS-Bridge using environment variables – it's really easy to inject those into a Docker container and users with current setup would be unaffected. Unfortunately I don't know PHP either.

The problem would still exist for custom bridges, though. To fix it, RSS-Bridge should look for them in some other directory as well, let's say bridges.d.

Bockiii commented 3 years ago

@verahawk check my proposed solution PR. it should do exactly what is needed.

ikajdan commented 3 years ago

@Bockiii Apart from some small issues, it looks good to me. I have added some comments over there.

EsmailELBoBDev2 commented 2 years ago

Hi i had same issue and this worked with me (https://github.com/RSS-Bridge/rss-bridge/issues/1955#issuecomment-766399765)

You could add the whitelist outside the container and add a volume mapping for it. The path inside the container is /app/whitelist.txt. So you would add: /path/to/your/whitelist.txt:/app/whitelist.txt as a volume mapping.

my docker conf is

version: '2'
services:
  rss-bridge:
    image: rssbridge/rss-bridge:latest
    volumes:
      - /etc/rss-bridge/config.ini.php:/config
      - /etc/rss-bridge/whitelist.txt:/app/whitelist.txt
    ports:
      - 3300:80
    restart: unless-stopped
Bockiii commented 2 years ago

You can just map the folder to /config in the container and it will pick up your whitelist, php config and additional bridges.

volumes:
  - /etc/rss-bridge:/config
Bockiii commented 2 years ago

@em92 can be closed

dvikan commented 2 years ago
docker exec -it rss-bridge /bin/bash
vim /app/whitelist.txt