services:
  backend-webapp:
    image: "docker-hosted.nexus.bthlabs.pl/hotpocket/backend:{{ hotpocket_app.backend.image_tag }}"
    command:
      - "/srv/venv/bin/gunicorn"
      - "-c"
      - "/srv/lib/gunicorn.conf.py"
      - "-b"
      - "unix:///srv/run/gunicorn.sock"
      - "hotpocket_backend.wsgi:application"
    logging:
      driver: "loki"
      options:
        loki-url: "{{ hotpocket_app.loki.url }}"
        loki-external-labels: "{{ hotpocket_app.backend.webapp.loki.external_labels }}"
        labels: "node"
    labels:
      node: "{{ hotpocket_app.loki.node }}"
    env_file:
      - "etc/backend_base.env"
      - "etc/backend_webapp.env"
    extra_hosts: [{% for extra_host in hotpocket_app.docker.extra_hosts %}"{{ extra_host }}"{% endfor %}]
    restart: "unless-stopped"
    volumes:
      - "{{ hotpocket_app.deployment_directory }}/etc/backend:/srv/etc"
      - "{{ hotpocket_app.deployment_directory }}/lib/backend:/srv/lib/backend"
      - "{{ hotpocket_app.deployment_directory }}/run/backend-webapp:/srv/run"
      - "{{ hotpocket_app.deployment_directory }}/run/uploads:/srv/uploads"

  backend-admin:
    image: "docker-hosted.nexus.bthlabs.pl/hotpocket/backend:{{ hotpocket_app.backend.image_tag }}"
    command:
      - "/srv/venv/bin/gunicorn"
      - "-c"
      - "/srv/lib/gunicorn.conf.py"
      - "-b"
      - "unix:///srv/run/gunicorn.sock"
      - "hotpocket_backend.wsgi:application"
    logging:
      driver: "loki"
      options:
        loki-url: "{{ hotpocket_app.loki.url }}"
        loki-external-labels: "{{ hotpocket_app.backend.admin.loki.external_labels }}"
        labels: "node"
    labels:
      node: "{{ hotpocket_app.loki.node }}"
    env_file:
      - "etc/backend_base.env"
      - "etc/backend_admin.env"
    extra_hosts: [{% for extra_host in hotpocket_app.docker.extra_hosts %}"{{ extra_host }}"{% endfor %}]
    restart: "unless-stopped"
    volumes:
      - "{{ hotpocket_app.deployment_directory }}/etc/backend:/srv/etc"
      - "{{ hotpocket_app.deployment_directory }}/lib/backend:/srv/lib/backend"
      - "{{ hotpocket_app.deployment_directory }}/run/backend-admin:/srv/run"
      - "{{ hotpocket_app.deployment_directory }}/run/uploads:/srv/uploads"

  backend-celery-worker:
    image: "docker-hosted.nexus.bthlabs.pl/hotpocket/backend:{{ hotpocket_app.backend.image_tag }}"
    command:
      - "/srv/venv/bin/celery"
      - "-A"
      - "hotpocket_backend.celery:app"
      - "worker"
      - "-l"
      - "INFO"
      - "-Q"
      - "celery,webapp"
      - "-c"
      - "{{ hotpocket_app.backend.celery_worker.concurrency }}"
    logging:
      driver: "loki"
      options:
        loki-url: "{{ hotpocket_app.loki.url }}"
        loki-external-labels: "{{ hotpocket_app.backend.celery_worker.loki.external_labels }}"
        labels: "node"
    labels:
      node: "{{ hotpocket_app.loki.node }}"
    env_file:
      - "etc/backend_base.env"
      - "etc/backend_webapp.env"
    extra_hosts: [{% for extra_host in hotpocket_app.docker.extra_hosts %}"{{ extra_host }}"{% endfor %}]
    restart: "unless-stopped"
    volumes:
      - "{{ hotpocket_app.deployment_directory }}/etc/backend:/srv/etc"
      - "{{ hotpocket_app.deployment_directory }}/lib/backend:/srv/lib/backend"
      - "{{ hotpocket_app.deployment_directory }}/run/backend-celery-worker:/srv/run"
      - "{{ hotpocket_app.deployment_directory }}/run/uploads:/srv/uploads"

  backend-celery-beat:
    image: "docker-hosted.nexus.bthlabs.pl/hotpocket/backend:{{ hotpocket_app.backend.image_tag }}"
    command:
      - "/srv/venv/bin/celery"
      - "-A"
      - "hotpocket_backend.celery:app"
      - "beat"
      - "-l"
      - "INFO"
      - "-s"
      - "/srv/run/celery-beat-schedule"
    logging:
      driver: "loki"
      options:
        loki-url: "{{ hotpocket_app.loki.url }}"
        loki-external-labels: "{{ hotpocket_app.backend.celery_beat.loki.external_labels }}"
        labels: "node"
    labels:
      node: "{{ hotpocket_app.loki.node }}"
    env_file:
      - "etc/backend_base.env"
      - "etc/backend_webapp.env"
    extra_hosts: [{% for extra_host in hotpocket_app.docker.extra_hosts %}"{{ extra_host }}"{% endfor %}]
    restart: "unless-stopped"
    volumes:
      - "{{ hotpocket_app.deployment_directory }}/etc/backend:/srv/etc"
      - "{{ hotpocket_app.deployment_directory }}/lib/backend:/srv/lib/backend"
      - "{{ hotpocket_app.deployment_directory }}/run/backend-celery-beat:/srv/run"
      - "{{ hotpocket_app.deployment_directory }}/run/uploads:/srv/uploads"
