A command-line application that displays uv index information in your area.
⚠ This project is no longer maintained.
UV Index is a simple command line application that allows users to quickly get the UV index in their area. A common use case is to quickly determine if you will need to wear sunscreen on any given day.
- Automatic location detection based on the calling IP
- Custom sun protection recommendations based on the current uv index
- Three verbosity levels
I built uvindex
mostly as a side-project to sharpen my skills with the following technologies: Rust, Docker multi-stage builds, Terraform, and Kubernetes. I also learned how to create nice scalable svg logos using Figma to create the logo you see at the top of this README, in the docs
folder, and on uvindex.xyz.
Despite being mainly a learning project, I do use uvindex
frequently to convince my friends and family to apply sunscreen. People are often surprised by uv index and its related recommended precautions on a day that doesn't feel like a high-uv day.
To install the CLI on x86 ubuntu/debian, you can just download the latest release binary, and move it to your ~/.local/bin
folder.
On other platforms, you'll have to compile the binary yourself:
- Install Rust and Cargo
- Run
cd services/cli
- Run
cargo build --release
- Rename the file in
services/cli/target/release/uvindex-cli
touvindex
- Move this
uvindex
file to the~/.local/bin
folder
Pull requests and forks are welcome. For major changes, please open an issue first to discuss what you would like to change.
Instructions on how to set up the project for local development and on the cloud are listed below.
Set up the following environment variables
WEATHERBIT_API_KEY
: create a weatherbit account and set up an API key.OPENWEATHER_API_KEY
: create an openweather account and set up an API key.
To run the code in containers (recommended)
- Install Docker
- Install Docker-compose
- Run
make build
from the root of this repository (you only need to rebuild when a dockerfile is changed)
To run the code natively
- Install Rust and Cargo
- Run
cd services/backend
followed byrustup override set nightly
- If things are still not working, run
rustup update && cargo update
from services/backend and services/cli - set
UVINDEX_BACKEND_PROTOCOL
environment variable tohttp
- set
UVINDEX_BACKEND_HOST
environment variable tolocalhost
- set
UVINDEX_BACKEND_PORT
environment variable to3000
In containers:
make start
Natively: (from services/backend
and services/cli
)
cargo run -- <args>
This project currently runs on Google Cloud Platform (GCP), and is hence set up to quickly get deployed on GCP using terraform. Here are the (high-level) steps.
- Create a GCP project.
- Buy a domain.
- Set up a service account as per the instructions here. Give it
owner
permissions. - Set the service account email (listed in the uvindex-account.json) as a domain owner on GCP.
- Due to limitations with terraform and GCP, there is one manual step to perform on Github prior to running terraform: Enable the cloud build app from github (but don't add the build trigger manually on GCP)
- Use terraform and specify all the variables listed in the
terraform/variables.tf
file to generate everything. - Add the following roles to the cloud build service account:
Service Account User
,Cloud Run Admin
.
This project is licensed under the MIT License - see the LICENSE file for details.