@polymorphism-tech/morph-spec 1.0.4 → 2.1.0

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 (152) hide show
  1. package/CLAUDE.md +1381 -0
  2. package/LICENSE +72 -0
  3. package/README.md +89 -6
  4. package/bin/detect-agents.js +225 -0
  5. package/bin/morph-spec.js +120 -0
  6. package/bin/render-template.js +302 -0
  7. package/bin/semantic-detect-agents.js +246 -0
  8. package/bin/validate-agents-skills.js +239 -0
  9. package/bin/validate-agents.js +69 -0
  10. package/bin/validate-phase.js +263 -0
  11. package/content/.azure/README.md +293 -0
  12. package/content/.azure/docs/azure-devops-setup.md +454 -0
  13. package/content/.azure/docs/branch-strategy.md +398 -0
  14. package/content/.azure/docs/local-development.md +515 -0
  15. package/content/.azure/pipelines/pipeline-variables.yml +34 -0
  16. package/content/.azure/pipelines/prod-pipeline.yml +319 -0
  17. package/content/.azure/pipelines/staging-pipeline.yml +234 -0
  18. package/content/.azure/pipelines/templates/build-dotnet.yml +75 -0
  19. package/content/.azure/pipelines/templates/deploy-app-service.yml +94 -0
  20. package/content/.azure/pipelines/templates/deploy-container-app.yml +120 -0
  21. package/content/.azure/pipelines/templates/infra-deploy.yml +90 -0
  22. package/content/.claude/commands/morph-apply.md +118 -26
  23. package/content/.claude/commands/morph-archive.md +9 -9
  24. package/content/.claude/commands/morph-clarify.md +184 -0
  25. package/content/.claude/commands/morph-design.md +275 -0
  26. package/content/.claude/commands/morph-proposal.md +56 -15
  27. package/content/.claude/commands/morph-setup.md +100 -0
  28. package/content/.claude/commands/morph-status.md +47 -32
  29. package/content/.claude/commands/morph-tasks.md +319 -0
  30. package/content/.claude/commands/morph-uiux.md +211 -0
  31. package/content/.claude/skills/specialists/ai-system-architect.md +604 -0
  32. package/content/.claude/skills/specialists/ms-agent-expert.md +143 -89
  33. package/content/.claude/skills/specialists/ui-ux-designer.md +744 -9
  34. package/content/.claude/skills/stacks/dotnet-blazor.md +244 -8
  35. package/content/.claude/skills/stacks/dotnet-nextjs.md +2 -2
  36. package/content/.morph/.morphversion +5 -0
  37. package/content/.morph/config/agents.json +101 -8
  38. package/content/.morph/config/azure-pricing.json +70 -0
  39. package/content/.morph/config/azure-pricing.schema.json +50 -0
  40. package/content/.morph/config/config.template.json +15 -3
  41. package/content/.morph/docs/STORY-DRIVEN-DEVELOPMENT.md +392 -0
  42. package/content/.morph/hooks/README.md +239 -0
  43. package/content/.morph/hooks/pre-commit-agents.sh +24 -0
  44. package/content/.morph/hooks/pre-commit-all.sh +48 -0
  45. package/content/.morph/hooks/pre-commit-costs.sh +91 -0
  46. package/content/.morph/hooks/pre-commit-specs.sh +49 -0
  47. package/content/.morph/hooks/pre-commit-tests.sh +60 -0
  48. package/content/.morph/project.md +5 -4
  49. package/content/.morph/schemas/agent.schema.json +296 -0
  50. package/content/.morph/standards/agent-framework-setup.md +453 -0
  51. package/content/.morph/standards/architecture.md +142 -7
  52. package/content/.morph/standards/azure.md +218 -23
  53. package/content/.morph/standards/coding.md +47 -12
  54. package/content/.morph/standards/dotnet10-migration.md +494 -0
  55. package/content/.morph/standards/fluent-ui-setup.md +590 -0
  56. package/content/.morph/standards/migration-guide.md +514 -0
  57. package/content/.morph/standards/passkeys-auth.md +423 -0
  58. package/content/.morph/standards/vector-search-rag.md +536 -0
  59. package/content/.morph/state.json +18 -0
  60. package/content/.morph/templates/FluentDesignTheme.cs +149 -0
  61. package/content/.morph/templates/MudTheme.cs +281 -0
  62. package/content/.morph/templates/contracts.cs +55 -55
  63. package/content/.morph/templates/decisions.md +4 -4
  64. package/content/.morph/templates/design-system.css +226 -0
  65. package/content/.morph/templates/infra/.dockerignore.example +89 -0
  66. package/content/.morph/templates/infra/Dockerfile.example +82 -0
  67. package/content/.morph/templates/infra/README.md +286 -0
  68. package/content/.morph/templates/infra/app-service.bicep +164 -0
  69. package/content/.morph/templates/infra/deploy.ps1 +229 -0
  70. package/content/.morph/templates/infra/deploy.sh +208 -0
  71. package/content/.morph/templates/infra/main.bicep +41 -7
  72. package/content/.morph/templates/infra/parameters.dev.json +6 -0
  73. package/content/.morph/templates/infra/parameters.prod.json +6 -0
  74. package/content/.morph/templates/infra/parameters.staging.json +29 -0
  75. package/content/.morph/templates/proposal.md +3 -3
  76. package/content/.morph/templates/recap.md +3 -3
  77. package/content/.morph/templates/spec.md +9 -8
  78. package/content/.morph/templates/sprint-status.yaml +68 -0
  79. package/content/.morph/templates/state.template.json +222 -0
  80. package/content/.morph/templates/story.md +143 -0
  81. package/content/.morph/templates/tasks.md +1 -1
  82. package/content/.morph/templates/ui-components.md +276 -0
  83. package/content/.morph/templates/ui-design-system.md +286 -0
  84. package/content/.morph/templates/ui-flows.md +336 -0
  85. package/content/.morph/templates/ui-mockups.md +133 -0
  86. package/content/.morph/test-infra/example.bicep +59 -0
  87. package/content/CLAUDE.md +124 -0
  88. package/content/README.md +79 -0
  89. package/detectors/config-detector.js +223 -0
  90. package/detectors/conversation-analyzer.js +163 -0
  91. package/detectors/index.js +84 -0
  92. package/detectors/standards-generator.js +275 -0
  93. package/detectors/structure-detector.js +221 -0
  94. package/docs/README.md +149 -0
  95. package/docs/api/cost-calculator.js.html +513 -0
  96. package/docs/api/design-system-generator.js.html +382 -0
  97. package/docs/api/fonts/Montserrat/Montserrat-Bold.eot +0 -0
  98. package/docs/api/fonts/Montserrat/Montserrat-Bold.ttf +0 -0
  99. package/docs/api/fonts/Montserrat/Montserrat-Bold.woff +0 -0
  100. package/docs/api/fonts/Montserrat/Montserrat-Bold.woff2 +0 -0
  101. package/docs/api/fonts/Montserrat/Montserrat-Regular.eot +0 -0
  102. package/docs/api/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
  103. package/docs/api/fonts/Montserrat/Montserrat-Regular.woff +0 -0
  104. package/docs/api/fonts/Montserrat/Montserrat-Regular.woff2 +0 -0
  105. package/docs/api/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
  106. package/docs/api/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +978 -0
  107. package/docs/api/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
  108. package/docs/api/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
  109. package/docs/api/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
  110. package/docs/api/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
  111. package/docs/api/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +1049 -0
  112. package/docs/api/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
  113. package/docs/api/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
  114. package/docs/api/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
  115. package/docs/api/global.html +5263 -0
  116. package/docs/api/index.html +96 -0
  117. package/docs/api/scripts/collapse.js +39 -0
  118. package/docs/api/scripts/commonNav.js +28 -0
  119. package/docs/api/scripts/linenumber.js +25 -0
  120. package/docs/api/scripts/nav.js +12 -0
  121. package/docs/api/scripts/polyfill.js +4 -0
  122. package/docs/api/scripts/prettify/Apache-License-2.0.txt +202 -0
  123. package/docs/api/scripts/prettify/lang-css.js +2 -0
  124. package/docs/api/scripts/prettify/prettify.js +28 -0
  125. package/docs/api/scripts/search.js +99 -0
  126. package/docs/api/state-manager.js.html +423 -0
  127. package/docs/api/styles/jsdoc.css +776 -0
  128. package/docs/api/styles/prettify.css +80 -0
  129. package/docs/examples.md +328 -0
  130. package/docs/getting-started.md +302 -0
  131. package/docs/installation.md +361 -0
  132. package/docs/templates.md +418 -0
  133. package/docs/validation-checklist.md +266 -0
  134. package/package.json +39 -12
  135. package/src/commands/cost.js +181 -0
  136. package/src/commands/create-story.js +283 -0
  137. package/src/commands/detect.js +104 -0
  138. package/src/commands/doctor.js +67 -0
  139. package/src/commands/generate.js +149 -0
  140. package/src/commands/init.js +69 -45
  141. package/src/commands/shard-spec.js +224 -0
  142. package/src/commands/sprint-status.js +250 -0
  143. package/src/commands/state.js +333 -0
  144. package/src/commands/sync.js +167 -0
  145. package/src/commands/update-pricing.js +206 -0
  146. package/src/commands/update.js +88 -13
  147. package/src/lib/complexity-analyzer.js +292 -0
  148. package/src/lib/cost-calculator.js +429 -0
  149. package/src/lib/design-system-generator.js +298 -0
  150. package/src/lib/state-manager.js +340 -0
  151. package/src/utils/file-copier.js +59 -0
  152. package/src/utils/version-checker.js +175 -0
