services:

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

{% include 'roles/docker-central-database/templates/services/' + database_type + '.yml.j2' %}

  web:
    image: ghcr.io/mastodon/mastodon:{{applications.mastodon.version}}
{% include 'roles/docker-compose/templates/services/base.yml.j2' %}
    command: bash -c "rm -f /mastodon/tmp/pids/server.pid; bundle exec rails s -p 3000"
    healthcheck:
      test: ['CMD-SHELL', 'wget -q --spider --proxy=off localhost:3000/health || exit 1']
    ports:
      - "127.0.0.1:{{ports.localhost.http[application_id]}}:3000"
{% include 'templates/docker/container/depends-on-database-redis.yml.j2' %}
    volumes:
      - data:/mastodon/public/system
{% include 'templates/docker/container/networks.yml.j2' %}

  streaming:
    image: ghcr.io/mastodon/mastodon-streaming:{{applications.mastodon.version}}
{% include 'roles/docker-compose/templates/services/base.yml.j2' %}
    command: node ./streaming
    healthcheck:
      test: ['CMD-SHELL', 'wget -q --spider --proxy=off localhost:4000/api/v1/streaming/health || exit 1']
    ports:
      - "127.0.0.1:{{ports.localhost.websocket[application_id]}}:4000"
{% include 'templates/docker/container/depends-on-database-redis.yml.j2' %}
{% include 'templates/docker/container/networks.yml.j2' %}

  sidekiq:
    image: ghcr.io/mastodon/mastodon:{{applications.mastodon.version}}
{% include 'roles/docker-compose/templates/services/base.yml.j2' %}
    command: bundle exec sidekiq
{% include 'templates/docker/container/depends-on-database-redis.yml.j2' %}
    volumes:
      - data:/mastodon/public/system
    healthcheck:
      test: ['CMD-SHELL', "ps aux | grep '[s]idekiq\ 6' || false"]
{% include 'templates/docker/container/networks.yml.j2' %}

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

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