docker-compose.yml


Overview

This [docker-compose.yml](/projects/291/68791) file defines the configuration for running the **Avalanche blockchain API service** within a Docker containerized environment tailored for local development. It orchestrates the setup of a single service named `api`, which:

This file is part of a broader set of Docker Compose configurations that enable developers to spin up isolated blockchain coinstack API services (e.g., Litecoin, Avalanche) locally with a development-friendly workflow.


Detailed Explanation

Top-Level Keys


Service: api

This is the primary container running the Avalanche API server.

Key

Description

`image`

`unchained-local-node` - A locally built Docker image containing the node/API environment.

`env_file`

`.env` - Loads environment variables from this file to configure service behavior.

`labels`

Docker labels configuring Traefik routing and load balancing rules.

`working_dir`

[/app/node/coinstacks/avalanche/api](/projects/291/69281) - Sets the working directory inside the container.

`command`

`yarn nodemon` - Starts the API using nodemon for hot reloading on source changes.

`volumes`

Mounts `../../..` from host to `/app` in the container, enabling live code updates.

`networks`

Connects this service to the external network `avalanche`.

Labels for Traefik Integration

These labels instruct Traefik to:

labels:
  - 'traefik.enable=true'
  - 'traefik.http.routers.avalanche-api.rule=Host(`api.avalanche.localhost`)'
  - 'traefik.http.services.avalanche-api.loadbalancer.server.port=3000'

Volumes and Working Directory

Command


Network: avalanche

networks:
  avalanche:
    name: avalanche_default
    external: true

Usage Example

Assuming the `unchained-local-node` image is already built and the `avalanche_default` Docker network exists, run:

docker-compose up

This command will:


Important Implementation Details


Interaction with Other System Components


Mermaid Diagram: Service-Workflow Flowchart

flowchart TD
    A[Developer / Host Machine]
    B[Local Source Code]
    C[Docker Container: Avalanche API]
    D[unchained-local-node Image]
    E[Traefik Reverse Proxy]
    F[avalanche_default Network]
    G[Blockchain Node & Indexer Services]

    A --> B
    B -->|Volume Mount| C
    D --> C
    C --> F
    G --> F
    C -->|HTTP port 3000| E
    E -->|Routes api.avalanche.localhost| A

**Diagram Explanation:**


Summary

This [docker-compose.yml](/projects/291/68791) file is a concise yet powerful configuration enabling local development of the Avalanche blockchain API service. By combining containerization, automatic code reload, network isolation, and dynamic reverse proxying, it provides a developer-friendly environment that closely mirrors production while accelerating iteration and debugging workflows. It fits into a larger ecosystem of Docker Compose files for multiple blockchain coinstacks, collectively supporting a modular and scalable blockchain infrastructure development setup.