container-superposition 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/README.md +365 -9
  2. package/dist/scripts/init.js +220 -94
  3. package/dist/scripts/init.js.map +1 -1
  4. package/dist/tool/commands/doctor.js +2 -2
  5. package/dist/tool/commands/explain.d.ts.map +1 -1
  6. package/dist/tool/commands/explain.js +88 -0
  7. package/dist/tool/commands/explain.js.map +1 -1
  8. package/dist/tool/commands/plan.d.ts +51 -0
  9. package/dist/tool/commands/plan.d.ts.map +1 -1
  10. package/dist/tool/commands/plan.js +523 -1
  11. package/dist/tool/commands/plan.js.map +1 -1
  12. package/dist/tool/questionnaire/composer.d.ts +12 -3
  13. package/dist/tool/questionnaire/composer.d.ts.map +1 -1
  14. package/dist/tool/questionnaire/composer.js +133 -20
  15. package/dist/tool/questionnaire/composer.js.map +1 -1
  16. package/dist/tool/schema/types.d.ts +18 -0
  17. package/dist/tool/schema/types.d.ts.map +1 -1
  18. package/dist/tool/utils/gitignore.d.ts +15 -0
  19. package/dist/tool/utils/gitignore.d.ts.map +1 -0
  20. package/dist/tool/utils/gitignore.js +41 -0
  21. package/dist/tool/utils/gitignore.js.map +1 -0
  22. package/dist/tool/utils/services-export.d.ts +14 -0
  23. package/dist/tool/utils/services-export.d.ts.map +1 -0
  24. package/dist/tool/utils/services-export.js +478 -0
  25. package/dist/tool/utils/services-export.js.map +1 -0
  26. package/dist/tool/utils/summary.d.ts +69 -0
  27. package/dist/tool/utils/summary.d.ts.map +1 -0
  28. package/dist/tool/utils/summary.js +260 -0
  29. package/dist/tool/utils/summary.js.map +1 -0
  30. package/docs/overlays.md +48 -5
  31. package/overlays/.presets/microservice.yml +32 -6
  32. package/overlays/.presets/web-api.yml +76 -56
  33. package/overlays/cloudflared/README.md +190 -0
  34. package/overlays/cloudflared/devcontainer.patch.json +3 -0
  35. package/overlays/cloudflared/overlay.yml +15 -0
  36. package/overlays/cloudflared/setup.sh +49 -0
  37. package/overlays/cloudflared/verify.sh +21 -0
  38. package/overlays/direnv/README.md +6 -4
  39. package/overlays/direnv/setup.sh +0 -12
  40. package/overlays/grpc-tools/README.md +242 -0
  41. package/overlays/grpc-tools/devcontainer.patch.json +14 -0
  42. package/overlays/grpc-tools/overlay.yml +14 -0
  43. package/overlays/grpc-tools/setup.sh +57 -0
  44. package/overlays/grpc-tools/verify.sh +47 -0
  45. package/overlays/keycloak/.env.example +5 -0
  46. package/overlays/keycloak/README.md +238 -0
  47. package/overlays/keycloak/devcontainer.patch.json +17 -0
  48. package/overlays/keycloak/docker-compose.yml +32 -0
  49. package/overlays/keycloak/overlay.yml +23 -0
  50. package/overlays/keycloak/verify.sh +54 -0
  51. package/overlays/mailpit/.env.example +4 -0
  52. package/overlays/mailpit/README.md +191 -0
  53. package/overlays/mailpit/devcontainer.patch.json +20 -0
  54. package/overlays/mailpit/docker-compose.yml +17 -0
  55. package/overlays/mailpit/overlay.yml +26 -0
  56. package/overlays/mailpit/verify.sh +52 -0
  57. package/overlays/ngrok/overlay.yml +2 -1
  58. package/overlays/python/README.md +51 -35
  59. package/overlays/python/devcontainer.patch.json +7 -4
  60. package/overlays/python/setup.sh +50 -23
  61. package/overlays/python/verify.sh +29 -1
  62. package/package.json +1 -1
package/README.md CHANGED
@@ -6,6 +6,75 @@
6
6
 
7
7
  Composable devcontainer scaffolds that collapse into working environments.
8
8
 
