Skip to content

Latest commit

History

39 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

πŸš€ FlutterBench - Flutter Development Environment

A comprehensive Flutter development environment with DevContainer templates and project creation tools.

🧱 Container Architecture (Layered)

FlutterBench is standardizing on the layered workBenches model:

  • Layer 0: workbench-base:latest
  • Layer 1a: dev-bench-base:latest
  • Layer 2: flutter-bench:latest (bench-specific tools)
  • Layer 3: flutter-bench:{user} (user image built from Layer 2)

Legacy Note

Any monolithic .devcontainer/ Dockerfiles are deprecated. The layered images are the source of truth going forward.

Bench Image Workflow

Use these commands for the bench itself:

# Check whether Flutter bench images are current
./scripts/rebuild-stack.sh --check
# Rebuild Layer 2 and Layer 3
./scripts/build-layer.sh
# Start the bench container from the prebuilt user image
./scripts/start-monster.sh

./scripts/start-monster.sh no longer builds a monolithic devcontainer image. It ensures flutter-bench:latest exists, refreshes flutter-bench:${USER} if needed, and then starts the bench container from the layered image.

Flutter SDK policy

flutterBench now carries two SDK tracks in Layer 2:

  • /opt/flutter β€” the shared current stable SDK used as the default flutter
  • /opt/flutter-3.27.0 β€” the long-term supported Flutter 3.27 line for pinned repos

Shell helpers exposed in bench user environments:

  • flutter / dart β†’ current stable
  • flutter327 / dart327 β†’ pinned Flutter 3.27.0

Use project-local FVM where the repo pins a version. The baked 3.27 SDK exists to avoid slow first-run downloads for long-lived pinned projects.

🎯 Purpose

FlutterBench provides two ways to create Flutter projects with DevContainer support:

  1. πŸ€– Automated Setup - Use new-flutter-project.sh for quick, standardized project creation
  2. πŸ”§ Manual Setup - Copy templates manually for maximum customization control

πŸ“ Structure

flutterBench/
β”œβ”€β”€ scripts/
β”‚ β”œβ”€β”€ new-flutter-project.sh # Automated project creation
β”‚ β”œβ”€β”€ new-dartwing-project.sh # DartWing project creation β”‚ β”œβ”€β”€ update-flutter-project.sh # Update existing projects
β”‚ β”œβ”€β”€ launch-devbench.sh # Launch development container
β”‚ └── start-monster.sh # Container startup script
β”œβ”€β”€ templates/
β”‚ └── flutter-devcontainer-template/ # DevContainer template
β”‚ β”œβ”€β”€ .devcontainer/ # VS Code DevContainer config
β”‚ β”œβ”€β”€ .vscode/ # VS Code settings & tasks
β”‚ β”œβ”€β”€ scripts/
β”‚ β”‚ β”œβ”€β”€ manual-setup-project.sh # Manual setup validation
β”‚ β”‚ └── README.md # Script usage guide
β”‚ β”œβ”€β”€ .env.example # Environment template
β”‚ └── README.md # Template documentation
└── docs/ # Additional documentation

πŸš€ Getting Started

Option 1: Automated Setup (Recommended)

Best for: New projects, standardized setup, quick start

# Navigate to flutterBench scriptscd /path/to/workBenches/devBenches/flutterBench/scripts
# Create new Flutter project with DevContainer
./new-flutter-project.sh my-flutter-app
# Or specify custom target directory 
./new-flutter-project.sh my-flutter-app ~/projects/special-projects

What it does automatically:

  • βœ… Creates Flutter project using flutter create
  • βœ… Copies and configures DevContainer template
  • βœ… Sets up environment variables (.env)
  • βœ… Configures user UID/GID for proper permissions
  • βœ… Sets up infrastructure paths
  • βœ… Includes specKit for spec-driven development
  • βœ… Ready to open in VS Code

Option 2: Manual Setup (Advanced)

Best for: Existing projects, template customization, learning/understanding

# 1. Create or navigate to your Flutter project
flutter create my-flutter-app # or use existing projectcd my-flutter-app
# 2. Copy template files
TEMPLATE_PATH="/path/to/workBenches/devBenches/flutterBench/templates/flutter-devcontainer-template"
cp -r "$TEMPLATE_PATH/.devcontainer".
cp -r "$TEMPLATE_PATH/.vscode".
cp -r "$TEMPLATE_PATH/scripts".
cp "$TEMPLATE_PATH/.env.example".# 3. Set up environment configuration
cp .env.example .env
# Edit .env file with your project settings...# 4. Validate setup (IMPORTANT!)
./scripts/manual-setup-project.sh

When to use manual setup:

  • βœ… Adding DevContainer to existing Flutter project
  • βœ… Need to customize template before applying
  • βœ… Working with non-standard directory structure
  • βœ… Want to understand how the template works
  • βœ… Debugging container configuration issues

πŸ“‹ Key Differences

FeatureAutomated SetupManual Setup
Speed⚑ Fast (single command)🐒 Multiple steps required
Control🎯 StandardizedπŸ”§ Full customization
Validationβœ… Built-inπŸ“‹ Manual validation required
LearningπŸ“¦ Black boxπŸŽ“ Educational
Best ForNew projectsExisting projects, customization
Difficulty🟒 Easy🟑 Intermediate

