---
title: Platform and services installation
description: Installation of the IoT platform — downloading images, Docker setup, system install, updates and autostart configuration.
weight: 1
---

import Tabs from '@/components/docs/Tabs.astro';
import Steps from '@/components/docs/Steps.astro';
import FileTree from '@/components/docs/FileTree.astro';
import Image from '@/components/docs/Image.astro';
import Alert from '@/components/docs/Alert.astro';
import Details from '@/components/docs/Details.astro';

## Installation files download

There are two ways to download the installation images of the "Secure IoT Telemetry Data Acquisition and Processing Platform":

<Tabs labels={['Downloading from external media', 'Downloading via the Internet']}>
  <Fragment slot="panel-0">
    In the case when the server is not connected to the Internet (for example, according to the
    enterprise security policy), it is possible to install the "Secure IoT Platform for Telemetry
    Data Collection and Processing" system offline. In this case, the installation images of the
    system are transferred to the server from an external media.
  </Fragment>
  <Fragment slot="panel-1">
    If the server is connected to the Internet, the system installation images are uploaded to the
    server via a remote repository.
  </Fragment>
</Tabs>

## Installation steps

<Steps>

### Copy the required data package

To install the containerization tool it is necessary to execute the commands (administrator rights will be required):

- It is necessary to copy the downloaded `unicloud.tgz` archive to the user's root folder. Copy the `images` folder (standalone installation package of the system with archived images) to the root folder of the user. The archive also contains configuration files `docker-compose.yml` and `.env` (hidden, it is necessary to display hidden files).

<FileTree
  tree={[
    {
      name: 'images',
      children: [
        { name: 'vadtel-nginx-latest.tar.gz' },
        { name: 'vadtel-app-latest.tar.gz' },
        { name: 'anytelemetry-latest.tar.gz' },
        { name: 'pgbouncer-latest.tar.gz' },
        { name: 'vadteljsondaemon-latest.tar.gz' },
        { name: 'logrotate-latest.tar.gz' },
        { name: 'postgres-15.1-alpine.tar.gz' },
        { name: 'redis-6.0.16-alpine.tar.gz' },
        { name: 'vector-latest.tar.gz' },
      ],
    },
  ]}
/>

- The configuration files should be copied to `/opt/vadtelnewweb/`.

- Logins and passwords to the system must be specified in the `.env` file:

```bash title=".env"
#key
SECRET_KEY_BASE=0356080kcn0ejgk4lwekrf

#DB PGSQL login
PG_APP_USER=ppppp

#DB PGSQL password
PG_APP_PASSWORD= ppppp

#WEB interface login
VADTEL_SUPER_ADMIN_EMAIL=NEED_USERNAME

#WEB interface password
VADTEL_SUPER_ADMIN_PASSWORD=NEED_PASSWORD

#DB PGSQL unicloud login
VADTEL_UNICLOUD_TEST_USERNAME=NEED_USERNAME

#DB PGSQL unicloud password
VADTEL_UNICLOUD_TEST_PASSWORD=NEED_PASSWORD
```

### Installing Docker and Docker Compose

#### Installing Docker and Docker Compose on the CentOS distribution.

Install Docker and Docker Compose:

```bash
sudo dnf install docker-ce docker-compose
```

```text title="Expected output"
Dependencies resolved.
Installing:
  docker-ce
  docker-compose

Transaction Summary
Install  2 Packages

Is this ok [y/N]: y

Downloading Packages...
Running transaction...

Complete!
```

Run and add Docker to autoloader:

```bash
sudo systemctl enable --now docker && systemctl start docker
```

#### Installing Docker and Docker Compose on an Debian distribution

Install Docker and Docker Compose:

```bash
sudo apt update
sudo apt install docker docker-compose
```

```text title="Expected output"
Reading package lists... Done
Building dependency tree... Done
The following NEW packages will be installed:
  docker docker-compose

Do you want to continue? [Y/n] y

Setting up docker ...
Setting up docker-compose ...
Processing triggers for man-db ...
```

### System Installation

Next, the system installation does not differ for different operating systems. Add the user under which the application will run to the docker group:

```bash
sudo usermod -aG docker ${USER}
```

<Alert type="warning">
  After running this command, to apply permissions, you must terminate the session and log in again.
</Alert>

Next, unpack the `unicloud.tgz` archive copied to the user's root folder and run the following command:

```bash
tar -xf unicloud.tgz
```

