﻿# Docker Compose deployment

## Description

PVS\-Studio Atlas Server is deployed via Docker Compose in containers running 64\-bit Linux\.

The example of the `docker-compose.yml` configuration file:

```cpp
services:
  database:
    image: postgres:18.2
    platform: linux/amd64
    container_name: atlas-database
    restart: unless-stopped
    shm_size: 1g
    environment:
      - POSTGRES_DB=atlas
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=password
    volumes:
      - ./postgresql_data:/var/lib/postgresql
    ports:
      - 8081:5432
    healthcheck:
      test: pg_isready -U postgres
      interval: 30s
      start_period: 10s
      timeout: 10s
      retries: 5
  dashboard:
    image: viva64/atlas-dashboard:latest
    platform: linux/amd64
    container_name: atlas-dashboard
    restart: unless-stopped
    shm_size: 1g
    depends_on:
      database:
        condition: service_healthy
    environment:
      - "ATLAS_DB_CONNECTION_STRING=Server=database;Port=5432;\
           Username=postgres;Password=password;Database=atlas;\
           Timeout=300;CommandTimeout=300;"
      #- ATLAS_DB_CONNECTION_STRING_FILE=
      - "ATLAS_JWT_PRIVATE_TOKEN=DEMO_JWT_PRIVATE_TOKEN_\
          loH93fI6vNyL71M0bD6TmCTlZJa"
      #- ATLAS_JWT_PRIVATE_TOKEN_FILE=
      - ATLAS_SERVER_URL=http://localhost:8080
      #- ATLAS_SERVER_URL_FILE=
    volumes:
    # Store logs on the local disk outside the container
      - ./dashboard_logs:/app/logs
    # Store authorization keys on the local disk so
    # they are not lost when the container restarts
      - ./dashboard_keys:/root/.aspnet/DataProtection-Keys
    # Store root certificates
      - ./dashboard_certs:/app/certs
    # Store .pvsmap reports
      - ./storage_data:/app/storage
    ports:
      - 8080:8080
  migrator:
    image: viva64/atlas-migrator:latest
    platform: linux/amd64
    container_name: atlas-migrator
    depends_on:
      - database
    environment:
      - "ATLAS_DB_CONNECTION_STRING=Server=database;Port=5432;\
           Username=postgres;Password=password;Database=atlas;\
           Timeout=300;CommandTimeout=300;"
      #- ATLAS_DB_CONNECTION_STRING_FILE=
    profiles:
      - manual
```

## Database service

Name: **database**\.

Environment variables:

* **TZ** : a timezone used for storing dates\.
* **POSTGRES\_DB**: a database name\. Default: `atlas`\.
* **POSTGRES\_USER**: a database administrator name\. Default: `postgres`\. 
* **POSTGRES\_PASSWORD**: a database administrator password\. Default: `postgres`\.  

On the first run, the database will be created with the specified name and credentials\.

## User service

Name: **dashboard**\.

* **TZ** : a timezone used for storing dates\.
* **ATLAS\_DB\_CONNECTION\_STRING**: a connection string in Key\-Value format\.
* **ATLAS\_JWT\_PRIVATE\_TOKEN**: a JWT token\.
* **ATLAS\_SERVER\_URL**: the address of the future server\.

## How to download and run Docker images

Open the directory containing the `docker-compose.yml` configuration file and run the following commands:

```cpp
docker compose --profile manual pull
docker compose up
```

Add the `-d` parameter to run the server detached from the console:

```cpp
docker compose up -d
```

The first time, it is recommended to run the services with console output enabled to ensure the absence of errors\.

Follow the link specified in `ATLAS_SERVER_URL` and try logging in with the **admin **/ **admin **credentials\.

Once run and authentication succeed, continue setting up the server:

* [PVS\-Studio license activation](https://pvs-studio.com/en/docs/manual/7200/)
* [Project and branch management](https://pvs-studio.com/en/docs/manual/7207/)
* [Sending analysis results to the server](https://pvs-studio.com/en/docs/manual/7205/)