# Docker Compose Deployment Files

Source: https://help.sendent.com/sendent-nextcloud-workspace/nextcloud-for-exchange/docker-compose-deployment-files

If you are deploying the Nextcloud Exchange Connector via Docker, you will need the deployment files to instruct Docker on how to build your environment.

Below are the official `.yml` configurations. You can copy the contents of the files you need, save them to your host machine with the exact filenames provided in the headings, and place them all in the same deployment directory.

## docker-compose.yml (Base Instance)

*This is the mandatory base file for all Docker deployments. It defines the primary synchronization service.*

```yaml
# Main docker-compose file

services:
  # SendentSynchronizer
  primary.sendent.synchronization.service:
    image: rg.nl-ams.scw.cloud/sendent-public/sendent-sync:latest
    # deploy:
    #   resources:
    #     limits:
    #       memory: 4G  # Memory limiting per Instance
    #     reservations:
    #       memory: 1G  # Memory reservation per Instance
    build:
      context: .
      dockerfile: Dockerfile
    restart: on-failure
    environment:
      # Nextcloud Configuration
      - Service__NextcloudConfiguration__NextcloudBaseUrl
      - Service__NextcloudConfiguration__NextcloudServiceUsername
      - Service__NextcloudConfiguration__NextcloudServicePassword
      - Service__NextcloudConfiguration__SharedSecret

      # Exchange Configuration
      - Service__ExchangeConfiguration__ExchangeType
      - Service__ExchangeConfiguration__ExchangeOnPremUrl
      - Service__ExchangeConfiguration__ExchangeOnPremDomain
      - Service__ExchangeConfiguration__ExchangeOnPremAdfsAuthorityUrl
      - Service__ExchangeConfiguration__ExchangeTenantId
      - Service__ExchangeConfiguration__ExchangeAdminRaw
      - Service__ExchangeConfiguration__ExchangeAdminFile
    
     # EventSync pair
     - EventSync__CalendarPriorityOrder__0
     - EventSync__CalendarPriorityOrder__1
     - EventSync__Pairs__0__SourceClientId
     - EventSync__Pairs__0__TargetClientId

     # EventSyncClients [0] Exchange (EWS or Graph)
     - EventSyncClients__0__Identifier
     - EventSyncClients__0__Provider
     - EventSyncClients__0__Settings__ExchangeType
     - EventSyncClients__0__Settings__TenantId
     - EventSyncClients__0__Settings__AppId
     - EventSyncClients__0__Settings__ClientSecret
     - EventSyncClients__0__Settings__OnPremUrl
     - EventSyncClients__0__Settings__OnPremDomain
     - EventSyncClients__0__Settings__UserName
     - EventSyncClients__0__Settings__Password
     - EventSyncClients__0__Settings__OnPremAdfsAuthorityUrl
     - EventSyncClients__0__Settings__ClientId
     - EventSyncClients__0__Settings__OutlookTimeZone

     # EventSyncClients [1] DAV
     - EventSyncClients__1__Identifier
     - EventSyncClients__1__Provider
     - EventSyncClients__1__Settings__BaseUrl
     - EventSyncClients__1__Settings__ServiceUsername
     - EventSyncClients__1__Settings__ServicePassword
     - EventSyncClients__1__Settings__SharedSecret
    
      # Database Configuration
      - DatabaseConfiguration__DatabaseType
      - DatabaseConfiguration__DatabaseEncryptionKey
      - DatabaseConfiguration__ConnectionString

      # Concurrency Configuration
      - Service__ConcurrencyConfiguration__MaxParallelProcessingUsers
      - Service__ConcurrencyConfiguration__MaxUsersPerAdmin

      # Service Configuration
      - Service__IsPrimary=true
      - Service__DefaultWorkerName
      - Service__BatchLimit
      - Service__WorkerIntervalSeconds
      - Service__SyncIntervalInSeconds
      - Service__CriticalSyncIntervalInSeconds
      - Service__BatchSaveSize
      - Service__StartWeekend
      - Service__SyncMode
      - Service__SyncType

      # Full Synchronization Configuration
      - Service__FullSyncConfiguration__ProcessAttachments

      # Sensitive Synchronization Configuration
      - Service__SensitiveSyncConfiguration__SensitiveTitle
      - Service__SensitiveSyncConfiguration__SensitiveCategory

      # Logging Configuration
      - Serilog__MinimumLevel__Default

      - Service__LoggingConfiguration__LogsOutput
      - Service__LoggingConfiguration__LogDirectoryPath
      - Service__LoggingConfiguration__LogFileSizeLimit
      - Service__LoggingConfiguration__LogFileAmountLimit
      # Configuration for Loki
      - Service__LoggingConfiguration__LokiInternalUrl

    volumes:
      - sendent-logs:/app/logs
      - ./exchangeAdmins:/app/settings

volumes:
  sendent-logs:
    driver: local
```

