services:
#  @todo Test which containers can be removed crom cental_database networks 
{% include 'roles/docker-central-database/templates/services/' + database_type + '.yml.j2' %}

{% include 'templates/docker/services/redis.yml.j2' %}

  celeryworker:
    # Celery workers handle background tasks (such file imports or federation
    # messaging). The more processes a worker gets, the more tasks
    # can be processed in parallel. However, more processes also means
    # a bigger memory footprint.
    # By default, a worker will span a number of process equal to your number
    # of CPUs. You can adjust this, by explicitly setting the --concurrency
    # flag:
    #   celery -A funkwhale_api.taskapp worker -l INFO --concurrency=4
{% include 'roles/docker-compose/templates/services/base.yml.j2' %}
    image: funkwhale/api:{{applications.funkwhale.version}}
    command: celery -A funkwhale_api.taskapp worker -l INFO --concurrency={{celeryd_concurrency}}
    environment:
      - C_FORCE_ROOT=true
    volumes:
      - "data:{{media_root}}"
      - "music:{{music_directory_path}}:ro"
{% include 'templates/docker/container/depends-on-database-redis.yml.j2' %}
{% include 'templates/docker/container/networks.yml.j2' %}

  celerybeat:
{% include 'roles/docker-compose/templates/services/base.yml.j2' %}
    image: funkwhale/api:{{applications.funkwhale.version}}
    command: celery -A funkwhale_api.taskapp beat --pidfile= -l INFO
{% include 'templates/docker/container/depends-on-database-redis.yml.j2' %}
{% include 'templates/docker/container/networks.yml.j2' %}

  api:
{% include 'roles/docker-compose/templates/services/base.yml.j2' %}
    image: funkwhale/api:{{applications.funkwhale.version}}
    volumes:
      - "music:{{music_directory_path}}:ro"
      - "data:{{media_root}}"
      - "static_root:{{static_root}}"
    ports:
      - "5000" # Exposes API just in local docker network to be used by front container
{% include 'templates/docker/container/depends-on-database-redis.yml.j2' %}
{% include 'templates/docker/container/networks.yml.j2' %}

  front:
{% include 'roles/docker-compose/templates/services/base.yml.j2' %}
    image: funkwhale/front:{{applications.funkwhale.version}}
    depends_on:
      - api
    environment:
      # Override those variables in your .env file if needed
      - "NGINX_MAX_BODY_SIZE=100M"
    volumes:
      - "data:{{media_root}}:ro"
      #- "{{static_root}}:{{static_root}}:ro"
    ports:
      # override those variables in your .env file if needed
      - "127.0.0.1:{{ports.localhost.http[application_id]}}:80"
  
  typesense:
{% include 'roles/docker-compose/templates/services/base.yml.j2' %}
    image: typesense/typesense:0.24.0
    volumes:
      - ./typesense/data:/data
    command: --data-dir /data --enable-cors
    profiles:
      - typesense

{% include 'templates/docker/compose/volumes.yml.j2' %}
  data:
  static_root:
  redis:
  music:

{% include 'templates/docker/compose/networks.yml.j2' %}