9
+ ## ⚡ 30-Second Quickstart
10
+
11
+ Get a fully-configured development environment in one command:
12
+
13
+ ```bash
14
+ # Web API with database and observability (Node.js)
15
+ npx container-superposition init --preset web-api --language nodejs
16
+ # Creates: Node.js + PostgreSQL + Redis + Grafana + Prometheus + Loki
17
+
18
+ # Or compose + specific language
19
+ npx container-superposition init --stack compose --language nodejs --database postgres
20
+ # Creates: Node.js + PostgreSQL devcontainer
21
+
22
+ # Then open in VS Code
23
+ code .
24
+ # Click "Reopen in Container" when prompted
25
+ ```
26
+
27
+ **That's it!** Your devcontainer is ready. Jump to [Quick Start](#-quick-start) for more options or [Examples](#-examples) for real-world references.
28
+
29
+ ### 👁️ Preview Before You Commit
30
+
31
+ Use the `plan` command to see exactly what will be created:
32
+
33
+ ```bash
34
+ npx container-superposition plan --stack compose --overlays nodejs,postgres,grafana,prometheus
35
+ ```
36
+
37
+ **Example output:**
38
+
39
+ ```
40
+ ╭──────────────────╮
41
+ │ Generation Plan │
42
+ ╰──────────────────╯
43
+
44
+ Stack: compose
45
+
46
+ Overlays Selected:
47
+ ✓ nodejs (Node.js)
48
+ ✓ postgres (PostgreSQL)
49
+ ✓ grafana (Grafana)
50
+ ✓ prometheus (Prometheus)
51
+
52
+ Port Mappings:
53
+ postgres: 5432
54
+ grafana: 3000
55
+ prometheus: 9090
56
+
57
+ Files to Create/Modify:
58
+ .devcontainer/
59
+ 📄 .env.example
60
+ 📄 README.md
61
+ 📄 devcontainer.json
62
+ 📄 docker-compose.yml
63
+ 📄 global-packages-nodejs.txt
64
+ 📄 ports.json
65
+ 📄 superposition.json
66
+ .devcontainer/scripts/
67
+ 📄 setup-nodejs.sh
68
+ 📄 verify-grafana.sh
69
+ 📄 verify-nodejs.sh
70
+ 📄 verify-postgres.sh
71
+ 📄 verify-prometheus.sh
72
+
73
+ ✓ No conflicts detected. Ready to generate!
74
+ ```
75
+
76
+ This gives you full visibility into the configuration before any files are created.
77
+
9
78
  ## 🎯 Purpose
10
79
 
11
80
  Container Superposition provides a **modular, overlay-based system** for building devcontainer configurations. Start with a minimal base template, then compose it with language frameworks, databases, observability tools, and cloud utilities to create your ideal development environment.
@@ -333,7 +402,7 @@ npx container-superposition doctor --fix
333
402
 
334
403
  **Doctor checks:**
335
404
 
336
- - ✅ Node.js version compatibility (>= 18)
405
+ - ✅ Node.js version compatibility (>= 20)
337
406
  - ✅ Docker daemon connectivity
338
407
  - ✅ Docker Compose v2 availability (when using compose stack)
339
408
  - ✅ Overlay integrity (valid manifests, required files)
@@ -346,7 +415,7 @@ npx container-superposition doctor --fix
346
415
  🔍 Running diagnostics...
347
416
 
348
417
  Environment:
349
- ✓ Node.js version: v20.10.0 (>= 18.0.0 required)
418
+ ✓ Node.js version: v20.10.0 (>= 20.0.0 required)
350
419
  ✓ Docker daemon: Docker version 24.0.5
351
420
  ✓ Docker Compose: v2.23.0 (v2 required)
352
421
 
@@ -482,22 +551,140 @@ The tool automatically validates overlay compatibility and warns you when select
482
551
  - Environment-specific configuration
483
552
  - Compatibility rules and best practices
484
553
 
