website-screenshot
February 23, 2023 ยท View on GitHub
๐ธ website screenshots as a service
Features
- ๐ซ powered by Rust
- ๐ blazing fast
- ๐ฎโโโโโโ built-in ratelimiter
- ๐ built-in storage providers
- ๐ก๏ธ built-in authentication
- ๐ผ configurable
Deployment
Prerequisites
- Rust 1.61 or greater
- Redis 6 or greater
- Chrome browser
- Chromedriver (must match with the version your Chrome browser)
Environment Variables
PORT- the port that the application will run (optional, defaults to3000)REDIS_URL- the address of your redis database (required)FULLSCREEN_SCREENSHOT- if set, it will screenshot the whole website (optional)CHECK_IF_NSFW- if set, it will check if the url is marked as NSFW (optional)GOOGLE_CHROME_PATH- the path to the chrome executable (optional)CHROMEDRIVER_ADDRESS- the address on where chromedriver is listening (optional, defaults tohttp://localhost:9515)DARK_MODE- if set, it will take screenshots in dark mode, if the website supports it (optional)FORCE_NSFW_CHECK- if set, force NSFW check (optional)FORCE_DARK_MODE- if set, force dark mode (optional)CHROME_FLAGS- additional flags to provide to chrome (optional, example:--a,--b,-c)
Railway
Changing Providers
To change the provider in railway:
- Open the repo that railway made for you.
- Open the Dockerfile
- Edit lines 39 and 44 with
fleet build --release --no-default-features --features <your_provider>. - Deploy your app again.
Pre-built Binaries
โ ๏ธ- You can't change the provider when using the pre-built binaries.
Linux
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.
Building from source
- Clone this repository. e.g.
git clone https://github.com/devtomio/website-screenshot - Build the binary
cargo build --release - Start chromedriver in the background
chromedriver & - Run the app
./target/release/website-screenshot
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
cargo build --release
Cloudinary Provider
๐ - You must make an unsigned upload preset.
Environment Variables
CLOUDINARY_API_KEY- your api key (required)CLOUDINARY_UPLOAD_PRESET- the name of your unsigned upload preset (required)CLOUDINARY_CLOUD_NAME- the cloud name that you set during registration (required)
Build Command
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
S3_BUCKET_NAME- the name of your s3 bucket (required)S3_REGION- the region of your s3 bucket (required, only optional if using self-hosted s3)S3_ACCESS_KEY- your access key (required)S3_SECRET_KEY- your secret key (required)S3_SECURITY_TOKEN- your security token (optional)S3_SESSION_TOKEN- your session token (optional)
Self-hosted S3 Storage
To use a self-hosted S3 Storage, set the S3_ENDPOINT_URL environment variable to the endpoint url.
Build Command
cargo build --release --no-default-features --features s3_provider
Tixte Provider
Environment Variables
TIXTE_UPLOAD_KEY- your upload key, can be found on the integrations tab (required)TIXTE_DOMAIN_CONFIG- whether to use random domains or a specific domain (required, can only bestandard, orrandom)TIXTE_CUSTOM_DOMAIN- the specific domain to use (only required whenTIXTE_DOMAIN_CONFIGis set tostandard)
Build Command
cargo build --release --no-default-features --features tixte_provider
Sled Provider
Environment Variables
SLED_PATH- the path to provide when opening the sled database (optional, defaults to.website-screenshot)
Build Command
cargo build --release --no-default-features --features sled_provider
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
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!