-
Notifications
You must be signed in to change notification settings - Fork 3
docs: Add documentation for FlatRun Agent #152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Lantum-Brendan
wants to merge
1
commit into
flatrun:main
Choose a base branch
from
Lantum-Brendan:docs/create-docs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+241
−0
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| { | ||
| "$schema": "https://raw.githubusercontent.com/whilesmart/docs-kit/main/schema/docs.schema.json", | ||
| "name": "FlatRun Agent", | ||
| "description": "Lightweight Go backend for flat-file Docker Compose orchestration with a REST API, container lifecycle management, and plugin architecture", | ||
| "icon": "server", | ||
| "category": { | ||
| "language": "go", | ||
| "framework": "app" | ||
| }, | ||
| "sidebar": [ | ||
| { "title": "Overview", "path": "docs/overview.md" }, | ||
| { "title": "Installation", "path": "docs/installation.md" }, | ||
| { "title": "Configuration", "path": "docs/configuration.md" }, | ||
| { "title": "API Reference", "path": "docs/api-reference.md" }, | ||
| { "title": "Plugin Architecture", "path": "docs/PLUGIN_ARCHITECTURE.md" }, | ||
| { "title": "Security", "path": "docs/security.md" } | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| ## API Reference | ||
|
|
||
| ### Authentication | ||
|
|
||
| | Method | Endpoint | Description | | ||
| |---|---|---| | ||
| | POST | `/api/auth/login` | Login with API key | | ||
| | GET | `/api/auth/validate` | Validate JWT token | | ||
| | GET | `/api/auth/status` | Check auth status | | ||
|
|
||
| ### Deployments | ||
|
|
||
| | Method | Endpoint | Description | | ||
| |---|---|---| | ||
| | GET | `/api/deployments` | List all deployments | | ||
| | POST | `/api/deployments` | Create new deployment | | ||
| | GET | `/api/deployments/:name` | Get deployment details | | ||
| | DELETE | `/api/deployments/:name` | Delete deployment | | ||
| | POST | `/api/deployments/:name/start` | Start deployment | | ||
| | POST | `/api/deployments/:name/stop` | Stop deployment | | ||
| | POST | `/api/deployments/:name/restart` | Restart deployment | | ||
| | GET | `/api/deployments/:name/logs` | Get deployment logs | | ||
|
|
||
| ### Docker Resources | ||
|
|
||
| | Method | Endpoint | Description | | ||
| |---|---|---| | ||
| | GET | `/api/containers` | List containers | | ||
| | GET | `/api/images` | List images | | ||
| | GET | `/api/volumes` | List volumes | | ||
| | GET | `/api/networks` | List networks | | ||
| | POST | `/api/networks` | Create network | | ||
| | DELETE | `/api/networks/:name` | Delete network | | ||
|
|
||
| ### Other | ||
|
|
||
| | Method | Endpoint | Description | | ||
| |---|---|---| | ||
| | GET | `/api/health` | Health check | | ||
| | GET | `/api/stats` | System statistics | | ||
| | GET | `/api/certificates` | List SSL certificates | | ||
| | GET | `/api/templates` | List Quick App templates | | ||
| | GET | `/api/plugins` | List installed plugins | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| ## Configuration | ||
|
|
||
| Copy the example configuration and edit it: | ||
|
|
||
| ```bash | ||
| cp config.example.yml config.yml | ||
| ``` | ||
|
|
||
| ### Reference | ||
|
|
||
| ```yaml | ||
| 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 | ||
| ``` | ||
|
|
||
| ### Key Options | ||
|
|
||
| | Option | Description | | ||
| |---|---| | ||
| | `deployments_path` | Directory containing docker-compose deployments | | ||
| | `api.port` | API server port (default: 8090) | | ||
| | `auth.api_keys` | Valid API keys for authentication | | ||
| | `auth.jwt_secret` | Secret for signing JWT tokens | | ||
| | `logging.level` | Log level: debug, info, warn, error | | ||
| | `health.check_interval` | Health check frequency | | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| ## Installation | ||
|
|
||
| ### Prerequisites | ||
|
|
||
| - Go 1.21 or later (for building from source) | ||
| - Docker and Docker Compose v2 | ||
| - Access to Docker socket (`/var/run/docker.sock`) | ||
| - Linux server (Ubuntu 20.04+, Debian 11+, or similar) | ||
|
|
||
| ### Option 1: Build from Source | ||
|
|
||
| ```bash | ||
| git clone https://github.com/flatrun/agent.git | ||
| cd agent | ||
| make build | ||
| ``` | ||
|
|
||
| Or manually: | ||
|
|
||
| ```bash | ||
| go mod download | ||
| go build -o flatrun-agent ./cmd/agent | ||
| ``` | ||
|
|
||
| ### Option 2: Download Binary | ||
|
|
||
| ```bash | ||
| wget https://github.com/flatrun/agent/releases/latest/download/flatrun-agent | ||
| chmod +x flatrun-agent | ||
| ``` | ||
|
|
||
| ### Running | ||
|
|
||
| Development mode: | ||
|
|
||
| ```bash | ||
| make run | ||
| # or | ||
| ./flatrun-agent --config config.yml | ||
| ``` | ||
|
|
||
| ### Production with Systemd | ||
|
|
||
| Move the binary to a system location: | ||
|
|
||
| ```bash | ||
| sudo mv flatrun-agent /usr/local/bin/ | ||
| sudo chmod +x /usr/local/bin/flatrun-agent | ||
| ``` | ||
|
|
||
| Create `/etc/systemd/system/flatrun-agent.service`: | ||
|
|
||
| ```ini | ||
| [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: | ||
|
|
||
| ```bash | ||
| sudo systemctl daemon-reload | ||
| sudo systemctl enable flatrun-agent | ||
| sudo systemctl start flatrun-agent | ||
| sudo systemctl status flatrun-agent | ||
| sudo journalctl -u flatrun-agent -f | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| ## Overview | ||
|
|
||
| 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. | ||
|
|
||
| ### Features | ||
|
|
||
| - 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 | ||
| - Plugin architecture for extensibility | ||
|
|
||
| ### Architecture | ||
|
|
||
| The agent follows a flat-file approach: each deployment is a directory containing a `docker-compose.yml` file. The agent watches the configured deployments directory and manages the containers through the Docker API. It communicates with the FlatRun UI through a REST API and uses JWT tokens for authentication. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| ## Security | ||
|
|
||
| - Use strong, unique API keys. | ||
| - Generate a secure JWT secret: `openssl rand -base64 32`. | ||
| - Run behind a reverse proxy (nginx) with HTTPS in production. | ||
| - Restrict Docker socket access appropriately. | ||
| - Keep the agent updated. | ||
|
|
||
| ### Troubleshooting | ||
|
|
||
| **Agent won't start:** | ||
| - Check Docker is running: `systemctl status docker` | ||
| - Verify Docker socket permissions: `ls -la /var/run/docker.sock` | ||
| - Validate the config YAML syntax | ||
|
|
||
| **Authentication issues:** | ||
| - Ensure the API key matches between UI and agent config | ||
| - Verify JWT secret is set | ||
| - Check CORS origins include your UI URL | ||
|
|
||
| **Can't see deployments:** | ||
| - Verify `deployments_path` exists and is readable | ||
| - Check each deployment has a valid `docker-compose.yml` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hardcoding a specific instruction to generate a secret is better than using a placeholder string which might be accidentally left in production configurations.