Skip to main content

Manual

caution

PeCoReT is in an early stage of development! Do not use it in production!

This guide will walk you through the process of installation PeCoReT.

Requirements

Since we do not want to run PeCoReT as root, we need to create a new user.

useradd -m pecoret

To install PeCoReT, we need git, python and nginx installed.

apt install git python3-pip nginx

Source Code and Python Dependencies

Clone the repository somewhere. The following guide assumes you are installing into /opt.

cd /opt
git clone https://github.com/pecoret/pecoret
cd pecoret
chown pecoret:pecoret -R .

Now we need to install the python dependencies:

pip install -r server/requirements.txt && pip install gunicorn
tip

You may want to install the dependencies into a virtual environment

The configuration file (production.py) needs to be created:

su - pecoret
cd /opt/pecoret/server
cp local_settings.template.py conf/production.py
exit

At this stage, you may want to read on how to configure your installation.

Setup Database

This is an optional step, which depends on your setup and configuration. For example, if you plan to use a sqlite database, you do not need to do anything from this section. However, it is recommended to use Postgres in production environments.

su - postgres -c psql

in the Postgres console, create a new database and user:

CREATE DATABASE pecoret;
CREATE USER pecoret WITH PASSWORD 'mypasswordhere';
GRANT ALL PRIVILEGES ON DATABASE pecoret TO pecoret;
ALTER DATABASE pecoret OWNER TO pecoret;

To use postgres as a database backend, you need to install an additional dependency:

pip install psycopg2-binary

Initialize PeCoReT

In this step, we need to initialize PeCoReT and create a superuser.

su - pecoret
cd /opt/pecoret/server
python manage.py migrate
python manage.py collectstatic
python manage.py createsuperuser
exit

Systemd Service

If you want to run the PeCoReT services using systemd, you can use the following example:

/etc/systemd/system/pecoret-server.service
[Unit]
Description=PeCoReT server
After=network.target

[Service]
User=pecoret
Group=pecoret
WorkingDirectory=/opt/pecoret/server
ExecStart=gunicorn --bind 127.0.0.1:8000 pecoret.wsgi

[Install]
WantedBy=multi-user.target

An example for the worker:

/etc/systemd/system/pecoret-qcluster.service
[Unit]
Description=PeCoReT server
After=network.target

[Service]
User=pecoret
Group=pecoret
WorkingDirectory=/opt/pecoret/server
ExecStart=python3 manage.py qcluster

[Install]
WantedBy=multi-user.target

To enable the services on boot and start them, you can issue the following command:

systemctl enable --now pecoret-server
systemctl enable --now pecoret-qcluster

Install and Setup the Frontend

Follow the nodejs documentation for install instructions depending on your distribution.

su - pecoret
cd /opt/pecoret/frontend

and create an .env file with the following content

VITE_APP_API_URL=https://pecoret.example.com/api

change the URL of the API and build the frontend:

npm install
npm run build

Setup nginx

Paste a nginx config file. You may want to further hardening the TLS configuration or HTTP headers, which is not part of this guide.

server {
listen 80 default_server;
server_tokens off;
return 301 https://$host$request_uri;
}

server {
listen 443 ssl;
server_name _;
server_tokens off;

ssl_certificate /etc/ssl/yourcert.crt;
ssl_certificate_key /etc/ssl/yourcertkey.key;

ssl_protocols TLSv1.3;
ssl_prefer_server_ciphers on;
ssl_ciphers ECDH+AESGCM:ECDH+AES256:ECDH+AES128:DH+3DES:!ADH:!AECDH:!MD5;

location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

[...]
}

and start the nginx service:

systemctl enable --now nginx