website-screenshot

Rust: 1.62+ Continuous Delivery Continuous Integration

📸 website screenshots as a service

Features

Deployment

Prerequisites

Environment Variables

Railway

Deploy on Railway

Changing Providers

To change the provider in railway:

  1. Open the repo that railway made for you.
  2. Open the Dockerfile
  3. Edit lines 39 and 44 with fleet build --release --no-default-features --features <your_provider>.
  4. Deploy your app again.

Pre-built Binaries

⚠️- You can't change the provider when using the pre-built binaries.

Linux

sh curl -fsSL https://raw.githubusercontent.com/devtomio/website-screenshot/main/install.sh

Other

See the Releases page of this repository and download the appropriate binary.

Docker

⚠️- You can't change the provider when using the docker image.

A dockerized version of this application is available here.

Cargo

Installing website-screenshot as a crate.

sh cargo install website-screenshot

Building from source

  1. Clone this repository. e.g. git clone https://github.com/devtomio/website-screenshot
  2. Build the binary cargo build --release

Authentication

Authentication will be enabled if the AUTH_TOKEN variable is set.

It will check if the Authorization header sent by the user is equal to the AUTH_TOKEN that you set.

Storage Providers

Fs (Filesystem) Provider

📝 - This is the default provider.

Build Command

sh cargo build --release

[Cloudinary] Provider

📝 - You must make an unsigned upload preset.

Environment Variables

Build Command

sh cargo build --release --no-default-features --features cloudinary_provider

Amazon AWS [S3] Provider

⚠️ - This is untested. If you encounter a bug please don't hesitate to open an issue.

Environment Variables

Self-hosted S3 Storage

To use a self-hosted S3 Storage, set the S3_ENDPOINT_URL environment variable to the endpoint url.

Build Command

sh cargo build --release --no-default-features --features s3_provider

[Tixte] Provider

Environment Variables

Build Command

sh cargo build --release --no-default-features --features tixte_provider

[Sled] Provider

Environment Variables

Build Command

sh cargo build --release --no-default-features --features sled_provider

Endpoints

GET /

Hello, world!

Example Response:

text Hello, world!

POST /screenshot

Creates a screenshot.

JSON payload with the url key.

Example Payload:

json { "url": "https://rust-lang.org" }

Example Response

json { "slug": "abcdefghijk", "path": "/s/abcdefghijk", "metadata": { "url": "https://rust-lang.org" } }

GET /s/:slug

Gets the screenshot that is corresponding to the slug.

Example URL

text http://localhost:3000/s/abcdefghijk

Example Response

Rust Website

License

Licensed under either of

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Tomio

💻 📖 🚇 🚧

This project follows the all-contributors specification. Contributions of any kind welcome!