LogoContainerPub

Development Guide

Get started with ContainerPub development

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):

curl -fsSL https://raw.githubusercontent.com/liodali/ContainerPub/main/scripts/install.sh | bash

Or compile from source:

./scripts/install-cli.sh

CLI Usage#

Login#

dart_cloud login

Deploy a Function#

dart_cloud deploy ./my_function

List Functions#

dart_cloud list

View Logs#

dart_cloud logs <function-id>

Delete Function#

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#

// main.dart
void main() {
  print('Hello from ContainerPub!');
}

Building Functions#

Local Build#

cd my_function
dart pub get
dart run main.dart

Build Process#

  1. Upload function archive
  2. Extract to container
  3. Build Docker/Podman image
  4. Store metadata
  5. Ready for execution

Environment Variables#

Configure environment variables in your function:

dart_cloud deploy ./my_function \
  --env DATABASE_URL=postgresql://... \
  --env API_KEY=secret

Monitoring#

View Function Metrics#

dart_cloud metrics <function-id>

Check Function Status#

dart_cloud status <function-id>

Stream Logs#

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#

  1. Check Dart SDK version
  2. Verify pubspec.yaml
  3. Ensure main() exists
  4. Check network connectivity

Slow Execution#

  1. Optimize dependencies
  2. Reduce function size
  3. Check resource limits
  4. Profile your code

Build Failures#

  1. Check build logs
  2. Verify dependencies
  3. Test locally first
  4. Check Podman status

Next Steps#