<FileTree
  tree={[
    {
      name: 'unicloud',
      children: [
        {
          name: 'run',
          state: 'closed',
          children: [{ name: 'db-unicloud', type: 'folder', state: 'closed' }],
        },
        { name: 'remote_install.sh' },
        { name: 'init-db', children: [{ name: 'create_tables.sql' }] },
        { name: 'script_conf.sh' },
        { name: 'docker-compose.yml' },
        {
          name: 'logs',
          state: 'closed',
          children: [
            { name: 'crontab', type: 'folder', state: 'closed' },
            { name: 'vadteljsondaemon', type: 'folder', state: 'closed' },
            { name: 'anytelemetry', type: 'folder', state: 'closed' },
          ],
        },
        { name: 'backups', type: 'folder', state: 'closed' },
        {
          name: 'data',
          state: 'closed',
          children: [{ name: 'db-unicloud', type: 'folder', state: 'closed' }],
        },
        {
          name: 'local-images',
          children: [
            { name: 'pgbouncer.tar.gz' },
            { name: 'postgres.tar.gz' },
            { name: 'vadteljsondaemon.tar.gz' },
            { name: 'anytelemetry.tar.gz' },
            { name: 'logrotate.tar.gz' },
          ],
        },
        { name: 'unicloud.service' },
      ],
    },
  ]}
/>

After executing the command, go to the unzipped `unicloud` folder in the user's root folder and run the script:

```bash
sudo ./remote_install.sh
```

```text title="Expected output"
Reading package lists... Done
Building dependency tree... Done
Created symlink /etc/systemd/system/multi-user.target.wants/unicloud.service
  -> /lib/systemd/system/unicloud.service
Packet successfully installed. Database credentials saved to the .env file
```

After successful installation of the package, go to the `/var/lib/unicloud` folder with administrator privileges, and change the Owner Name and Group Name to the current user for the `.env` file

The script generates access — login, password to the database `/var/lib/unicloud/.env`, which must be specified in the file `/opt/vadtelnewweb/.env`.

These are the values:

```bash
VADTEL_UNICLOUD_TEST_USERNAME=NEED_USERNAME

VADTEL_UNICLOUD_TEST_PASSWORD=NEED_PASSWORD
```

### Extracting and downloading images

Unzip the previously copied folder with `images` image files

```bash
gunzip vadtel-nginx-latest.tar.gz
gunzip vadtel-app-latest.tar.gz
gunzip anytelemetry-latest.tar.gz
gunzip pgbouncer-latest.tar.gz
gunzip vadteljsondaemon-latest.tar.gz
gunzip logrotate-latest.tar.gz
gunzip postgres-15.1-alpine.tar.gz
gunzip redis-6.0.16-alpine.tar.gz
gunzip vector-latest.tar.gz
```

Uploading images to Docker:

```bash
docker load -i vadtel-nginx-latest.tar
docker load -i vadtel-app-latest.tar
docker load -i anytelemetry-latest.tar
docker load -i pgbouncer-latest.tar
docker load -i vadteljsondaemon-latest.tar
docker load -i logrotate-latest.tar
docker load -i postgres-15.1-alpine.tar
docker load -i redis-6.0.16-alpine.tar
docker load -i vector-latest.tar.gz
```

```text title="Expected output"
Loaded image: vadtel-nginx:latest
Loaded image: vadtel-app:latest
Loaded image: anytelemetry:latest
Loaded image: pgbouncer:latest
Loaded image: vadteljsondaemon:latest
Loaded image: logrotate:latest
Loaded image: postgres:15.1-alpine
Loaded image: redis:6.0.16-alpine
Loaded image: vector:latest
```

Check if the images are available:

```bash
docker images
```

```text title="Output structure"
REPOSITORY          TAG
vadtel-nginx        latest
vadtel-app          latest
anytelemetry        latest
pgbouncer           latest
vadteljsondaemon    latest
logrotate           latest
postgres            15.1-alpine
redis               6.0.16-alpine
vector              latest
```

If the images loaded without errors, being in the `/var/lib/unicloud` folder, run the following command:

```bash
docker-compose up -d
```

Create a directory in the `/opt` folder for the `vadtelnewweb` application

```bash
sudo mkdir /opt/vadtelnewweb
cd /opt/vadtelnewweb
```

After that, it is necessary to copy `docker-compose.yml` and `.env` files (if not copied earlier for a new installation) to the `/opt/vadtelnewweb` folder.

For the first run, it is necessary to create a Database, for this purpose execute the following command:

```bash
docker-compose run app bundle exec rails db:create
```

```text title="Expected output"
Creating <project>_db_1    ... done
Creating <project>_app_run ... done
Created database '<database_name>'
```

Now we can run the application:

```bash
docker-compose up -d
```

```text title="Expected output"
Creating network "unicloud_unicloud-net" ... done
Creating <project>_db_1                  ... done
Creating <project>_app_1                 ... done
Creating <project>_nginx_1               ... done
```

<Details title="Troubleshooting">
If an error occurs after running the application:

```bash
network unicloud_unicloud-net declared as external, but could not be found
```

