LogoContainerPub

Deployment Configuration

Deployment restrictions and validation configuration

Deployment Configuration#

This document describes the deployment configuration for dart_cloud_cli.

Configuration Overview#

All deployment restrictions and validation rules are centralized in lib/config/deployment_config.dart.

Size Limits#

LimitValueDescription
Maximum size5 MBFunctions exceeding this cannot be deployed
Warning threshold4 MBFunctions between 4-5 MB trigger a warning

Reducing Function Size#

If your function exceeds 5 MB:

1. Remove unnecessary directories:

rm -rf .git .dart_tool build node_modules

2. Use .gitignore to exclude files:

.dart_tool/
build/
.git/
node_modules/

3. Minimize dependencies:

  • Only include required packages in pubspec.yaml
  • Use dart pub get to install only production dependencies

4. Remove build artifacts:

dart pub get
dart pub upgrade

Forbidden Directories#

The following directories cannot be deployed:

DirectoryReason
.gitVersion control
.githubGitHub workflows
.vscodeVS Code settings
.ideaIntelliJ settings
node_modulesNode.js dependencies
.dart_toolDart build artifacts
buildBuild output
.gradleGradle build files
.cocoapodsCocoaPods files

Why? These directories:

  • Contain unnecessary files that increase size
  • May contain sensitive information
  • Are not needed for function execution

Forbidden Files#

Exact Matches#

FileReason
.envEnvironment variables
.env.localLocal environment overrides
secrets.jsonSecrets configuration
credentials.jsonCredentials file

Patterns#

PatternReason
*.pemPrivate keys (PEM format)
*.keyPrivate keys
*.p12PKCS12 certificates
*.pfxPKCS12 certificates
.env.*.localEnvironment overrides

Why? These files:

  • Contain sensitive credentials
  • Should never be committed to version control
  • Could expose secrets if deployed

Required Files#

FilePurpose
pubspec.yamlDart package manifest

Required Entry Points#

One of the following must exist:

FileDescription
main.dartFunction entry point in root
bin/main.dartFunction entry point in bin directory

Security Configuration#

Forbidden Imports#

ImportReason
dart:mirrorsReflection
dart:ffiForeign Function Interface

Dangerous Operations#

OperationDescription
Process.run()Execute processes
Process.start()Start processes
Process.runSync()Synchronous process execution

Dangerous Patterns#

PatternDescription
ShellShell execution
bashBash execution
Platform.executablePlatform executable access
Platform.scriptPlatform script access
SocketRaw socket operations
ServerSocketServer socket operations

Deployment Validation Flow#

1. Check function size
   ├─ If > 5 MBERROR
   └─ If 4-5 MBWARNING

2. Check for forbidden directories
   └─ If found → ERROR

3. Check for forbidden files
   └─ If found → ERROR

4. Verify required files exist
   └─ If missing → ERROR

5. Analyze code
   ├─ Check CloudDartFunction structure
   ├─ Verify @cloudFunction annotation
   ├─ Check for main() function
   └─ Scan for security risks

6. If all pass → Create archive and upload
   If any fail → Display errors and abort

Common Issues#

"Function size exceeds 5 MB limit"#

Solution:

  • Remove .git, .dart_tool, build directories
  • Check for large files (images, videos, etc.)
  • Minimize dependencies

"Forbidden directories found: .git"#

Solution:

  • Run: rm -rf .git
  • Or add to .gitignore if using version control

"Forbidden files found: .env"#

Solution:

  • Remove .env file
  • Use environment variables instead
  • Store secrets in secure configuration

"pubspec.yaml not found"#

Solution:

  • Ensure pubspec.yaml exists in function root
  • Run: dart pub get to initialize

"main.dart or bin/main.dart not found"#

Solution:

  • Create main.dart in function root
  • Or create bin/main.dart
  • Must contain your @cloudFunction class

Modifying Configuration#

To change deployment restrictions:

  1. Edit lib/config/deployment_config.dart
  2. Update the constants in DeploymentConfig class
  3. Rebuild the CLI

Example - Change maximum size to 10 MB:

class DeploymentConfig {
  static const int maxFunctionSizeMB = 10;  // Changed from 5
  static const int sizeWarningThresholdMB = 8;  // Changed from 4
  // ... rest of config
}

Best Practices#

  1. Keep it minimal - Only include necessary files
  2. Use .gitignore - Exclude build artifacts
  3. No secrets - Never commit .env or credentials
  4. Clean before deploy - Remove build directories
  5. Check size - Monitor function size growth
  6. Test locally - Verify before deployment

See Also#