Skip to content

ingeniumstudio/briefkasten-scrape

 
 

Repository files navigation

📸 Briefkasten Image Job

GitHub Workflow Status Demo

Job to periodically fetch missing bookmark screenshot cover photos. This Github Action uses Playwright to periodically fetch missing screenshots of saved Bookmarks.

See also:

🚀 Getting Started

To run this yourself, you'll need a Github account and a few environment variables. These include a DATABASE_URL to your Briefkasten database. As well as the connection details to your image hosting service, in this case ImageKit.

  1. Clone the repository
$ git clone ssh://github.com/ndom91/briefkasten-scrape
$ cd briefkasten-scrape
  1. Install dependencies
$ npm install
  1. Build Docker container
$ docker build . -t briefkasten-scrape:latest
  1. Copy .env.example to .env and edit the file .env accordingly
$ cp .env.example .env
$ vim .env

File .env.example for reference

DATABASE_URL=postgres://bkAdmin:briefkasten@postgres:5432/briefkasten?sslmode=disable

SUPABASE_KEY=
SUPABASE_URL=
SUPABASE_BUCKET_ID=

BOOKMARKS_CHUNK=5
  1. Run container
$ docker run \
  --rm \
  --name briefkasten-scrape \
  --network briefkasten_default \
  --env-file .env
  briefkasten-scrape:latest

This will execute and fetch the first 5 Bookmarks with missing cover images and attempt to capture them with Playwright. They will be uploaded to your image store of choice and then displayed for the user the next time they open their Briefkasten.

⌚ Running the container automatically via a cronjob

  1. Install your favourite cron distribution
$ sudo apt install cronie
  1. Enable and start the service
$ sudo systemctl enable cronie
$ sudo systemctl start cronie
  1. Edit your crontab
$ crontab -e

You can configure it to run each 20 minutes; for this, add the following line, and save the file:

*/20 * * * * docker run --rm --name briefkasten-scrape --network briefkasten_default --env-file /PATH/TO/YOUR/.ENV_FILE briefkasten-scrape:latest

--network is the network the briefkasten docker compose is using. Probably no need to change.

You need to edit /PATH/TO/YOUR/ENVFILE above pointing to your ENVFILE

If you want to run your cronjob on another period, you can check the respective codes in https://crontab.guru

🏗 Contributing

Open to all contributions, please stick to formatting settings in your PR though!

📝 License

MIT

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 94.5%
  • Shell 2.8%
  • Dockerfile 2.7%