compose.j2

Overview

This file is a Jinja2 template for a Docker Compose configuration that defines multiple services and their runtime configurations for a containerized environment. It leverages templating variables and conditional logic to dynamically generate a docker-compose.yaml file tailored to deployment needs. The primary purpose is to orchestrate the deployment of several interdependent services including a web server, GraphQL API server, block manager, staking service, and log rotation utility within a defined network.


Services Description

nginx_bm

q_server_bm

block_manager

staking_bm

logrotate


Networks


Implementation Details and Algorithms


Interactions with Other System Components


Usage Examples


Visual Diagram of Service Structure

flowchart LR
nginx_bm["nginx_bm (NGINX)"]
q_server_bm["q_server_bm (GraphQL Server)"]
block_manager["block_manager (Block Manager)"]
staking_bm["staking_bm (Staking)"]
logrotate["logrotate (Log Rotation)"]
ackinacki_net["ackinacki-net Network"]
nginx_bm -->|API calls| block_manager
nginx_bm -->|API calls| q_server_bm
q_server_bm -->|Depends on| block_manager
staking_bm -->|Depends on| block_manager
block_manager -.->|Logs stored| logrotate
nginx_bm --- ackinacki_net
q_server_bm --- ackinacki_net
block_manager --- ackinacki_net
staking_bm --- ackinacki_net
logrotate --- ackinacki_net

This diagram illustrates the interactions between services and their shared network, emphasizing dependency and communication flows.


Detailed Explanation of Key Configuration Elements

Environment Variables in block_manager


Conditional Port Binding in nginx_bm

The templated conditional block:

{% if NGINX_IP == "public" %}
  host_ip: {{ HOST_PUBLIC_IP }}
{% elif NGINX_IP == "private" %}
  host_ip: {{ HOST_PRIVATE_IP }}
{% else %}
  host_ip: {{ NGINX_IP }}
{% endif %}

determines the host IP address for NGINX port publishing, enabling environment-specific deployments without modifying the Compose file manually.


Inclusion of External Environment Variables

The line:

{% include 'extra/block-manager-env.j2' ignore missing +%}

allows injecting additional environment variables or configurations into the block manager service from an external template file if present, providing extensibility.


Volume Mounting Strategy


Relations to Other Topics