This directory contains Docker configuration for running the Hercules distributed file system with multiple server types: Master Server, Chunk Servers, and Gateway Server.
All components are pure Go implementations - no Python or other language dependencies required.
- Docker Engine 20.10+
- Docker Compose 1.29+
- Make (optional, but recommended)
# Using Make
make build-all
make up
# Or using Docker Compose directly
docker-compose up -dmake status
# or
docker-compose ps# All services
make logs
# Specific service
make logs-master
make logs-chunk
make logs-gatewayThe Hercules system is a pure Go implementation consisting of three main components:
-
Master Server (Port 9090)
- Manages file metadata
- Coordinates chunk servers
- Handles namespace operations
- Written in Go
-
Chunk Servers (Ports 8081-8083)
- Store actual file chunks
- Handle read/write operations
- Report to master server
- Written in Go
-
Gateway Server (Port 8089)
- HTTP API for client interactions
- Provides REST endpoints
- Handles client requests
- Written in Go
All servers are pure Go implementations with no external language dependencies.
make build-all# Master server
make build-master
# Chunk server
make build-chunk
# Gateway server
make build-gatewayEach image can be built with the SERVER_TYPE argument:
docker build --build-arg SERVER_TYPE=master_server -t hercules-master .
docker build --build-arg SERVER_TYPE=chunk_server -t hercules-chunkserver .
docker build --build-arg SERVER_TYPE=gateway_server -t hercules-gateway .make up
# or
docker-compose up -dmake down
# or
docker-compose downmake restart
# or
docker-compose restartAdd more chunk servers dynamically:
make scale N=5
# or
docker-compose up -d --scale chunkserver=5Each service can be configured via environment variables:
SERVER_TYPE=master_serverSERVER_ADDRESS=master:9090ROOT_DIR=/data/masterLOG_LEVEL=info(debug, info, warn, error)
SERVER_TYPE=chunk_serverSERVER_ADDRESS=chunk_server<number>:8081MASTER_ADDR=master:9090ROOT_DIR=/data/chunksLOG_LEVEL=info
SERVER_TYPE=gateway_serverGATEWAY_ADDR=8089MASTER_ADDR=master:9090LOG_LEVEL=info
Edit docker-compose.yml to customize:
- Port mappings
- Volume mounts
- Resource limits
- Network configuration
Data is stored in named Docker volumes:
master-data: Master server metadatachunk1-data,chunk2-data,chunk3-data: Chunk storagegateway-data: Gateway cache and data- Various log volumes for each service
make backupThis creates timestamped tar.gz files in the backups/ directory.
make restore BACKUP=master-20240101-120000.tar.gzmake dev-master
make dev-chunk
make dev-gatewaymake shell-master
make shell-chunk1
make shell-gatewaymake healthServices communicate over a bridge network (hercules-net) with subnet 172.25.0.0/16.
Services use Docker DNS:
- Master:
master:9090 - Chunk Servers:
chunkserver1:8081,chunkserver2:8082, etc. - Gateway:
gateway:8089
make network-info
make ping-master
make ping-chunksAll services include health checks that monitor:
- Process status
- Service availability
- Response times
Health checks run every 30 seconds with:
- Timeout: 10s
- Retries: 3
- Start period: 10-20s (varies by service)
Access logs via:
docker-compose logs -f [service-name]The gateway server exposes HTTP endpoints on port 8089:
# Health check
curl http://localhost:8089/health
# File operations (example)
curl http://localhost:8089/api/v1/list?path=./-
Check if ports are already in use:
netstat -tuln | grep -E '9090|808[1-3]|8089'
-
Check logs:
make logs
-
Verify Docker resources:
docker system df docker system prune
-
Check network:
make network-info
-
Ping services:
make ping-master make ping-chunks
-
Verify service health:
make health
-
List volumes:
docker volume ls | grep hercules -
Inspect volume:
docker volume inspect hercules_master-data
make downmake cleanmake clean-volumesmake clean
make build-all
make upAdd resource constraints in docker-compose.yml:
services:
master:
deploy:
resources:
limits:
cpus: '2'
memory: 2G
reservations:
cpus: '1'
memory: 1GModify the network configuration:
networks:
hercules-net:
driver: bridge
ipam:
config:
- subnet: 10.5.0.0/16Use alternative volume drivers (e.g., for NFS):
volumes:
master-data:
driver: local
driver_opts:
type: nfs
o: addr=10.0.0.1,rw
device: ":/path/to/share"For production use, consider:
- Use specific image tags instead of
latest - Set resource limits for all services
- Enable log rotation to prevent disk space issues
- Configure automated backups
- Set up monitoring (Prometheus, Grafana)
- Use secrets management for sensitive data
- Enable TLS for gateway server
- Configure proper DNS instead of Docker DNS
When modifying Docker configuration:
- Test builds: `make build-all