Skip to content

rharish101/dilbert-viewer

Repository files navigation

Dilbert Viewer

Tests Deployment

A simple comic viewer for Dilbert by Scott Adams, hosted on Heroku here. It uses the third-party Rust Buildpack with the Heroku Redis add-on for caching.

Setup

The Heroku CLI is used to locally run the code as specified in the Procfile. To install the Heroku CLI, please refer to Heroku's installation guide for recommended installation options.

Recommendation:

If you have a memory limit on your Redis database (like Heroku does), configure Redis to evict keys using the allkeys-lru policy. To configure this with Heroku's Redis addon, run the following:

heroku redis:maxmemory -a app-name --policy allkeys-lru

Here, app-name is the name of your Heroku app that has a Redis database configured.

Running

Build the project in release mode:

cargo build --release

Then, set the required environment variables and run the viewer locally with the Heroku CLI:

REDIS_TLS_URL=$(heroku config:get REDIS_TLS_URL -a app-name) heroku local web

Here, app-name is the name of your Heroku app that has a Redis database configured. You can also replace the value of this environment variable with a URL to your custom Redis database.

If you want to run the viewer without a Redis database, then simply run it without the environment variable:

heroku local web

To set the log level of the viewer, set the RUST_LOG environment variable according to this specification. For example, to view all logs at or above the DEBUG level, run:

RUST_LOG=debug heroku local web

Contributing

pre-commit is used for managing hooks that run before each commit (such as clippy), to ensure code quality. Thus, this needs to be set up only when one intends to commit changes to git.

Firstly, install pre-commit itself. Next, install pre-commit hooks:

pre-commit install

For testing your changes using the provided test suite, run all tests as follows:

cargo test

Licenses

This repository uses REUSE to document licenses. Each file either has a header containing copyright and license information, or has an entry in the DEP5 file at .reuse/dep5. The license files that are used in this project can be found in the LICENSES directory.

A copy of the AGPL-3.0-or-later license is placed in LICENSE, to signify that it constitutes the majority of the codebase, and for compatibility with GitHub.