485
- ### Regenerating from Manifest
554
+ ### Overlay Compatibility Matrix
555
+
556
+ Common overlays and their compatibility with different deployment targets:
557
+
558
+ | Overlay | Local | Codespaces | Gitpod | Notes |
559
+ | -------------------- | ----- | ---------- | ------ | ---------------------------------------- |
560
+ | **docker-sock** | ✅ | ❌ | ❌ | Requires host Docker socket (local only) |
561
+ | **docker-in-docker** | ✅ | ✅ | ✅ | Slower but portable |
562
+ | **postgres** | ✅ | ✅ | ✅ | |
563
+ | **redis** | ✅ | ✅ | ✅ | |
564
+ | **mysql** | ✅ | ✅ | ✅ | |
565
+ | **mongodb** | ✅ | ✅ | ✅ | |
566
+ | **sqlserver** | ✅ | ✅ | ✅ | Needs memory (>2GB recommended) |
567
+ | **rabbitmq** | ✅ | ✅ | ✅ | |
568
+ | **grafana** | ✅ | ✅ | ✅ | |
569
+ | **prometheus** | ✅ | ✅ | ✅ | |
570
+ | **jaeger** | ✅ | ✅ | ✅ | |
571
+ | **playwright** | ✅ | ✅ | ✅ | Requires browser dependencies |
572
+ | **aws-cli** | ✅ | ✅ | ✅ | CLI tools work everywhere |
573
+ | **kubectl-helm** | ✅ | ✅ | ✅ | |
574
+ | **terraform** | ✅ | ✅ | ✅ | |
575
+
576
+ **Legend:**
577
+
578
+ - ✅ Fully supported
579
+ - ❌ Not supported (technical limitation)
580
+
581
+ The `--target` flag enables automatic validation during generation.
582
+
583
+ ## ⚠️ Security Considerations
584
+
585
+ **Important:** Container Superposition is designed for **development environments only**. Be aware of these security implications:
586
+
587
+ ### docker-sock Overlay
588
+
589
+ - **⚠️ Risk:** Provides **root-level access** to host Docker daemon
590
+ - **⚠️ Limitation:** Not supported in GitHub Codespaces (requires local Docker)
591
+ - **✅ Alternative:** Use `docker-in-docker` for isolation and portability
592
+ - **✅ When to use:** Local development only, trusted code only
593
+
594
+ **Why this matters:**
486
595
 
487
- Every devcontainer generation creates a `superposition.json` manifest file that records your configuration choices. You can use this manifest to:
596
+ Mounting `/var/run/docker.sock` gives the container full control over the host's Docker daemon. A compromised container could:
488
597
 
489
- - **Iterate on your setup** - Modify overlay selections and regenerate
490
- - **Update to latest** - Regenerate with newer overlay versions
491
- - **Experiment safely** - Try different configurations with automatic backup
492
- - **Share configurations** - Commit the manifest for team consistency
598
+ - Access your entire filesystem via volume mounts
599
+ - Create privileged containers
600
+ - Effectively gain root access to your host machine
601
+
602
+ **Best practices:**
603
+
604
+ - ✅ Only use on your local development machine
605
+ - ✅ Never use in multi-tenant or production environments
606
+ - ✅ Audit containers created from within the devcontainer
607
+ - ❌ Don't use with untrusted code or dependencies
608
+
609
+ ### Database Default Credentials
610
+
611
+ All database overlays (PostgreSQL, Redis, MySQL, etc.) use **development-only default credentials**:
612
+
613
+ - Default passwords like `postgres`, `redis`, `admin`
614
+ - No authentication enabled by default (where applicable)
615
+ - Designed for local development convenience
616
+
617
+ **Best practices:**
618
+
619
+ - ✅ Change default passwords for any networked testing
620
+ - ✅ Never expose database ports publicly
621
+ - ✅ Use `.env` (gitignored) for custom credentials
622
+ - ❌ Never commit real credentials to version control
623
+
624
+ ### Environment Files
625
+
626
+ - **`.env.example`** - Committed to git, contains templates and defaults
627
+ - **`.env`** - Gitignored, contains your actual values (may include secrets)
628
+
629
+ **Best practices:**
630
+
631
+ - ✅ Copy `.env.example` to `.env` and customize
632
+ - ✅ Use placeholder values in `.env.example` (`CHANGEME`, `your-key-here`)
633
+ - ✅ Verify `.env` is in `.gitignore` before committing
634
+ - ❌ Never commit `.env` files with real credentials
635
+
636
+ ### General Security Principles
637
+
638
+ - **Development only** - These configurations are optimized for developer productivity, not security
639
+ - **Local networks** - Keep devcontainer services on local networks, don't expose to internet
640
+ - **Update regularly** - Keep base images and overlays up to date
641
+ - **Audit dependencies** - Be aware of what's installed in your devcontainer
642
+
643
+ See individual overlay READMEs (especially [docker-sock](overlays/docker-sock/README.md)) for specific security considerations.
644
+
645
+ ### Safe Upgrade and Regeneration
646
+
647
+ Every devcontainer generation creates a `superposition.json` manifest file that records your configuration choices. This manifest is the key to safe updates and iterations.
648
+
649
+ **Why the manifest exists:**
650
+
651
+ - **🔄 Reproducibility** - Recreate exact same configuration on any machine
652
+ - **⬆️ Upgrades** - Pull latest overlay improvements without starting from scratch
653
+ - **🧪 Experimentation** - Try different configurations with automatic backup
654
+ - **👥 Team Sharing** - Commit the manifest for consistent team environments
655
+
656
+ **When to regenerate (regen) vs manual edit:**
657
+
658
+ | Scenario | Use | Why |
659
+ | ---------------------------------- | ---------------------- | -------------------------------------------- |
660
+ | Update to latest overlay versions | `regen` | Get bug fixes and improvements automatically |
661
+ | Add/remove overlays | `init --from-manifest` | Let the tool handle merge complexity |
662
+ | Change port offset | `init --from-manifest` | Automatic port recalculation |
663
+ | Tweak VS Code settings | Manual edit | Simple JSON change, no regeneration needed |
664
+ | Add custom script | Manual edit | Direct file addition |
665
+ | Fix specific devcontainer bug | Manual edit | Quick fix without full regeneration |
666
+ | Switch base image | `init --from-manifest` | Template dependencies may change |
667
+ | Your project evolved significantly | `init` (fresh) | Clean slate with new requirements |
493
668
 