@@ -0,0 +1,226 @@
1
+ /**
2
+ * Design System - {Project Name}
3
+ *
4
+ * CSS Variables generated from ui-design-system.md
5
+ * Use estas variáveis em todo o projeto para manter consistência visual.
6
+ *
7
+ * Template MORPH-SPEC v2.1.1 by Polymorphism Tech
8
+ */
9
+
10
+ :root {
11
+ /* ========================================
12
+ * CORES PRINCIPAIS
13
+ * ======================================== */
14
+
15
+ --color-primary: #{hex da cor primária};
16
+ --color-primary-hover: #{hex da cor primária mais escura};
17
+ --color-primary-active: #{hex da cor primária ainda mais escura};
18
+
19
+ --color-secondary: #{hex da cor secundária};
20
+ --color-secondary-hover: #{hex};
21
+ --color-secondary-active: #{hex};
22
+
23
+ /* ========================================
24
+ * CORES DE ESTADO
25
+ * ======================================== */
26
+
27
+ --color-success: #{hex};
28
+ --color-success-bg: #{hex com transparência ou shade mais claro};
29
+ --color-success-border: #{hex};
30
+
31
+ --color-error: #{hex};
32
+ --color-error-bg: #{hex};
33
+ --color-error-border: #{hex};
34
+
35
+ --color-warning: #{hex};
36
+ --color-warning-bg: #{hex};
37
+ --color-warning-border: #{hex};
38
+
39
+ --color-info: #{hex};
40
+ --color-info-bg: #{hex};
41
+ --color-info-border: #{hex};
42
+
43
+ /* ========================================
44
+ * ESCALA DE NEUTROS (Cinzas)
45
+ * ======================================== */
46
+
47
+ --color-gray-50: #{hex};
48
+ --color-gray-100: #{hex};
49
+ --color-gray-200: #{hex};
50
+ --color-gray-300: #{hex};
51
+ --color-gray-400: #{hex};
52
+ --color-gray-500: #{hex};
53
+ --color-gray-600: #{hex};
54
+ --color-gray-700: #{hex};
55
+ --color-gray-800: #{hex};
56
+ --color-gray-900: #{hex};
57
+
58
+ /* ========================================
59
+ * TIPOGRAFIA - FONTES
60
+ * ======================================== */
61
+
62
+ --font-sans: '{Font Name}', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
63
+ --font-serif: '{Font Name}', Georgia, 'Times New Roman', serif;
64
+ --font-mono: '{Font Name}', 'Fira Code', 'Courier New', Consolas, monospace;
65
+
66
+ /* ========================================
67
+ * TIPOGRAFIA - TAMANHOS
68
+ * ======================================== */
69
+
70
+ --text-xs: 0.75rem; /* 12px */
71
+ --text-sm: 0.875rem; /* 14px */
72
+ --text-base: 1rem; /* 16px */
73
+ --text-lg: 1.125rem; /* 18px */
74
+ --text-xl: 1.25rem; /* 20px */
75
+ --text-2xl: 1.5rem; /* 24px */
76
+ --text-3xl: 1.875rem; /* 30px */
77
+ --text-4xl: 2.25rem; /* 36px */
78
+ --text-5xl: 3rem; /* 48px */
79
+
80
+ /* ========================================
81
+ * TIPOGRAFIA - LINE HEIGHTS
82
+ * ======================================== */
83
+
84
+ --leading-none: 1;
85
+ --leading-tight: 1.25;
86
+ --leading-snug: 1.375;
87
+ --leading-normal: 1.5;
88
+ --leading-relaxed: 1.625;
89
+ --leading-loose: 2;
90
+
91
+ /* ========================================
92
+ * TIPOGRAFIA - FONT WEIGHTS
93
+ * ======================================== */
94
+
95
+ --font-light: 300;
96
+ --font-regular: 400;
97
+ --font-medium: 500;
98
+ --font-semibold: 600;
99
+ --font-bold: 700;
100
+ --font-extrabold: 800;
101
+
102
+ /* ========================================
103
+ * ESPAÇAMENTO
104
+ * Baseado em múltiplos de {base}px (ex: 4px)
105
+ * ======================================== */
106
+
107
+ --space-0: 0;
108
+ --space-1: 0.25rem; /* 4px */
109
+ --space-2: 0.5rem; /* 8px */
110
+ --space-3: 0.75rem; /* 12px */
111
+ --space-4: 1rem; /* 16px */
112
+ --space-5: 1.25rem; /* 20px */
113
+ --space-6: 1.5rem; /* 24px */
114
+ --space-7: 1.75rem; /* 28px */
115
+ --space-8: 2rem; /* 32px */
116
+ --space-10: 2.5rem; /* 40px */
117
+ --space-12: 3rem; /* 48px */
118
+ --space-16: 4rem; /* 64px */
119
+ --space-20: 5rem; /* 80px */
120
+ --space-24: 6rem; /* 96px */
121
+
122
+ /* ========================================
123
+ * BORDER RADIUS
124
+ * ======================================== */
125
+
126
+ --rounded-none: 0;
127
+ --rounded-sm: 0.125rem; /* 2px */
128
+ --rounded-md: 0.375rem; /* 6px */
129
+ --rounded-lg: 0.5rem; /* 8px */
130
+ --rounded-xl: 0.75rem; /* 12px */
131
+ --rounded-2xl: 1rem; /* 16px */
132
+ --rounded-full: 9999px;
133
+
134
+ /* ========================================
135
+ * SOMBRAS (Shadows)
136
+ * ======================================== */
137
+
138
+ --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
139
+ --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
140
+ --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
141
+ --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
142
+ --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
143
+
144
+ /* ========================================
145
+ * Z-INDEX LAYERS
146
+ * ======================================== */
147
+
148
+ --z-0: 0;
149
+ --z-10: 10;
150
+ --z-20: 20;
151
+ --z-30: 30;
152
+ --z-40: 40;
153
+ --z-50: 50; /* Modals, dropdowns */
154
+ --z-100: 100; /* Tooltips */
155
+ --z-max: 9999; /* Toasts, notifications */
156
+
157
+ /* ========================================
158
+ * TRANSITIONS / ANIMATIONS
159
+ * ======================================== */
160
+
161
+ --transition-fast: 150ms ease-in-out;
162
+ --transition-base: 250ms ease-in-out;
163
+ --transition-slow: 350ms ease-in-out;
164
+
165
+ --ease-in: cubic-bezier(0.4, 0, 1, 1);
166
+ --ease-out: cubic-bezier(0, 0, 0.2, 1);
167
+ --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
168
+
169
+ /* ========================================
170
+ * BREAKPOINTS (informativo - usar em media queries)
171
+ * ======================================== */
172
+
173
+ /* @media (min-width: 640px) - sm */
174
+ /* @media (min-width: 768px) - md */
175
+ /* @media (min-width: 1024px) - lg */
176
+ /* @media (min-width: 1280px) - xl */
177
+ /* @media (min-width: 1536px) - 2xl */
178
+ }
179
+
180
+ /* ========================================
181
+ * MODO ESCURO (Dark Mode)
182
+ * Opcional - ajuste as cores para dark theme
183
+ * ======================================== */
184
+
185
+ @media (prefers-color-scheme: dark) {
186
+ :root {
187
+ /* Inverter cores conforme necessário */
188
+ --color-gray-50: #{hex do gray-900};
189
+ --color-gray-900: #{hex do gray-50};
190
+ /* ... outras inversões */
191
+ }
192
+ }
193
+
194
+ /* ========================================
195
+ * CLASSES UTILITÁRIAS (Exemplo)
196
+ * ======================================== */
197
+
198
+ /* Exemplo de uso das variáveis */
199
+ .btn-primary {
200
+ background-color: var(--color-primary);
201
+ color: white;
202
+ padding: var(--space-2) var(--space-4);
203
+ border-radius: var(--rounded-md);
204
+ font-weight: var(--font-semibold);
205
+ transition: background-color var(--transition-base);
206
+ }
207
+
208
+ .btn-primary:hover {
209
+ background-color: var(--color-primary-hover);
210
+ }
211
+
212
+ .card {
213
+ background-color: white;
214
+ padding: var(--space-6);
215
+ border-radius: var(--rounded-lg);
216
+ box-shadow: var(--shadow-md);
217
+ }
218
+
219
+ .text-muted {
220
+ color: var(--color-gray-600);
221
+ font-size: var(--text-sm);
222
+ }
223
+
224
+ /* ========================================
225
+ * FIM DO DESIGN SYSTEM
226
+ * ======================================== */
@@ -0,0 +1,89 @@
1
+ # ==============================================================================
2
+ # MORPH-SPEC - .dockerignore
3
+ # Exclude unnecessary files from Docker build context
4
+ # ==============================================================================
5
+
6
+ # Git
7
+ .git
8
+ .gitignore
9
+ .gitattributes
10
+
11
+ # CI/CD
12
+ .github
13
+ .azure
14
+ azure-pipelines.yml
15
+ .gitlab-ci.yml
16
+
17
+ # IDEs
18
+ .vs
19
+ .vscode
20
+ .idea
21
+ *.swp
22
+ *.swo
23
+ *~
24
+ .DS_Store
25
+
26
+ # Build outputs
27
+ **/bin/
28
+ **/obj/
29
+ **/out/
30
+ **/publish/
31
+
32
+ # NuGet
33
+ **/packages/
34
+ *.nupkg
35
+
36
+ # Test results
37
+ **/TestResults/
38
+ **/*.trx
39
+ **/*.coverage
40
+
41
+ # User-specific files
42
+ *.user
43
+ *.suo
44
+ *.userosscache
45
+ *.sln.docstates
46
+
47
+ # Documentation
48
+ *.md
49
+ docs/
50
+ README.md
51
+ LICENSE
52
+
53
+ # .morph framework files (excluded from container)
54
+ .morph/
55
+ CLAUDE.md
56
+
57
+ # Node modules (if using Tailwind, etc)
58
+ **/node_modules/
59
+ **/npm-debug.log
60
+
61
+ # Logs
62
+ **/logs/
63
+ *.log
64
+
65
+ # Database files
66
+ *.db
67
+ *.db-shm
68
+ *.db-wal
69
+
70
+ # Secrets (should never be in container)
71
+ **/*.Development.json
72
+ **/*.Local.json
73
+ **/*.secrets.json
74
+ .env
75
+ .env.local
76
+
77
+ # Windows files
78
+ Thumbs.db
79
+ ehthumbs.db
80
+ Desktop.ini
81
+ $RECYCLE.BIN/
82
+
83
+ # macOS files
84
+ .DS_Store
85
+ .AppleDouble
86
+ .LSOverride
87
+
88
+ # Azure
89
+ .azure/
@@ -0,0 +1,82 @@
1
+ # ==============================================================================
2
+ # MORPH-SPEC - .NET 8 Blazor Server Dockerfile
3
+ # Multi-stage build for production-ready container
4
+ # ==============================================================================
5
+
6
+ # ==============================================================================
7
+ # Stage 1: Base Runtime
8
+ # ==============================================================================
9
+ FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
10
+
11
+ # Set working directory
12
+ WORKDIR /app
13
+
14
+ # Expose ports
15
+ EXPOSE 8080
16
+ EXPOSE 8081
17
+
18
+ # Create non-root user for security
19
+ RUN adduser --disabled-password --gecos '' appuser && chown -R appuser /app
20
+ USER appuser
21
+
22
+ # ==============================================================================
23
+ # Stage 2: Build
24
+ # ==============================================================================
25
+ FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
26
+
27
+ # Set working directory
28
+ WORKDIR /src
29
+
30
+ # Copy project files
31
+ # Adjust paths according to your solution structure
32
+ COPY ["src/YourApp/YourApp.csproj", "src/YourApp/"]
33
+ COPY ["src/YourApp.Core/YourApp.Core.csproj", "src/YourApp.Core/"]
34
+ COPY ["src/YourApp.Infrastructure/YourApp.Infrastructure.csproj", "src/YourApp.Infrastructure/"]
35
+
36
+ # Restore dependencies
37
+ RUN dotnet restore "src/YourApp/YourApp.csproj"
38
+
39
+ # Copy all source code
40
+ COPY . .
41
+
42
+ # Build project
43
+ WORKDIR "/src/src/YourApp"
44
+ RUN dotnet build "YourApp.csproj" -c Release -o /app/build
45
+
46
+ # ==============================================================================
47
+ # Stage 3: Publish
48
+ # ==============================================================================
49
+ FROM build AS publish
50
+
51
+ # Publish application
52
+ RUN dotnet publish "YourApp.csproj" \
53
+ -c Release \
54
+ -o /app/publish \
55
+ /p:UseAppHost=false \
56
+ /p:PublishTrimmed=false \
57
+ /p:PublishSingleFile=false
58
+
59
+ # ==============================================================================
60
+ # Stage 4: Final
61
+ # ==============================================================================
62
+ FROM base AS final
63
+
64
+ # Set working directory
65
+ WORKDIR /app
66
+
67
+ # Copy published files from publish stage
68
+ COPY --from=publish /app/publish .
69
+
70
+ # Set environment variables
71
+ ENV ASPNETCORE_URLS=http://+:8080
72
+ ENV ASPNETCORE_ENVIRONMENT=Production
73
+ ENV DOTNET_RUNNING_IN_CONTAINER=true
74
+ ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false
75
+
76
+ # Health check endpoint
77
+ # Adjust path to match your health check endpoint
78
+ HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
79
+ CMD curl -f http://localhost:8080/health || exit 1
80
+
81
+ # Set entry point
82
+ ENTRYPOINT ["dotnet", "YourApp.dll"]
@@ -0,0 +1,286 @@
1
+ # MORPH-SPEC - Templates Bicep
2
+
3
+ Templates de infraestrutura para Azure com suporte a App Service e Container Apps.
4
+
5
+ ---
6
+
7
+ ## 🚀 Quick Start
8
+
9
+ ### 1. App Service Free (Desenvolvimento - $0/mês)
10
+
11
+ ```bash
12
+ # Deploy infraestrutura com App Service Free
13
+ az deployment group create \
14
+ --resource-group rg-myapp-dev \
15
+ --template-file main.bicep \
16
+ --parameters @parameters.dev.json \
17
+ --parameters appName=myapp
18
+ ```
19
+
20
+ ### 2. Container Apps (Produção - $5-15/mês)
21
+
22
+ ```bash
23
+ # Build e push imagem para ACR
24
+ az acr build \
25
+ --registry acrXXXX \
26
+ --image myapp:v1.0.0 \
27
+ --file Dockerfile \
28
+ .
29
+
30
+ # Deploy infraestrutura com Container Apps
31
+ az deployment group create \
32
+ --resource-group rg-myapp-prod \
33
+ --template-file main.bicep \
34
+ --parameters @parameters.prod.json \
35
+ --parameters appName=myapp
36
+ ```
37
+
38
+ ---
39
+
40
+ ## 📁 Estrutura de Arquivos
41
+
42
+ ```
43
+ infra/
44
+ ├── main.bicep # Entry point com lógica condicional
45
+ ├── parameters.dev.json # Params dev (App Service Free)
46
+ ├── parameters.prod.json # Params prod (Container Apps)
47
+ ├── app-service.bicep # Template App Service
48
+ ├── container-app.bicep # Template Container App
49
+ ├── container-app-env.bicep # Container Apps Environment
50
+ ├── sql-database.bicep # Azure SQL Database
51
+ ├── storage.bicep # Storage Account
52
+ ├── key-vault.bicep # Key Vault
53
+ └── app-insights.bicep # Application Insights
54
+ ```
55
+
56
+ ---
57
+
58
+ ## ⚙️ Parâmetros Principais
59
+
60
+ ### main.bicep
61
+
62
+ | Parâmetro | Tipo | Default | Descrição |
63
+ |-----------|------|---------|-----------|
64
+ | `environment` | string | `dev` | Ambiente (dev, staging, prod) |
65
+ | `appName` | string | **required** | Nome da aplicação (3-15 chars) |
66
+ | `location` | string | `resourceGroup().location` | Região Azure |
67
+ | `hostingType` | string | `appservice` | Tipo de hosting (`appservice` ou `containerapp`) |
68
+ | `appServiceSku` | string | `F1` | SKU do App Service (F1, B1, S1, P1v2) |
69
+ | `containerImage` | string | `mcr.microsoft.com/hello-world:latest` | Imagem Docker (apenas Container Apps) |
70
+ | `sqlAdminPassword` | securestring | **required** | Senha do SQL Server |
71
+
72
+ ---
73
+
74
+ ## 🌐 Escolhendo o Hosting Type
75
+
76
+ ### App Service (`hostingType: appservice`)
77
+
78
+ **Usar quando:**
79
+ - ✅ Orçamento zero (Free F1)
80
+ - ✅ MVP ou protótipo
81
+ - ✅ Tráfego baixo (<100 req/dia)
82
+ - ✅ App tolerante a cold starts (20 min sleep)
83
+ - ✅ Deploy simplificado (sem Docker)
84
+
85
+ **SKUs disponíveis:**
86
+ - `F1` (Free): $0/mês - 1GB RAM, 60 min CPU/dia, sleep após 20min
87
+ - `B1` (Basic): $13/mês - 1.75GB RAM, always-on
88
+ - `S1` (Standard): $70/mês - 1.75GB RAM, auto-scale, slots
89
+ - `P1v2` (Premium): $85/mês - 3.5GB RAM, melhor performance
90
+
91
+ ### Container Apps (`hostingType: containerapp`)
92
+
93
+ **Usar quando:**
94
+ - ✅ Produção com SLA 24/7
95
+ - ✅ Auto-scaling baseado em demanda
96
+ - ✅ SSL customizado necessário
97
+ - ✅ Background jobs (Hangfire)
98
+ - ✅ Arquitetura microserviços
99
+
100
+ **Custo:** $0-15/mês (scale-to-zero + consumo)
101
+
102
+ ---
103
+
104
+ ## 📝 Configuração por Ambiente
105
+
106
+ ### Development (parameters.dev.json)
107
+
108
+ ```json
109
+ {
110
+ "environment": { "value": "dev" },
111
+ "hostingType": { "value": "appservice" },
112
+ "appServiceSku": { "value": "F1" }
113
+ }
114
+ ```
115
+
116
+ **Infraestrutura:**
117
+ - App Service Free F1
118
+ - Azure SQL Free (32GB)
119
+ - App Insights Free (5GB)
120
+
121
+ **Custo total:** $0/mês
122
+
123
+ ### Staging (parameters.staging.json)
124
+
125
+ ```json
126
+ {
127
+ "environment": { "value": "staging" },
128
+ "hostingType": { "value": "containerapp" },
129
+ "minReplicas": { "value": 0 } // scale-to-zero
130
+ }
131
+ ```
132
+
133
+ **Infraestrutura:**
134
+ - Container Apps (scale-to-zero)
135
+ - Azure SQL Free (32GB)
136
+ - ACR Basic
137
+ - App Insights Free
138
+
139
+ **Custo total:** $5-10/mês
140
+
141
+ ### Production (parameters.prod.json)
142
+
143
+ ```json
144
+ {
145
+ "environment": { "value": "prod" },
146
+ "hostingType": { "value": "containerapp" },
147
+ "minReplicas": { "value": 1 } // always-on
148
+ }
149
+ ```
150
+
151
+ **Infraestrutura:**
152
+ - Container Apps (min 1 replica)
153
+ - Azure SQL Free (ou pago se necessário)
154
+ - ACR Basic
155
+ - App Insights (pode ultrapassar free tier)
156
+
157
+ **Custo total:** $10-20/mês
158
+
159
+ ---
160
+
161
+ ## 🔧 Customização
162
+
163
+ ### Adicionar variáveis de ambiente
164
+
165
+ **App Service:**
166
+ ```bicep
167
+ module appService 'app-service.bicep' = {
168
+ params: {
169
+ envVars: {
170
+ MY_CUSTOM_VAR: 'value'
171
+ ANOTHER_VAR: 'another-value'
172
+ }
173
+ }
174
+ }
175
+ ```
176
+
177
+ **Container Apps:**
178
+ ```bicep
179
+ module containerApp 'container-app.bicep' = {
180
+ params: {
181
+ envVars: [
182
+ {
183
+ name: 'MY_CUSTOM_VAR'
184
+ value: 'value'
185
+ }
186
+ ]
187
+ }
188
+ }
189
+ ```
190
+
191
+ ### Usar secrets do Key Vault
192
+
193
+ ```bicep
194
+ param sqlAdminPassword string {
195
+ reference: {
196
+ keyVault: {
197
+ id: '/subscriptions/.../providers/Microsoft.KeyVault/vaults/kv-myapp'
198
+ }
199
+ secretName: 'sql-admin-password'
200
+ }
201
+ }
202
+ ```
203
+
204
+ ---
205
+
206
+ ## 🔄 Migração App Service → Container Apps
207
+
208
+ Ver guia completo em: `../../standards/migration-guide.md`
209
+
210
+ **Resumo:**
211
+ 1. Criar Dockerfile
212
+ 2. Implementar health checks
213
+ 3. Build e push para ACR
214
+ 4. Atualizar `parameters.json` → `hostingType: containerapp`
215
+ 5. Redeploy
216
+ 6. Testar
217
+ 7. Cutover DNS
218
+
219
+ ---
220
+
221
+ ## 📊 Outputs Gerados
222
+
223
+ Após deploy, os seguintes outputs são gerados:
224
+
225
+ ```bash
226
+ # Obter URL da aplicação
227
+ az deployment group show \
228
+ -g rg-myapp-dev \
229
+ -n deployment-name \
230
+ --query properties.outputs.appUrl.value
231
+
232
+ # Obter connection string SQL
233
+ az deployment group show \
234
+ -g rg-myapp-dev \
235
+ -n deployment-name \
236
+ --query properties.outputs.sqlConnectionString.value
237
+
238
+ # Obter App Insights connection string
239
+ az deployment group show \
240
+ -g rg-myapp-dev \
241
+ -n deployment-name \
242
+ --query properties.outputs.appInsightsConnectionString.value
243
+ ```
244
+
245
+ ---
246
+
247
+ ## 🆘 Troubleshooting
248
+
249
+ ### Erro: "The template deployment 'X' is not valid"
250
+
251
+ Validar template:
252
+ ```bash
253
+ az deployment group validate \
254
+ --resource-group rg-myapp-dev \
255
+ --template-file main.bicep \
256
+ --parameters @parameters.dev.json
257
+ ```
258
+
259
+ ### Erro: "SKU not available in this location"
260
+
261
+ Verificar SKUs disponíveis:
262
+ ```bash
263
+ az appservice list-locations --sku F1
264
+ ```
265
+
266
+ ### Deploy muito lento
267
+
268
+ Container Apps pode levar 5-10 minutos no primeiro deploy. Use `--no-wait` para não bloquear:
269
+ ```bash
270
+ az deployment group create \
271
+ ... \
272
+ --no-wait
273
+ ```
274
+
275
+ ---
276
+
277
+ ## 📚 Referências
278
+
279
+ - [Bicep Documentation](https://learn.microsoft.com/azure/azure-resource-manager/bicep/)
280
+ - [App Service Bicep Reference](https://learn.microsoft.com/azure/templates/microsoft.web/sites)
281
+ - [Container Apps Bicep Reference](https://learn.microsoft.com/azure/templates/microsoft.app/containerapps)
282
+ - [Azure CLI Reference](https://learn.microsoft.com/cli/azure/)
283
+
284
+ ---
285
+
286
+ *MORPH-SPEC by Polymorphism Tech*