This means that the external network was not created during installation, so you need to perform the initial installation from the `unicloud.tar.tgz` archive, according to [instructions](#system-installation).

After that, you need to re-run the application:

```bash
docker-compose up -d
```

</Details>

To check for running containers, execute the following command:

```bash
docker ps
```

```text title="Output structure"
CONTAINER ID   IMAGE          STATUS         PORTS                  NAMES
<id>           vadtel-nginx   Up <uptime>    0.0.0.0:80->80/tcp     <project>_nginx_1
<id>           vadtel-app     Up <uptime>                           <project>_app_1
<id>           postgres       Up <uptime>    5432/tcp               <project>_db_1
```

### Software Update

To upgrade the software, you need to shut down the containers by going to `/opt/vadtelnewweb`, and executing the following command:

```bash
docker-compose down
```

Then, navigate to the `/var/lib/unicloud` folder to perform the following actions:

- Stop the `unicloud` service:

```bash
sudo service unicloud stop
```

- Shutting down the containers:

```bash
docker-compose down
```

Next, copy and unpack the necessary compressed image files:

```bash
gunzip vadtel-nginx-latest.tar.gz
gunzip vadtel-app-latest.tar.gz
gunzip anytelemetry-latest.tar.gz
gunzip pgbouncer-latest.tar.gz
gunzip vadteljsondaemon-latest.tar.gz
gunzip logrotate-latest.tar.gz
gunzip postgres-15.1-alpine.tar.gz
gunzip redis-6.0.16-alpine.tar.gz
gunzip vector-latest.tar.gz
```

Load images into Docker:

```bash
docker load -i vadtel-nginx-latest.tar
docker load -i vadtel-app-latest.tar
docker load -i anytelemetry-latest.tar
docker load -i pgbouncer-latest.tar
docker load -i vadteljsondaemon-latest.tar
docker load -i logrotate-latest.tar
docker load -i postgres-15.1-alpine.tar
docker load -i redis-6.0.16-alpine.tar
docker load -i vector-latest.tar.gz
```

```text title="Expected output"
Loaded image: vadtel-nginx:latest
Loaded image: vadtel-app:latest
Loaded image: anytelemetry:latest
Loaded image: pgbouncer:latest
Loaded image: vadteljsondaemon:latest
Loaded image: logrotate:latest
Loaded image: postgres:15.1-alpine
Loaded image: redis:6.0.16-alpine
Loaded image: vector:latest
```

Checking the availability of images:

```bash
docker images
```

```text title="Output structure"
REPOSITORY          TAG
vadtel-nginx        latest
vadtel-app          latest
anytelemetry        latest
pgbouncer           latest
vadteljsondaemon    latest
logrotate           latest
postgres            15.1-alpine
redis               6.0.16-alpine
vector              latest
```

If the images loaded without errors, while in the `/var/lib/unicloud` folder, run the following command:

```shell
sudo service unicloud start
docker-compose up -d
```

Next, you need to go to the folder `/opt/vadtelnewweb` and run the application:

```shell
docker-compose up -d
```

To check running containers, run the following command:

```bash
docker ps
```

### Configuring autoload

Create/edit/copy the configuration file `/etc/docker/daemon.json` and add the following to it (replacing values if necessary):

```json title="daemon.json"
{
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "50m",
    "max-file": "3"
  }
}
```

Then we create a script for autostarting the application, for which we will need a file `docker-compose-vadtel.service` with the contents given below, where `WorkingDirectory` is the path to `docker-compose.yml`

Execute command:

```shell
nano /etc/systemd/system/docker-compose-vadtel.service
```

```ini title="docker-compose-vadtel.service"
[Unit]
Description=Docker Compose vadtel Application Service
Requires=docker.service
After=docker.service
StartLimitIntervalSec=60

[Service]
WorkingDirectory=/opt/vadtelnewweb
ExecStart=/usr/bin/docker-compose up
ExecStop=/usr/bin/docker-compose down
TimeoutStartSec=0
Restart=on-failure
StartLimitBurst=3

[Install]
WantedBy=multi-user.target
```

In order to activate the autorun script from the `/etc/systemd/system/` directory, execute the command:

```shell
sudo systemctl enable docker-compose-vadtel
```

### System health check

After launching the application, in order to check the system operability, it is necessary to enter the IP address of the server where the application is running in the browser address bar:

```bash
http://127.0.0.1/auth/users/sign_in
```

<Image src="/images/deployment/step-06-login-en.webp" alt="Platform sign-in page" />

Login and password for signing in to the system are specified in the file `/opt/vadtelnewweb/.env`

```shell title=".env"
VADTEL_SUPER_ADMIN_EMAIL= (login)
VADTEL_SUPER_ADMIN_PASSWORD= (password)
```

</Steps>
