chauduyphanvu / reddit-markdown

MIT License
34 stars 6 forks source link

Dockerise script #19

Open nathanpovo opened 8 months ago

nathanpovo commented 8 months ago

Creates a docker file that can be used to run the script without the need to have ruby installed locally.

How to use

  1. Clone the repository locally
  2. Modify the settings.json to set the path of the downloaded md files

Change the setting default_save_location from the default value of "DEFAULT_REDDIT_SAVE_LOCATION" to "".

  1. Build the docker image:
docker build -t reddit-markdown .
  1. Run the docker image:
docker run -it --rm --name reddit-markdown-container -v $PWD:/app reddit-markdown

For fellow powershell users: this has to be changed slightly to:

docker run -it --rm --name reddit-markdown-container -v ${PWD}:/app reddit-markdown
  1. Follow the instructions of the script as normal (enter URL, directory, etc.)

Output

With the above instructions, this is the output I get when running the demo:

docker run -it --rm --name reddit-markdown-container -v ${PWD}:/app reddit-markdown

✏️ If you have a link to the Reddit post you want to save, enter/paste it below. Separate multiple links with commas.
✏️ If you need a demo, enter "demo".
✏️ If you want a surprise, enter "surprise".
✏️ If you want to save currently trending posts in a subreddit, enter "r/[SUBREDDIT_NAME]", e.g. "r/pcmasterrace".
✏️ If you have a multireddit (i.e. collection of multiple subreddits) defined in `settings.json`, enter its name, e.g. "m/stocks".
demo

=> Enter a full path to save the post(s) to. Hit Enter/Return for current directory, which is /app.

🔃Demo mode enabled. Using demo link...
🔃Processing post 1 of 1...
https://www.reddit.com/r/pcmasterrace/comments/101kjyq/my_dad_has_been_playing_civilization_almost_daily/

🔃Downloading post data...
🔃Saving...
✅Reddit post saved! Check it out at /app/pcmasterrace/my_dad_has_been_playing_civilization_almost_daily.md.

---
Thanks for using this script!
Something's not working as expected? Have a feature you'd like to see added? Let me know by opening an issue on GitHub at https://github.com/chauduyphanvu/reddit-markdown/issues.

image

chauduyphanvu commented 8 months ago

Thanks for this! I have zero experience with Docker so I'm going to trust you.

Actually, could you modify the PR to add the instructions themselves to the README (make a new section just for Docker)? Otherwise what you wrote in the PR description can be hard to find.

nathanpovo commented 8 months ago

add the instructions themselves to the README

Will do

nathanpovo commented 8 months ago

@chauduyphanvu would it be possible for the default value of the default_save_location to be changed from the current value of "DEFAULT_REDDIT_SAVE_LOCATION" to "".

It would make it easier for any users of the docker container since the current default error throws an error if it is left as it is.

Is there any benefit of using the current default value? The script asks you what location you want to use anyway if you use "" as the default value so I did not get the point. Admittedly, I never used the script directly so I am not sure if it would offer any benefits in that situation.