CLI Documentation
Welcome to the ContainerPub CLI documentation. The CLI provides a powerful command-line interface for deploying and managing Dart serverless functions.
Overview
The dart_cloud_cli tool enables developers to:
- Deploy Functions - Upload and deploy Dart functions with a single command
- Manage Functions - List, invoke, and delete deployed functions
- View Logs - Monitor function execution and debugging
- Authenticate - Secure access with JWT-based authentication
- Validate Code - Pre-deployment security and structure checks
Quick Links
Getting Started
- dart_cloud_cli - Complete CLI reference and usage guide
- dart_cloud_function Package - Function development package
- API Key Signing & Secure Invocation - Sign function invocations with HMAC-SHA256
Key Features
Authentication System
- Dual Token System - Access tokens (1 hour) and refresh tokens (30 days)
- Automatic Refresh - CLI automatically refreshes expired tokens
- Secure Storage - Encrypted token storage in user home directory
- Easy Logout - Invalidate all tokens with single command
Function Deployment
- One Command Deploy - dart_cloud deploy ./my-function
- Automatic Validation - Size limits, forbidden files, security checks
- Code Analysis - Validates function structure and annotations
- Function Caching - Stores function metadata locally for quick updates
Function Management
- List Functions - View all deployed functions
- Invoke Functions - Test functions with custom data
- View Logs - Real-time and historical logs
- Delete Functions - Remove functions when no longer needed
API Key Signing
- Generate API Keys - Create HMAC-SHA256 signing keys
- Secure Invocation - Sign requests with --sign flag
- Key Management - Rotate, revoke, and extend keys
- Timestamp Validation - Prevent replay attacks
- Hive Storage - Secure local key storage
Installation
dart
cd dart_cloud_cli
dart pub get
dart pub global activate --source path .
Quick Start
dart
# Login to platform
dart_cloud login
# Initialize function config
dart_cloud init
# Deploy function
dart_cloud deploy ./my-function
# List functions
dart_cloud list
# View logs
dart_cloud logs <function-id>
# Logout
dart_cloud logout
Documentation Structure
CLI Tool
- dart_cloud_cli - Complete CLI reference
- Installation and setup
- All commands and options
- Authentication flow
- Configuration files
- Troubleshooting
API Key Signing
- API Key Signing & Secure Invocation - Secure function invocations
- Generating API keys
- Secret key storage
- HMAC-SHA256 signing algorithm
- Signed invocation with --sign flag
- Key management (rotate, revoke, extend)
- Security best practices
- Troubleshooting
Function Package
- dart_cloud_function - Function development
- Package overview
- API reference
- Usage examples
- Best practices
- Testing guide
Authentication Flow
Login
- User provides email and password
- Backend validates and returns access + refresh tokens
- CLI stores tokens securely
- Ready to deploy and manage functions
Token Refresh
- CLI detects expired access token
- Automatically sends refresh token
- Receives new access token
- Retries original request
- Seamless user experience
Logout
- CLI sends both tokens to backend
- Backend blacklists both tokens
- CLI removes local token storage
- User must login again
Security Features
- Token Encryption - Tokens encrypted at rest
- Automatic Expiry - Access tokens expire after 1 hour
- Refresh Rotation - Old access tokens invalidated on refresh
- Secure Storage - Tokens in protected user directory
- Blacklist System - Compromised tokens can be invalidated
Validation & Security
Pre-Deployment Checks
- Size Limits - Functions must be under 5 MB
- Forbidden Files - No secrets, keys, or credentials
- Forbidden Directories - No version control or build artifacts
- Code Structure - Exactly one CloudDartFunction class
- Annotations - @cloudFunction annotation required
- Security - No dangerous imports or process execution
Code Analysis
- Static analysis of function code
- Security vulnerability detection
- Structure validation
- Best practice enforcement
Configuration
Global Config
Location: ~/.dart_cloud/config.json
json
{
"accessToken": "eyJhbGc...",
"refreshToken": "eyJhbGc...",
"serverUrl": "http://localhost:8080"
}
Function Config
Location: .dart_tool/function_config.json
json
{
"function_name": "my_function",
"function_id": "abc123xyz789",
"created_at": "2025-11-16T23:34:00.000Z"
}
Common Workflows
Deploy New Function
bash
mkdir my-function
cd my-function
dart create -t console-simple .
dart_cloud init
# Edit main.dart with your function
dart_cloud deploy .
Update Existing Function
dart
cd my-function
# Make changes to your function
dart_cloud deploy .
Monitor Function
bash
dart_cloud logs <function-id> --follow
Delete Function
bash
dart_cloud delete <function-id>Troubleshooting
Authentication Issues
- Run dart_cloud logout then dart_cloud login
- Check server URL in config file
- Verify credentials
Deployment Failures
- Check function size (must be < 5 MB)
- Remove forbidden files and directories
- Verify @cloudFunction annotation
- Check for security violations
Token Expired
- CLI automatically refreshes tokens
- If refresh fails, login again
- Check refresh token hasn't expired (30 days)
Next Steps
- Read dart_cloud_cli Guide for detailed CLI usage
- Learn API Key Signing for secure function invocations
- Check dart_cloud_function Package for function development
- Explore Backend API Reference for API details
- Review Backend Architecture for system design
Support
For issues, questions, or contributions:
- GitHub: liodali/ContainerPub
- Documentation: ContainerPub Docs