Files
computer-playbook/roles/web-app-mastodon/templates/compose.yml.j2

38 lines
2.0 KiB
Django/Jinja

{% include 'roles/sys-svc-compose/templates/base.yml.j2' %}
{% macro mastodon_service(name, container, image_key, command, ports_key=none, healthcheck=true, with_volumes=false, after_migrate=true, restart=none) -%}
{% set service_name = name %}
{% if restart is not none %}{% set docker_restart_policy = restart %}{% endif %}
{{ service_name }}:
{{ lookup('compose_only', 'container_name', container) }}
{{ lookup('container_image', application_id, image_key) }}
{% include 'roles/sys-svc-container/templates/base.yml.j2' %}
command: {{ command }}
{% if healthcheck %}
{{ lookup('container_healthcheck', service_name) | indent(4) }}
{% endif %}
{% if ports_key is not none %}
{{ lookup('container_ports', ['mastodon', ports_key, DOCKER_BIND_HOST]) | indent(4) }}
{% endif %}
{% if after_migrate %}
{{ lookup('container_depends_on', application_id, extra={
MASTODON_MIGRATE_SERVICE_NAME: {'condition': 'service_completed_successfully'},
}) | indent(4) }}
{% else %}
{{ lookup('container_depends_on', application_id) | indent(4) }}
{% endif %}
{% if with_volumes %}
{{ lookup('container_volumes', service_name) | indent(4) }}
{% endif %}
{{ lookup('container_extra_hosts') | indent(4) }}
{{ lookup('container_networks') | indent(4) }}
{% endmacro -%}
{{ mastodon_service(MASTODON_SERVICE_NAME, MASTODON_CONTAINER, 'mastodon', 'bash -c "rm -f /mastodon/tmp/pids/server.pid; bundle exec rails s -p 3000"', ports_key='http', with_volumes=true) }}
{{ mastodon_service(MASTODON_STREAMING_SERVICE_NAME, MASTODON_STREAMING_CONTAINER, 'streaming', 'node ./streaming', ports_key='websocket') }}
{{ mastodon_service(MASTODON_SIDEKIQ_SERVICE_NAME, MASTODON_SIDEKIQ_CONTAINER, 'mastodon', 'bundle exec sidekiq', with_volumes=true) }}
{{ mastodon_service(MASTODON_MIGRATE_SERVICE_NAME, MASTODON_MIGRATE_CONTAINER, 'mastodon', 'bundle exec rails db:prepare', healthcheck=false, after_migrate=false, restart='on-failure', with_volumes=true) }}
{{ lookup('compose_volumes') }}
{{ lookup('compose_networks') }}