docker-compose.yml
Overview
This [docker-compose.yml](/projects/291/68791) file defines a minimal Docker Compose configuration for the **Litecoin blockchain coinstack API service** within the ShapeShift Unchained developer tooling environment. Its primary purpose is to orchestrate the Litecoin API container locally, enabling developers to run the Litecoin API server with live code reloading, integrated routing, and network isolation consistent with the multi-blockchain local development ecosystem.
The file configures:
A single
apiservice running the Litecoin API server using a local Node.js runtime image.Environment variables loaded from a
.envfile.Traefik reverse proxy labels for hostname-based routing and load balancing.
Volume mounting to sync source code into the container for hot reload.
Connection to an external Docker network dedicated to Litecoin services.
This setup facilitates rapid iteration and debugging of the Litecoin API service in a containerized environment that mimics production-like network topology and routing behavior.
Services
api
Purpose
Runs the Litecoin API server container, which serves HTTP API requests for Litecoin blockchain data. It uses `nodemon` to watch source files and automatically reload the server on code changes, providing a smooth developer experience.
Configuration Details
Image:
unchained-local-node
A pre-built local Node.js runtime image designed for running ShapeShift Unchained coinstacks.Environment Variables: Loaded from
.envfile located alongside this Compose file. This allows sensitive or environment-specific configuration (e.g., API keys, ports) to be injected without hardcoding.Labels:
These Docker labels are consumed by Traefik (reverse proxy) to enable HTTP routing:traefik.enable=true— Enables Traefik routing for this container.traefik.http.routers.litecoin-api.rule=Host(api.litecoin.localhost)— Routes requests with the hostnameapi.litecoin.localhostto this service.traefik.http.services.litecoin-api.loadbalancer.server.port=3000 — Tells Traefik to forward traffic to container port 3000.
Working Directory: /app/node/coinstacks/litecoin/api
Sets the working directory inside the container to the Litecoin API codebase folder.Command: yarn nodemon
Starts the API server withnodemon, enabling automatic restarts upon source code changes.Volumes:
Mounts the source code directory from host to container at/app. This ensures code edits on the host machine immediately reflect inside the container, powering live reload.Networks:
Connects the container to an external Docker network namedlitecoin_default, ensuring isolation and service discovery within the Litecoin coinstack environment.
Networks
litecoin
Defined as an external Docker network named
litecoin_default.This network is typically created outside this Compose file to facilitate sharing between multiple Litecoin-related containers (e.g., local node, indexer, API).
Using this external network allows the API container to communicate with other Litecoin services and be discoverable by Traefik.
Usage Example
Assuming you have Docker and Docker Compose installed, and the external network `litecoin_default` already created, you can run the Litecoin API service locally:
docker-compose up -d
This command will:
Pull or build the
unchained-local-nodeimage if necessary.Start the
apicontainer with source code mounted.Register the container with Traefik to route
api.litecoin.localhosttraffic to port 3000.Enable live reload of the API server on code changes.
You can then access the Litecoin API at:
http://api.litecoin.localhost
If you modify API source files locally, `nodemon` inside the container will restart the server automatically.
Important Implementation Details
Live Reloading:
Usingnodemonallows developers to see code changes reflected immediately without rebuilding Docker images or restarting containers manually. This accelerates debugging and feature development.Traefik Integration:
The service uses Docker labels to seamlessly integrate with Traefik’s dynamic routing. This avoids manual proxy configuration and supports hostname-based routing for multi-blockchain APIs running concurrently.Volume Mounting:
Mounting the entire source directory (../../..:/app) enables all relevant code and dependencies to be accessible inside the container. It allows the container to run the latest code without rebuilding images.External Network Usage:
Connecting tolitecoin_defaultensures the API service can communicate securely and reliably with other Litecoin coinstack services like node daemons or indexers, which may be running in separate containers or Compose files.
Interaction with Other System Components
This Compose file is part of a layered local development environment for ShapeShift Unchained, specifically tailored for the Litecoin blockchain coinstack. It interacts with:
Local Node Containers:
The API container communicates with Litecoin node daemons running in other containers connected to the samelitecoin_defaultnetwork to fetch blockchain data.Traefik Reverse Proxy:
Traefik listens to Docker events and uses labels from this service to route HTTP and WebSocket requests from developers or testing tools to the appropriate API container via hostname-based rules.Developer Workflows:
Volume mounting and live reload enable seamless code iteration, while the.envfile allows environment-specific configurations without image rebuilds.Multi-Coinstack Environments:
Similar Compose files exist for other blockchains (e.g., Bitcoin, Ethereum) establishing isolated but parallel local environments, all integrated via Traefik.Performance Testing Tools:
Load testing scripts (e.g., using k6) send HTTP requests through Traefik to this API service, validating performance and reliability under simulated traffic.
Visual Diagram
flowchart TD
A[Source Code (host)] -->|Mount via volume| B[API Container (unchained-local-node)]
B -->|Runs nodemon| C[Litecoin API Server]
C -->|Listens on port 3000| D[Traefik Reverse Proxy]
D -->|Routes HTTP requests for api.litecoin.localhost| E[Developer / Client]
B -->|Connects to| F[Docker Network: litecoin_default]
F -->|Connects other Litecoin services| G[Litecoin Node Containers]
This flowchart illustrates the flow within this Compose setup:
Source code is mounted inside the API container.
nodemonruns the Litecoin API server with live reload.Traefik routes incoming requests based on hostname to the API server at port 3000.
The API container connects to the
litecoin_defaultDocker network to communicate with Litecoin node services.
Summary
This [docker-compose.yml](/projects/291/68791) file plays a critical role in the ShapeShift Unchained developer tooling ecosystem by enabling local development and testing of the Litecoin API server. It leverages Docker Compose features to combine containerization, live reload, dynamic routing, and network isolation, fostering an efficient and realistic local blockchain development environment.