> For the complete documentation index, see [llms.txt](https://docs.facephi.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.facephi.com/docs.facephi-en/sdks/backend-sdk/ine/installation/installation_instructions.md).

# Service installation and deployment

## 1. Installation and deployment

The service is containerized, and a Docker image is available in a Facephi repository.

```bash
docker login facephicorp.jfrog.io  
user: username
pass: token
```

```bash
docker pull facephicorp.jfrog.io/docker-pro-fphi/facephi-ine-service:#VERSION#
```

where `#VERSION#` is the specific version number to download (for example, `1.6.0`).

## 2. docker-compose

One way to deploy the service is to create a file `docker-compose.yml` with the following contents:

```yaml
version: '3.7'

services:
  ine-service:
    ports:
      - "6982:6982"
    volumes:
      - ./config:/service/config
      - ./logs:/service/logs
    image: facephicorp.jfrog.io/docker-pro-fphi/facephi-ine-service:latest
    container_name: facephi-ine-service
    environment:
      # Optional JWT protection
      # - FACEPHI_INE_REST_AUTH_ENABLED=true
      # - FACEPHI_INE_REST_AUTH_JWT_SECRET=shared-secret
      # - FACEPHI_INE_REST_AUTH_ACCEPT_AUTHORIZATION_HEADER=true
      # - FACEPHI_INE_REST_AUTH_ACCEPT_API_KEY_HEADER=true
      # - FACEPHI_INE_REST_AUTH_API_KEY_HEADER_NAME=x-api-key
```

Note the volumes mounted in the container. These volumes are used to store the service configuration files and write the logger output.

Run the following command from the folder containing the docker-compose.yml file to deploy the service:

```bash
  docker compose up -d
```

## 3. Configuration

The configuration file can contain the following information:

```json
{
    "port": 6982,                   # Service port number.
    "number_of_threads": 1,         # Number of I/O threads; defaults to 1. If the value is 0, the number of threads equals the number of CPU cores.
    "connection_timeout": 60,       # The lifetime of a connection with no reads or writes.
    "keep_alive_request_number": 0, # Sets the maximum number of requests that can be handled over a keep-alive connection.
                                    # Once the maximum number of requests is reached, the connection is closed.
                                    # The default value of 0 means unlimited.
    "client_max_body_size": 50,     # The maximum request body size, in Mb.
                                    # The default value is 100 Mb.
    "logger_path" : "/service",     # The path to the log file.
    "logger_file_prefix" : "ine",   # The file prefix used for rotated log files.
    "logger_level" : "trace",       # Sets the log level. [trace|debug|info|warn|error|fatal|off]
    "logger_rotation" : "daily",    # Sets log rotation. [hourly|daily]
    "logger_max_files" : 31,         # Sets the maximum number of log files.
    "auth_enabled": false,           # Enables or disables JWT authentication.
    "auth_jwt_secret": "",          # Shared secret used to validate HS256 JWTs.
    "auth_accept_authorization_header": true,
    "auth_accept_api_key_header": true,
    "auth_api_key_header_name": "x-api-key"
}
```

The configuration file can be passed to the service as a parameter. By default, the service will look for a file named `/service/config/config.json`.

The configuration precedence order is:

1. Environment variables `FACEPHI_INE_REST_*`
2. `config.json`
3. API default values set by the service before startup
4. Internal defaults of `Rest::Manager`

JWT authentication is optional and disabled by default.

* Public endpoints remain accessible without authentication: `GET /api/v1/health` and `GET /api/v1/version`.
* `POST /api/v1/facial/authentication` requires a valid JWT when JWT authentication is enabled.
* The service does not expose `GET/POST /config` endpoints at runtime, so JWT configuration cannot be viewed or modified through a public configuration API.

Supported JWT environment variables:

* `FACEPHI_INE_REST_AUTH_ENABLED`
* `FACEPHI_INE_REST_AUTH_JWT_SECRET`
* `FACEPHI_INE_REST_AUTH_ACCEPT_AUTHORIZATION_HEADER`
* `FACEPHI_INE_REST_AUTH_ACCEPT_API_KEY_HEADER`
* `FACEPHI_INE_REST_AUTH_API_KEY_HEADER_NAME`
