Personal self-hosted website aimed to be run on an Olimex Board (OlinuXino A20).
The backend of the web service is running a compiled program written in Rust. This language was chosen for its lower memory footprint compared to other interpreted languages such as Python and Javascript. The main libraries used are Actix (web server framework) and Diesel (query builder).
The API used to communicate with the web clients is a REST API. Authentication is handled via JWT.
The frontend of the web service is a TypeScript webapp using the SolidJS framework, and bundled using Vite. SolidJS was chosen for its lower network footprint, compared to other frameworks such as React. The styling of the app is handled using vanilla-extract as a CSS-in-JS utility. The color theme is using colors from the Radix-UI Colors project.
The images placeholders are generated and presented using Blurhash.
Install postgresql, and libpq-dev
. On Fedora, run sudo dnf install libpq-devel
.
Install diesel-cli:
cargo install diesel_cli --no-default-features --features postgres
# edit the .env values as needed
cp .env.example .env
# create the "extract from" folder
mkdir .extract-from
# run migration
yarn db:migrate
# extract the pictures in the "extract from" folder.
#
# Note: It is recommended to add the `-r` (release) flag, which makes thumbnail extraction
# much faster and can be worth the overhead of extra compilation time.
cargo run -r extract-pictures
# start api server
yarn start:rs
# start frontend server
yarn start
diesel migration generate <name-of-migration>
# run migration
yarn db:migrate
# redo last migration
yarn db:migrate:redo
Run this in a shell
node -p "require('crypto').randomBytes(100).toString('base64')"
Put the result in the JWT_SECRET
env variable in .env
.
Run the server with cargo run serve --unsafe-no-jwt-checks
, and go to http://localhost:5750/admin/jwt_gen#force-admin
to get a valid admin JWT and hit the "use" button.
You can then restart the cargo server without the flag.
Updates on major versions can cause issues with postgres. Here are the steps that I followed:
- If the database isn't up, restart with
sudo systemctl restart postgres.service
- If that fails, checks the logs with
journalctl -xeu postgres.service
- If the logs mention an update, run
sudo postgresql-setup --upgrade
If the database is up but the user postgres cannot be logged in as, edit the file /var/lib/pgsql/data/pg_hba.conf
as root
and change the 2 lines that mention localhost connections from ident
to md5
.