494
669
  **Quick regeneration (recommended):**
495
670
 
496
671
  ```bash
497
- # Simple regen command - automatically finds manifest in .devcontainer/
672
+ # Simple regen command - automatically finds manifest in .devcontainer/ or project root
498
673
  npx container-superposition regen
499
674
 
500
675
  # Creates backup and regenerates with exact same settings from manifest
676
+ # Perfect for updating to latest overlay versions
677
+ ```
678
+
679
+ **Update to latest version and regenerate:**
680
+
681
+ ```bash
682
+ # Update the tool and regenerate in one go
683
+ npx container-superposition@latest regen
684
+
685
+ # Or update globally first
686
+ npm update -g container-superposition
687
+ container-superposition regen
501
688
  ```
502
689
 
503
690
  **Interactive regeneration with changes:**
@@ -563,6 +750,175 @@ npx container-superposition init --from-manifest ./.devcontainer/superposition.j
563
750
 
564
751
  See [tool/README.md](tool/README.md) for full documentation.
565
752
 
753
+ ## 📂 Filesystem Contract
754
+
755
+ Understanding what Container Superposition writes and where helps you manage your devcontainer configuration effectively.
756
+
757
+ ### What Gets Written Where
758
+
759
+ **Generated by the tool:**
760
+
761
+ ```
762
+ your-project/
763
+ ├── .devcontainer/ # Main devcontainer directory
764
+ │ ├── devcontainer.json # Container configuration
765
+ │ ├── docker-compose.yml # Services (if using compose stack)
766
+ │ ├── .env.example # Environment variable templates
767
+ │ ├── ports.json # Port documentation and connection strings
768
+ │ ├── scripts/ # Setup and verification scripts
769
+ │ │ ├── post-create.sh # Runs once when container is created
770
+ │ │ └── post-start.sh # Runs every time container starts
771
+ │ └── custom/ # Your customizations (preserved across regen)
772
+ │ ├── devcontainer.patch.json
773
+ │ └── docker-compose.patch.yml
774
+ ├── superposition.json # Manifest file (enables regeneration)
775
+ └── .devcontainer.backup-*/ # Automatic backups (gitignored)
776
+ ```
777
+
778
+ ### Files You Should Customize
779
+
780
+ **After generation:**
781
+
782
+ - **`.env`** - Copy from `.env.example`, add your actual values
783
+ - **`.devcontainer/custom/`** - Add your project-specific patches here
784
+
785
+ **Direct edits (survive regeneration):**
786
+
787
+ - `.devcontainer/custom/devcontainer.patch.json` - Extra devcontainer settings
788
+ - `.devcontainer/custom/docker-compose.patch.yml` - Additional services
789
+ - `.devcontainer/custom/environment.env` - Extra environment variables
790
+ - `.devcontainer/custom/scripts/*` - Custom setup scripts
791
+
792
+ **Direct edits (lost on regeneration):**
793
+
794
+ - `.devcontainer/devcontainer.json` - Regenerated from overlays
795
+ - `.devcontainer/docker-compose.yml` - Regenerated from overlays
796
+ - `.devcontainer/scripts/` - Regenerated from overlays
797
+
798
+ ### Files You Should Commit
799
+
800
+ **Essential for team collaboration:**
801
+
802
+ - ✅ `superposition.json` - Enables `regen` command
803
+ - ✅ `.devcontainer/` - The generated configuration (team shares setup)
804
+ - ✅ `.env.example` - Template for environment variables
805
+ - ✅ `.devcontainer/custom/` - Your project-specific customizations
806
+
807
+ **Only for certain workflows:**
808
+
809
+ - ⚠️ `superposition.json` only - See [Team Workflow](docs/team-workflow.md) for manifest-only pattern
810
+
811
+ ### Files in .gitignore
812
+
813
+ **Automatically added to your `.gitignore`:**
814
+
815
+ ```gitignore
816
+ # Environment secrets (never commit)
817
+ .env
818
+ .devcontainer/.env
819
+
820
+ # Regeneration backups (local only)
821
+ .devcontainer.backup-*
822
+ ```
823
+
824
+ ### Workflow Examples
825
+
826
+ **Individual developer:**
827
+
828
+ ```bash
829
+ # 1. Generate devcontainer
830
+ npx container-superposition init --preset web-api --language nodejs
831
+
832
+ # 2. Customize .env from template
833
+ cp .devcontainer/.env.example .devcontainer/.env
834
+ # Edit .env with your values
835
+
836
+ # 3. Add project-specific customization
837
+ mkdir -p .devcontainer/custom
838
+ echo '{"customizations": {"vscode": {"extensions": ["eamodio.gitlens"]}}}' > .devcontainer/custom/devcontainer.patch.json
839
+
840
+ # 4. Commit everything except .env
841
+ git add .devcontainer/ superposition.json
842
+ git commit -m "Add devcontainer configuration"
843
+ ```
844
+
845
+ **Team collaboration:**
846
+
847
+ ```bash
848
+ # Developer 1: Create and commit
849
+ npx container-superposition init --preset web-api --language nodejs
850
+ git add superposition.json .devcontainer/
851
+ git commit -m "Add devcontainer"
852
+
853
+ # Developer 2: Clone and use
854
+ git clone repo
855
+ code .
856
+ # VS Code: "Reopen in Container"
857
+ cp .devcontainer/.env.example .devcontainer/.env
858
+ # Customize .env with your values
859
+
860
+ # Developer 1: Update to add Redis
861
+ npx container-superposition init --from-manifest superposition.json
862
+ # Add redis in questionnaire
863
+ git add superposition.json .devcontainer/
864
+ git commit -m "Add Redis to devcontainer"
865
+
866
+ # Developer 2: Pull and regenerate
867
+ git pull
868
+ npx container-superposition regen
869
+ # VS Code: "Rebuild Container"
870
+ ```
871
+
872
+ See **[Team Workflow Guide](docs/team-workflow.md)** for manifest-only workflow and CI integration.
873
+
874
+ ## 📚 Examples
875
+
876
+ Real-world reference configurations to help you get started quickly.
877
+
878
+ ### [Web API (Node.js)](examples/web-api-node/)
879
+
880
+ Full-stack web API with complete observability:
881
+
882
+ - **Stack**: Node.js + PostgreSQL + Redis
883
+ - **Observability**: OpenTelemetry Collector + Prometheus + Grafana + Loki
884
+ - **Use case**: Production-ready web API development
885
+
886
+ Each example includes a `superposition.json` manifest. To use:
887
+
888
+ ```bash
889
+ cd examples/web-api-node
890
+ npx container-superposition regen
891
+ code .
892
+ # Reopen in Container
893
+ ```
894
+
895
+ ### [.NET Microservice](examples/dotnet-service/)
896
+
897
+ Microservice with distributed tracing and monitoring:
898
+
899
+ - **Stack**: .NET + PostgreSQL
900
+ - **Observability**: OpenTelemetry Collector + Jaeger + Prometheus
901
+ - **Use case**: Microservice development with full observability
902
+
903
+ ```bash
904
+ cd examples/dotnet-service
905
+ npx container-superposition regen
906
+ code .
907
+ # Reopen in Container
908
+ ```
909
+
910
+ Each example includes:
911
+
912
+ - ✅ `superposition.json` manifest for regeneration
913
+ - ✅ Complete documentation on services and usage
914
+ - ✅ Instructions for extending and customizing
915
+
916
+ **Want to create your own?** Generate a manifest with:
917
+
918
+ ```bash
919
+ npx container-superposition init --stack compose --language nodejs --database postgres
920
+ ```
921
+
566
922
  ### Preserving Project-Specific Customizations
567
923
 
568
924
  **Problem**: When you regenerate a devcontainer (to add overlays or update), manual customizations are lost.