## docker-compose.multiinstances.yml

*Use this override file only if you are deploying a Multi-Instance architecture. It defines the secondary worker replicas.*

```yaml
# Multiinstances  override
# docker compose -f docker-compose.yml -f docker-compose.multiinstances.yml up

services:
  secondary.sendent.synchronization.service:
    image: rg.nl-ams.scw.cloud/sendent-public/sendent-sync:latest
    deploy:
      replicas: ${Secondary_Replicas_Amount:-0} # Amount of instances
    #   resources:
    #     limits:
    #       memory: 4G  # Memory limiting per Instance
    #     reservations:
    #       memory: 1G  # Memory reservation per Instance
    build:
      context: .
      dockerfile: Dockerfile
    restart: on-failure
    environment:
      # Nextcloud Configuration
      - Service__NextcloudConfiguration__NextcloudBaseUrl
      - Service__NextcloudConfiguration__NextcloudServiceUsername
      - Service__NextcloudConfiguration__NextcloudServicePassword
      - Service__NextcloudConfiguration__SharedSecret

      # Exchange Configuration
      - Service__ExchangeConfiguration__ExchangeType
      - Service__ExchangeConfiguration__ExchangeOnPremUrl
      - Service__ExchangeConfiguration__ExchangeOnPremDomain
      - Service__ExchangeConfiguration__ExchangeOnPremAdfsAuthorityUrl
      - Service__ExchangeConfiguration__ExchangeTenantId
      - Service__ExchangeConfiguration__ExchangeAdminRaw
      - Service__ExchangeConfiguration__ExchangeAdminFile

      # EventSync pair
      - EventSync__CalendarPriorityOrder__0
      - EventSync__CalendarPriorityOrder__1
      - EventSync__Pairs__0__SourceClientId
      - EventSync__Pairs__0__TargetClientId
    
      # EventSyncClients [0] Exchange (EWS or Graph)
      - EventSyncClients__0__Identifier
      - EventSyncClients__0__Provider
      - EventSyncClients__0__Settings__ExchangeType
      - EventSyncClients__0__Settings__TenantId
      - EventSyncClients__0__Settings__AppId
      - EventSyncClients__0__Settings__ClientSecret
      - EventSyncClients__0__Settings__OnPremUrl
      - EventSyncClients__0__Settings__OnPremDomain
      - EventSyncClients__0__Settings__UserName
      - EventSyncClients__0__Settings__Password
      - EventSyncClients__0__Settings__OnPremAdfsAuthorityUrl
      - EventSyncClients__0__Settings__ClientId
      - EventSyncClients__0__Settings__OutlookTimeZone
    
      # EventSyncClients [1] DAV
      - EventSyncClients__1__Identifier
      - EventSyncClients__1__Provider
      - EventSyncClients__1__Settings__BaseUrl
      - EventSyncClients__1__Settings__ServiceUsername
      - EventSyncClients__1__Settings__ServicePassword
      - EventSyncClients__1__Settings__SharedSecret

      # Database Configuration
      - DatabaseConfiguration__DatabaseType
      - DatabaseConfiguration__DatabaseEncryptionKey
      - DatabaseConfiguration__ConnectionString

      # Concurrency Configuration
      - Service__ConcurrencyConfiguration__MaxParallelProcessingUsers
      - Service__ConcurrencyConfiguration__MaxUsersPerAdmin

      # Service Configuration
      - Service__IsPrimary=false
      - Service__DefaultWorkerName
      - Service__BatchLimit
      - Service__WorkerIntervalSeconds
      - Service__SyncIntervalInSeconds
      - Service__CriticalSyncIntervalInSeconds
      - Service__BatchSaveSize
      - Service__StartWeekend
      - Service__SyncMode
      - Service__SyncType

      # Full Synchronization Configuration
      - Service__FullSyncConfiguration__ProcessAttachments

      # Sensitive Synchronization Configuration
      - Service__SensitiveSyncConfiguration__SensitiveTitle
      - Service__SensitiveSyncConfiguration__SensitiveCategory

      # Logging Configuration
      - Serilog__MinimumLevel__Default

      - Service__LoggingConfiguration__LogsOutput
      - Service__LoggingConfiguration__LogDirectoryPath
      - Service__LoggingConfiguration__LogFileSizeLimit
      - Service__LoggingConfiguration__LogFileAmountLimit
      # Configuration for Loki
      - Service__LoggingConfiguration__LokiInternalUrl

    volumes:
      - sendent-logs:/app/logs
      - ./exchangeAdmins:/app/settings
    depends_on:
      primary.sendent.synchronization.service:
        condition: service_started
```

