version: '3'
services:
  {{freva_rest_name}}:
{% if (ansible_become == true and ansible_become_user == 'root') or ansible_user == 'root' %}
    user: {{uid}}:{{gid}}
{% else %}
    user: root:0
{% endif %}
    image: ghcr.io/freva-org/freva-rest-api:{{freva_rest_version}}
    hostname: {{freva_rest_name}}
    environment:
      - API_SOLR_CORE=files
      - API_PORT={{freva_rest_port}}
      - API_PROXY={{freva_rest_proxy_url}}
      - COLUMNS=140
      - API_OIDC_CLIENT_ID={{freva_rest_oidc_client}}
      - API_OIDC_DISCOVERY_URL={{freva_rest_oidc_url}}
      - API_OIDC_CLIENT_SECRET={{freva_rest_oidc_client_secret}}
      - API_OIDC_TOKEN_CLAIMS={{ freva_rest_oidc_token_claims }}
{% if freva_rest_data_loader == true %}
      - API_REDIS_HOST={{cache_information.host}}
      - API_REDIS_PASSWORD={{cache_information.passwd}}
      - API_REDIS_USER={{cache_information.user}}
      - API_REDIS_SSL_CERTFILE=/certs/client-cert.pem
      - API_REDIS_SSL_KEYFILE=/certs/client-key.pem
      - CACHE_CONFIG={{ cache_information_enc }}
{% endif %}
      - API_MONGO_USER={{freva_rest_db_user}}
      - API_LOGDIR=/tmp/logs
      - API_SOLR_HOST={{freva_rest_search_server_host}}:8983
      - API_MONGO_HOST={{ freva_rest_mongodb_server_host }}:27017
      - API_MONGO_PASSWORD={{freva_rest_db_passwd}}
      - API_MONGO_DB=search_stats
      - API_SERVICES={{ freva_rest_services }}
    ports:
      - {{freva_rest_port}}:{{freva_rest_port}}
    container_name: {{freva_rest_name}}
    tty: true
    volumes:
      - /var/lib/sss/pipes:/var/lib/sss/pipes:ro
      - logs:/tmp/logs:z


volumes:
    logs:
