https://github.com/opensoft/flutterbench
This is a devcontainer setup for Flutter development. Scripts for setting up new devcontainer projects with well manered containers.
https://github.com/opensoft/flutterbench
Last synced: 12 days ago
JSON representation
This is a devcontainer setup for Flutter development. Scripts for setting up new devcontainer projects with well manered containers.
- Host: GitHub
- URL: https://github.com/opensoft/flutterbench
- Owner: opensoft
- Created: 2025-10-04T21:28:13.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2026-05-27T20:19:04.000Z (about 1 month ago)
- Last Synced: 2026-05-27T22:12:57.469Z (about 1 month ago)
- Language: Shell
- Size: 501 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ๐ 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:
```bash
# 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
```bash
# Navigate to flutterBench scripts
cd /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
```bash
# 1. Create or navigate to your Flutter project
flutter create my-flutter-app # or use existing project
cd 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
| Feature | Automated Setup | Manual Setup |
|---------|----------------|-------------|
| **Speed** | โก Fast (single command) | ๐ข Multiple steps required |
| **Control** | ๐ฏ Standardized | ๐ง Full customization |
| **Validation** | โ
Built-in | ๐ Manual validation required |
| **Learning** | ๐ฆ Black box | ๐ Educational |
| **Best For** | New projects | Existing projects, customization |
| **Difficulty** | ๐ข Easy | ๐ก Intermediate |
## ๐ง Manual Setup Validation
**โ ๏ธ IMPORTANT**: When using manual setup, you **MUST** run the validation script:
```bash
./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`](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:
```bash
# .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:
```bash
sonar-scanner -Dsonar.dart.lcov.reportPaths=coverage/lcov.info
```
Shell aliases: `flutter-sonar-coverage` and `dart-sonar-coverage`.
## ๐ Documentation
- [`templates/flutter-devcontainer-template/README.md`](templates/flutter-devcontainer-template/README.md) - Template details
- [`templates/flutter-devcontainer-template/scripts/README.md`](templates/flutter-devcontainer-template/scripts/README.md) - Manual setup guide
- [`docs/env-file-docker-compose-guide.md`](docs/env-file-docker-compose-guide.md) - Environment configuration guide
## ๐ฏ 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.