docker-compose.yml


Overview

This `docker-compose.yml` file defines the configuration for a Docker Compose application setup focusing on a single service named `api`. The primary purpose of this file is to orchestrate and run a Go-based API service (`unchained-local-go` image) within a Docker container. It leverages Traefik as a reverse proxy/load balancer to route HTTP requests to the API service based on the hostname.

Key functionalities:


Detailed Explanation

Services

api


Networks


Usage Example

To start the API service with this `docker-compose.yml`:

docker-compose up api

This command will:


Implementation Details and Algorithms


Interaction with Other Parts of the System


Mermaid Diagram

The following flowchart illustrates the startup and execution workflow of the `api` service in this Docker Compose file:

flowchart TD
    Start[Start Docker Compose]
    Start --> ConnectNet[Connect to external network: thorchain-v1_default]
    ConnectNet --> PullImage[Pull unchained-local-go image]
    PullImage --> CreateContainer[Create container with volumes and env]
    CreateContainer --> StartReflex[Start reflex file watcher]
    StartReflex --> WatchChanges[Watch source directories (pkg, internal, thorchain-v1)]
    WatchChanges -->|On change| GenerateSwagger[Generate Swagger spec]
    GenerateSwagger --> RunAPI[Run Go API server with .env]
    WatchChanges -->|No change| RunAPI
    RunAPI --> TraefikRouting[Traefik routes traffic to port 3000]

Summary

This `docker-compose.yml` file orchestrates a Go API service container with live reload and API documentation generation capabilities. It integrates tightly with a Traefik reverse proxy for routing and uses an external Docker network for broader connectivity. The reflex watcher automates the development workflow by regenerating Swagger specs and restarting the server on source changes, facilitating efficient iterative development.


End of Documentation for docker-compose.yml