## docker-compose.postgres.yml

*Use this file if you want Docker to host a local PostgreSQL database container for you.*

```yaml
# Postgres override
# docker compose -f docker-compose.yml -f docker-compose.postgres.yml up

services:
  postgres_db:
    image: postgres:15
    container_name: postgres_db
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: <replace_with_password>
      POSTGRES_DB: SendentDB
    ports:
      - '5432:5432'
    healthcheck:
      test: ['CMD-SHELL', 'pg_isready -U postgres -d SendentDB']
      interval: 5s
      timeout: 5s
      retries: 5

  primary.sendent.synchronization.service:
    depends_on:
      postgres_db:
        condition: service_healthy
```

## docker-compose.mysql.yml

*Use this file if you want Docker to host a local MySQL database container for you.*

```yaml
# MySQL override
# docker compose -f docker-compose.yml -f docker-compose.mysql.yml up

services:
  mysql_db:
    image: mysql:8.4
    container_name: mysql_db
    environment:
      MYSQL_ROOT_PASSWORD: '<replace_with_password>'
      MYSQL_DATABASE: 'SendentDB'
    ports:
      - '3306:3306'
    healthcheck:
      test:
        [
          'CMD-SHELL',
          "mysqladmin ping -h localhost -uroot -p'<replace_with_password>' || exit 1",
        ]
      interval: 10s
      timeout: 5s
      retries: 10
      start_period: 15s

  primary.sendent.synchronization.service:
    depends_on:
      mysql_db:
        condition: service_healthy

```

## docker-compose.mariadb.yml

*Use this file if you want Docker to host a local MariaDB container for you.*

```yaml
# MariaDB override
# docker compose -f docker-compose.yml -f docker-compose.mariadb.yml up

services:
  maria_db:
    image: mariadb:10.11
    command: ['--max-allowed-packet=128M', '--innodb-buffer-pool-size=512M']
    container_name: maria_db
    environment:
      MARIADB_ROOT_PASSWORD: <replace_with_password>
      MARIADB_DATABASE: SendentDB
    ports:
      - '3306:3306'
    healthcheck:
      test: ['CMD', 'healthcheck.sh', '--connect', '--innodb_initialized']
      interval: 5s
      timeout: 5s
      retries: 10

  primary.sendent.synchronization.service:
    depends_on:
      maria_db:
        condition: service_healthy
```

## docker-compose.sqlserver.yml

*Use this file if you want Docker to host a local Microsoft SQL Server container for you.*

```yaml
# SQL Server override
# docker compose -f docker-compose.yml -f docker-compose.sqlserver.yml up

services:
  mssql_db:
    image: mcr.microsoft.com/mssql/server:2022-latest
    container_name: mssql_db
    environment:
      SA_PASSWORD: '<replace_with_password>'
      ACCEPT_EULA: 'Y'
    ports:
      - '1433:1433'
    healthcheck:
      test:
        [
          'CMD-SHELL',
          "/opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P '<replace_with_password>' -C -Q 'SELECT 1' || exit 1",
        ]
      interval: 10s
      timeout: 5s
      retries: 10
      start_period: 15s

  primary.sendent.synchronization.service:
    depends_on:
      mssql_db:
        condition: service_healthy
```

## docker-compose.grafana.yml

*Use this file if you are enabling Grafana and Loki for advanced log visualization.*

```yaml
# Loki&Grafana override
# docker compose -f docker-compose.yml -f docker-compose.grafana.yml up

services:
  # Logger Services
  loki:
    image: grafana/loki:latest
    ports:
      - '127.0.0.1:3100:3100'
    command: -config.file=/etc/loki/local-config.yaml

  grafana:
    image: grafana/grafana:latest
    ports:
      - '127.0.0.1:3000:3000'
    environment:
      - GF_SECURITY_ADMIN_USER=${GRAFANA_USER}
      - GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_PASSWORD}
    volumes:
      - ./grafana/provisioning/datasources:/etc/grafana/provisioning/datasources
      - ./grafana/provisioning/dashboards:/etc/grafana/provisioning/dashboards
    depends_on:
      loki:
        condition: service_started

  # SendentSynchronizer
  primary.sendent.synchronization.service:
    depends_on:
      loki:
        condition: service_started
```
