Build Kibou from source
Toromino edited this page 3 months ago

Prerequirements

Dependencies

  • build-essential
  • diesel_cli
  • libpq-dev
  • libssl-dev
  • postgresql
  • rust (>=1.24)

Optional software

  • git (to clone & update Kibou)
  • nginx (or any different webserver which supports reverse proxys)
  • certbot (if you plan to create a Let’s Encrypt certificate)

Server requirements

  • 256 megabytes of RAM (or more)
  • a decent network connection
  • a domain name, with the ability to add an A record (if you want to use a domain)

Installation

Preperation

Before you start installing Kibou, make sure your system is up-to-date.

On Debian-based distributions

apt update && apt upgrade

Now some of the mentioned dependencies have to be installed.

On Debian-based distributions

apt install build-essential libssl-dev postgresql

Rust

Installation

To ensure you are running the latest version of Rust, install Rust via their rustup script.

curl -sf -L https://static.rust-lang.org/rustup.sh | sh

Currently Kibou requires Rust’s nightly branch, make sure you switch to nightly

rustup default nightly

Diesel-CLI

Installation

Diesel-CLI will be used to run database migrations, it can be installed using Cargo.

cargo install diesel_cli --no-default-features --features "postgres"

Kibou

System user

It is recommended to use a dedicated system user for Kibou.

useradd kibou

Deployment

Create a folder dedicated to Kibou, and grant the Kibou system user rights to this folder

mkdir /srv/kibou
chown -R kibou:kibou /srv/kibou

Using the Kibou system user, clone Kibou’s repository to it’s new dedicated folder

git clone https://git.cybre.club/kibouproject/kibou.git /srv/kibou

Setup

Switch to Kibou’s directory and compile Kibou (this might take a while).

cd /srv/kibou
cargo build --release

Configuration

Copy the example configuration (env.sample.toml) to either env.development.toml or env.production.toml and change it according to your needs.

cp env.sample.toml env.production.toml
nano env.production.toml

Database preperations

Now create a new postgres database, it’s called kibou_dev in this example. Create a new postgres user for Kibou and specify a safe password. Grant this user all priveleges for the newly created database.

sudo -u postgres psql
create database kibou_dev;
create user kibou with encrypted password '{YOUR_PASSWORD}';
grant all privileges on database kibou_dev to kibou;
\q

Copy the command below and change some parameters according to your postgres credentials. This .env file is needed for Diesel_CLI

echo DATABASE_URL=postgres://kibou:{YOUR_PASSWORD}@localhost/kibou_dev > .env

Now run the initial migrations

~/.cargo/bin/diesel migration run

Set up a (systemd) service

Systemd

You first need to create your kibou service file.

nano /etc/systemd/system/kibou.service

Now copy the contents of the example file kibou.service and change it according to your needs.