πŸ”§ Manual Setup Validation

⚠️ IMPORTANT: When using manual setup, you MUST run the validation script:

./scripts/manual-setup-project.sh

This script:

  • πŸ” Creates .env from .env.example if missing
  • βœ… Validates all required environment variables
  • πŸ”§ Checks variable formats and values
  • 🐳 Verifies Docker environment
  • πŸ“‹ Tests container configuration
  • πŸ—οΈ Validates infrastructure paths

πŸ“– For detailed manual setup guidance, see templates/flutter-devcontainer-template/scripts/README.md

πŸ’‘ Which Approach Should I Use?

Use Automated Setup when:

  • βœ… Creating a new Flutter project from scratch
  • βœ… You want standard workBenches project structure
  • βœ… You need to get started quickly
  • βœ… You trust the default configuration
  • βœ… You're new to DevContainers

Use Manual Setup when:

  • βœ… Adding DevContainer to existing Flutter project
  • βœ… You need custom template modifications
  • βœ… Working with unique directory structures
  • βœ… You want to learn how DevContainers work
  • βœ… Debugging container issues
  • βœ… You need maximum control over the setup process

βš™οΈ Centralized Configuration Philosophy

Key Principle: The .env file is the single source of truth for ALL project and user-specific configuration.

What This Means:

  • βœ… Template files remain untouched - devcontainer.json, docker-compose.yml, etc. are never modified
  • βœ… All customization via environment variables - container names, user settings, versions, ports
  • βœ… Project-specific settings isolated - each project has its own .env file
  • βœ… Easy template updates - template improvements don't conflict with your settings

Configuration Examples:

# .env file controls everything:
PROJECT_NAME=dartwing
APP_CONTAINER_SUFFIX=app # Results in: dartwing-app
SERVICE_CONTAINER_SUFFIX=gateway # Results in: dartwing-gateway 
USER_UID=1000
FLUTTER_VERSION=3.24.0
COMPOSE_PROJECT_NAME=dartwingers

Result: Template files use ${PROJECT_NAME}-${APP_CONTAINER_SUFFIX} β†’ resolves to dartwing-app

πŸš€ Next Steps After Setup

Regardless of which setup method you used:

  1. Open in VS Code: code .
  2. Reopen in Container: Click prompt or Ctrl+Shift+P β†’ "Dev Containers: Reopen in Container"
  3. Wait for build: First time takes 2-5 minutes
  4. Start coding: Container includes Flutter SDK, Android tools, and VS Code extensions

πŸ”§ Available Scripts

Project Creation

  • scripts/new-flutter-project.sh - Create new Flutter project with DevContainer
  • scripts/new-dartwing-project.sh - Create new DartWing project variant

Project Management

  • scripts/update-flutter-project.sh - Update existing project to latest template
  • templates/.../scripts/manual-setup-project.sh - Validate manual setup

Development Environment

  • scripts/launch-devbench.sh - Launch development container
  • scripts/start-monster.sh - Ensure Layer 2 and Layer 3, then start the bench container
  • scripts/rebuild-stack.sh - Check or rebuild the Flutter bench image stack
  • scripts/ensure-images.sh - Lightweight Layer 2/Layer 3 check for devcontainer startup

SonarCloud Coverage

  • sonarcloud-dart-flutter - Run Dart/Flutter coverage and SonarCloud scan

sonarcloud-dart-flutter reads SONARQUBE_TOKEN from ~/.config/sonarqube/sonar.env. For Flutter projects it runs flutter test --coverage; for pure Dart projects it runs the Dart coverage package. Both paths produce coverage/lcov.info, then the helper invokes:

sonar-scanner -Dsonar.dart.lcov.reportPaths=coverage/lcov.info

Shell aliases: flutter-sonar-coverage and dart-sonar-coverage.

πŸ“š Documentation

🎯 Template Features

The DevContainer template includes:

  • 🐳 Lightweight container (~500MB vs 2GB+ FlutterBench)
  • πŸ”§ Centralized configuration - ALL project and user settings in .env file only
  • πŸ“ No template file modification - template files remain untouched, use environment variables
  • 🏷️ Configurable container naming - customize app and service container names via .env
  • πŸ“± Shared ADB infrastructure (connects to external ADB server)
  • βš™οΈ VS Code integration (tasks, launch configs, extensions)
  • πŸ—οΈ Proper user permissions (UID/GID matching)
  • πŸ”„ Hot reload support (port forwarding configured)
  • πŸ§ͺ Testing support (launch configurations)
  • πŸ“‹ Spec-driven development (includes specKit)

πŸ—οΈ Container Philosophy

  • FlutterBench = Heavy development workbench (~2GB, all tools)
  • Project Containers = Lightweight project-specific environment (~500MB)

Use FlutterBench for heavy development, project containers for debugging and light development.

About

This is a devcontainer setup for Flutter development. Scripts for setting up new devcontainer projects with well manered containers.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages