Skip to content

Installation

This guide covers the core installation steps for LabID server components.

Prerequisites

Before starting, ensure you have completed the Prerequisites checklist.

1. System Preparation

Create a dedicated user and directory structure:

sudo useradd -m -s /bin/bash labid
sudo mkdir -p /opt/labid
sudo chown labid:labid /opt/labid

Note: This user account will need to have read and write (for dropbox functionality) to any StorageVolume you want LabID to manage.

2. Database Setup

Install and configure PostgreSQL:

# Install PostgreSQL
# If you are using a RHEL distribution like CentOS, replace "apt" with "yum" in the following commands
sudo apt update
sudo apt install postgresql postgresql-contrib postgresql-server

# start the postgres server
sudo -u postgres postgresql-setup --initdb
systemctl enable postgresql
systemctl start postgresql

# Create database and user
# mind the semi-column at the end of each command
# replace <password> with a custom value, keeping the single-quotes
sudo -u postgres psql
CREATE DATABASE labid_prod;
CREATE USER labid WITH PASSWORD '<password>';
GRANT ALL PRIVILEGES ON DATABASE labid_prod TO labid;

\q

3. Application Installation

Clone and set up the application:

# install git if not already installed
# here too use yum instead of apt on RHEL distrib
sudo apt install git

sudo -u labid -i

cd /opt/labid
git clone https://gitlab.com/lab-integrated-data/labid-server.git .

# we recommend using the production branch
git checkout production

# Install conda/mamba if not available
# Follow: https://mamba.readthedocs.io/en/latest/installation/mamba-installation.html
# Create and activate environment
conda env create --name labid -f requirements/environment.yml
conda activate labid

4. Basic Configuration

Create the initial environment configuration file /opt/labid/labid/.env as below. For DJANGO_DATABASE_URL replace <your_secure_password> with the password entered in Step 2, when creating the labid postgres user

DJANGO_SETTINGS_MODULE=labid.settings.production
DJANGO_SECRET_KEY=<your_very_long_secret_key_here>
DJANGO_DATABASE_URL=postgres://labid:<your_secure_password>@localhost:5432/labid_prod
DJANGO_ALLOWED_HOST=*  # modify accordingly
DJANGO_BASE_URL=https://your-labid.com
DJANGO_UI_BASE_URL=https://your-labid.com

Configuration Details

For comprehensive configuration options, see the Configuration Guide.

5. Database Migration and Setup

Initialize the database:

cd /opt/labid

# assuming you're in the root of the project
# To build with the UI you need to install nodejs, use "nvm" to do that
$ ./setup.sh
# without UI
$ ./setup.sh -b

This script will:

  • Run database migrations
  • Create a superuser account (username: admin, password: admin)
  • Set up initial data structures

6. Message Broker Setup

Install and configure RabbitMQ:

# Install RabbitMQ
# For RHEL distributions (CentOS...), rabbitmq-server cannot be installed via the traditional package manager (yum...)
# Follow the instructions at https://www.rabbitmq.com/docs/install-rpm
sudo apt install rabbitmq-server

# Configure using provided scripts
cd /opt/labid/deploy/rabbitmq
sudo ./configure.sh

7. Process Management - Systemd

Set up systemd services for process management:

# Copy configuration files
sudo cp /opt/labid/deploy/systemd/*.service /etc/systemd/system/
sudo cp /opt/labid/deploy/systemd/*.socket /etc/systemd/system/
sudo cp /opt/labid/deploy/systemd/labid.conf /etc/systemd/system/
sudo cp /opt/labid/deploy/systemd/systemd_tmpfiles.conf /etc/tmpfiles.d/labid.conf

# IMPORTANT: Edit service files to match your installation paths
# The provided systemd files use '/opt/labid-server' paths - update to '/opt/labid'
sudo nano /etc/systemd/system/labid-gunicorn.service
# Update: WorkingDirectory=/opt/labid/labid
# Update: User=labid (and Group as appropriate)
# Update: EnvironmentFile=/opt/labid/deploy/systemd/labid.conf

# Repeat for other service files:
# - labid-celery-worker.service
# - labid-celery-worker_archive.service
# - labid-celery-worker_ingestion.service
# - labid-celery-beat.service
# - labid-rabbitmq.service

# Enable and start services
sudo systemctl daemon-reload
sudo systemctl enable labid labid-rabbitmq labid-gunicorn labid-gunicorn.socket labid-celery-beat labid-celery-worker labid-celery-worker_archive labid-celery-worker_ingestion
sudo systemctl start labid

# Check status
sudo systemctl status labid

Alternative Process Management

While systemd is recommended, supervisord configurations are also available in the deploy directory.

8. Log Rotation

Configure log rotation to manage application logs:

sudo cp /opt/labid/deploy/logrotate/labid.conf /etc/logrotate.d/labid

Verification

After completing the installation steps:

  1. Check that all systemd services are running:

    sudo systemctl status labid labid-rabbitmq labid-gunicorn labid-celery-beat labid-celery-worker
    

  2. Verify database connectivity:

    sudo -u labid -i
    cd /opt/labid/labid
    python manage.py check --database default
    

  3. Test the application backend:

    curl http://localhost:8000/api/v2/version
    

Next Steps

Reference