- Created 3 bash scripts (check-env.sh, validate-compose.sh, reset-env.sh) - All scripts follow CLAUDE.md standards with proper headers and exit codes - Total: 491 lines of bash scripting with color-coded output - Marked 5 requirements complete (SETUP-01 through SETUP-04, INF-05) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
5.2 KiB
phase, plan, subsystem, tags, depends_on, provides, affects, tech_stack, key_files, decisions, metrics
| phase | plan | subsystem | tags | depends_on | provides | affects | tech_stack | key_files | decisions | metrics | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 01-setup-git-foundation | 01 | scripts |
|
|
|
|
|
|
Phase 1 Plan 01: Docker Validation Scripts Summary
One-liner: Created three bash scripts for Docker environment verification, compose validation, and environment cleanup with color-coded output and proper exit codes.
Objective
Create validation scripts that verify Docker environment requirements and provide cleanup utilities for lab workflows. Students need reliable tools to verify their Docker setup meets course requirements before starting labs, and a way to reset their environment between labs.
Artifacts Created
scripts/check-env.sh (165 lines)
Purpose: Verifies Docker environment meets course requirements.
Features:
- Docker Engine version check (>= 24.0 required)
- Docker Compose V2 detection (not legacy docker-compose)
- Network utilities verification (netcat/nc, curl, iproute2)
- System resources reporting (RAM, CPU cores)
- Color-coded output (green pass, red fail, yellow warn)
- Exit code 0 on success, 1 on failures
Test results:
- PASS: Docker Engine 29.2.1 detected
- PASS: Docker Compose V2 5.1.0 detected
- PASS: All network utilities available
- WARN: 15GB RAM (recommended: 16GB)
scripts/validate-compose.sh (94 lines)
Purpose: Validates docker-compose.yml files before deployment.
Features:
- YAML syntax validation using
docker compose config - Clear usage message when called without arguments
- Graceful handling of missing files
- Help flag support (-h, --help)
- Color-coded output
- Exit code 0 on valid config, 1 on errors
Test results:
- PASS: Shows usage when called without arguments
- PASS: Exits 1 when given non-existent file
- PASS: Validates valid compose files successfully
- PASS: Detects YAML syntax errors
scripts/reset-env.sh (232 lines)
Purpose: Cleans Docker environment between labs.
Features:
- Interactive mode with user confirmation
- --dry-run flag for safe preview
- Stops all containers
- Removes all user-created networks (preserves bridge, host, none)
- Removes all volumes
- Preserves Docker images
- Clear warning messages
- Progress reporting
Test results:
- PASS: --dry-run shows what would be deleted
- PASS: Default mode requires user confirmation
- PASS: Detects and reports current environment state
- PASS: Preserves default Docker networks
Deviations from Plan
Rule 1 - Bug: Fixed set -e causing premature exit in check-env.sh
Found during: Task 1 execution
Issue: The script used set -e which caused it to exit when command substitutions encountered expected failures (like docker compose version when checking for V2).
Fix: Removed set -e and handled command failures gracefully using conditional checks instead.
Files modified: scripts/check-env.sh
Commit: a60a9ab
Technical Decisions
-
Color-coded output: All three scripts use ANSI color codes for better readability (green for success, red for errors, yellow for warnings).
-
Exit code consistency: All scripts follow standard Unix conventions (0 for success, 1 for errors).
-
Idempotency: All scripts can be run multiple times without side effects.
-
Safety first: reset-env.sh requires confirmation by default and provides --dry-run flag for safe preview.
Cross-Verification
- check-env.sh validates SETUP-01 (Docker >= 24.0), SETUP-02 (network utilities), SETUP-03 (resources), SETUP-04 (verification script)
- validate-compose.sh validates INF-05 (compose validation before use)
Self-Check: PASSED
Verification steps:
- All scripts exist in scripts/ directory and are executable (rwxrwxrwx)
- check-env.sh accurately detects Docker Engine >= 24.0, Compose V2, and network utilities
- validate-compose.sh catches YAML syntax errors in docker-compose.yml files
- reset-env.sh provides safe cleanup with --dry-run flag
- All scripts follow CLAUDE.md standards (headers, error messages, exit codes)
File existence checks:
- FOUND: /home/luca/Sources/LucaSacchiNet/laboratori-cloud/scripts/check-env.sh
- FOUND: /home/luca/Sources/LucaSacchiNet/laboratori-cloud/scripts/validate-compose.sh
- FOUND: /home/luca/Sources/LucaSacchiNet/laboratori-cloud/scripts/reset-env.sh
Commit checks: