Development Guide
Learn how to develop, build, and deploy Dart functions with ContainerPub.
Getting Started
Prerequisites
- Dart SDK 3.x or higher
- Bun or pub for package management
- Podman (for local testing)
Installation
Automated Installation (Recommended):
bash
curl -fsSL https://raw.githubusercontent.com/liodali/ContainerPub/main/scripts/install.sh | bash
Or compile from source:
dart
./scripts/install-cli.shCLI Usage
Login
bash
dart_cloud loginDeploy a Function
bash
dart_cloud deploy ./my_functionList Functions
bash
dart_cloud listView Logs
bash
dart_cloud logs <function-id>Delete Function
bash
dart_cloud delete <function-id>Function Structure
A ContainerPub function requires:
my_function/ ├── main.dart # Entry point with main() function ├── pubspec.yaml # Dependencies └── lib/ # Additional code (optional)
Example Function
dart
// main.dart
void main() {
print('Hello from ContainerPub!');
}
Building Functions
Local Build
dart
cd my_function
dart pub get
dart run main.dart
Build Process
- Upload function archive
- Extract to container
- Build Docker/Podman image
- Store metadata
- Ready for execution
Environment Variables
Configure environment variables in your function:
bash
dart_cloud deploy ./my_function \
--env DATABASE_URL=postgresql://... \
--env API_KEY=secret
Monitoring
View Function Metrics
bash
dart_cloud metrics <function-id>Check Function Status
bash
dart_cloud status <function-id>Stream Logs
bash
dart_cloud logs <function-id> --follow
Best Practices
Security
- Never hardcode secrets
- Use environment variables
- Validate all inputs
- Keep dependencies updated
Performance
- Minimize cold start time
- Optimize dependencies
- Use efficient algorithms
- Cache when possible
Reliability
- Handle errors gracefully
- Use proper logging
- Test thoroughly
- Monitor in production
Troubleshooting
Function Won't Deploy
- Check Dart SDK version
- Verify pubspec.yaml
- Ensure main() exists
- Check network connectivity
Slow Execution
- Optimize dependencies
- Reduce function size
- Check resource limits
- Profile your code
Build Failures
- Check build logs
- Verify dependencies
- Test locally first
- Check Podman status
Next Steps
- Read the Architecture Overview
- Explore CLI Commands
- Check Best Practices