Lightweight Go agent for flat-file container orchestration.
FlatRun Agent is the backend service that manages Docker deployments through a simple filesystem-based approach. It monitors your deployments directory and provides a REST API for the FlatRun UI.
- Docker Compose deployment management
- Container lifecycle control (start, stop, restart)
- Real-time container monitoring and logs
- Docker resource management (images, volumes, networks)
- SSL certificate monitoring
- Quick App templates for rapid deployment
- JWT-based API authentication
- Health monitoring and statistics
- Go 1.21+ (for building from source)
- Docker & Docker Compose v2
- Access to Docker socket (
/var/run/docker.sock) - Linux server (Ubuntu 20.04+, Debian 11+, or similar)
# Clone the repository
git clone https://github.com/flatrun/agent.git
cd agent
# Install dependencies and build
make build
# Or manually:
go mod download
go build -o flatrun-agent ./cmd/agent# Download the latest release (when available)
wget https://github.com/flatrun/agent/releases/latest/download/flatrun-agent
chmod +x flatrun-agent- Copy the example configuration:
cp config.example.yml config.yml- Edit
config.yml:
deployments_path: /home/user/deployments
docker_socket: unix:///var/run/docker.sock
api:
host: 0.0.0.0
port: 8090
enable_cors: true
allowed_origins:
- http://localhost:5173
- http://localhost:3000
auth:
enabled: true
api_keys:
- "your-secure-api-key-here"
jwt_secret: "generate-a-secure-random-string-here"
nginx:
container_name: nginx
config_path: /deployments/nginx/conf.d
reload_command: nginx -s reload
certbot:
container_name: certbot
email: your-email@example.com
staging: true
logging:
level: info
format: json
health:
check_interval: 30s
metrics_retention: 24h- deployments_path: Directory where your docker-compose deployments are stored
- api.port: Port the API server listens on (default: 8090)
- auth.api_keys: List of valid API keys for authentication
- auth.jwt_secret: Secret key for signing JWT tokens (generate a secure random string)
# Using make
make run
# Or directly
./flatrun-agent --config config.yml- Move the binary to a system location:
sudo mv flatrun-agent /usr/local/bin/
sudo chmod +x /usr/local/bin/flatrun-agent- Create a systemd service file:
sudo nano /etc/systemd/system/flatrun-agent.service[Unit]
Description=FlatRun Agent
After=network.target docker.service
Requires=docker.service
[Service]
Type=simple
User=root
WorkingDirectory=/opt/flatrun
ExecStart=/usr/local/bin/flatrun-agent --config /opt/flatrun/config.yml
Restart=always
RestartSec=10
StandardOutput=journal
StandardError=journal
[Install]
WantedBy=multi-user.target- Enable and start the service:
sudo systemctl daemon-reload
sudo systemctl enable flatrun-agent
sudo systemctl start flatrun-agent
# Check status
sudo systemctl status flatrun-agent
# View logs
sudo journalctl -u flatrun-agent -f/etc/flatrun/ # FlatRun configuration (example location)
└── config.yml # Agent configuration
/usr/local/bin/
└── flatrun-agent # Agent binary
/path/to/deployments/ # Configurable via deployments_path
├── .flatrun/ # FlatRun metadata
│ └── templates/ # Quick App templates
├── myapp/ # Example deployment
│ └── docker-compose.yml
└── nginx/ # Nginx reverse proxy
└── conf.d/
The deployments directory can be located anywhere on your system (e.g., /home/user/deployments, /srv/deployments, /var/lib/flatrun/deployments). Configure it via deployments_path in your config file.
POST /api/auth/login- Login with API keyGET /api/auth/validate- Validate JWT tokenGET /api/auth/status- Check auth status
GET /api/deployments- List all deploymentsPOST /api/deployments- Create new deploymentGET /api/deployments/:name- Get deployment detailsDELETE /api/deployments/:name- Delete deploymentPOST /api/deployments/:name/start- Start deploymentPOST /api/deployments/:name/stop- Stop deploymentPOST /api/deployments/:name/restart- Restart deploymentGET /api/deployments/:name/logs- Get deployment logs
GET /api/containers- List containersGET /api/images- List imagesGET /api/volumes- List volumesGET /api/networks- List networksPOST /api/networks- Create networkDELETE /api/networks/:name- Delete network
GET /api/health- Health checkGET /api/stats- System statisticsGET /api/certificates- List SSL certificatesGET /api/templates- List Quick App templatesGET /api/plugins- List installed plugins
- Always use strong, unique API keys
- Generate a secure JWT secret (use
openssl rand -base64 32) - Run behind a reverse proxy (nginx) with HTTPS in production
- Restrict Docker socket access appropriately
- Keep the agent updated
# Run tests
make test
# Clean build artifacts
make clean
# Run in development mode with hot reload (requires air)
air- Check Docker is running:
systemctl status docker - Verify Docker socket permissions:
ls -la /var/run/docker.sock - Check config file syntax: validate your YAML
- Ensure API key matches between UI and agent config
- Verify JWT secret is set
- Check CORS origins include your UI URL
- Verify
deployments_pathexists and is readable - Check each deployment has a valid
docker-compose.yml
MIT License - See LICENSE file