@aifabrix/builder 2.39.0 โ†’ 2.39.2

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.
@@ -1,367 +0,0 @@
1
- # Miso Controller Builder
2
-
3
- Build, run, and deploy Miso Controller using `@aifabrix/builder`.
4
-
5
- ---
6
-
7
- ## Quick Start
8
-
9
- ### 1. Install
10
-
11
- ```bash
12
- pnpm install -g @aifabrix/builder
13
- ```
14
-
15
- ### 2. First Time Setup
16
-
17
- ```bash
18
- # Check your environment
19
- aifabrix doctor
20
-
21
- # Login to controller
22
- aifabrix login --method device --environment dev --controller http://localhost:3110 --offline
23
-
24
- # Register your application (gets you credentials automatically)
25
- aifabrix app register miso-controller --environment miso --controller http://localhost:3100
26
- ```
27
-
28
- ### 3. Build & Run Locally
29
-
30
- ```bash
31
- # Build the Docker image
32
- aifabrix build miso-controller
33
-
34
- # Generate environment variables
35
- aifabrix resolve miso-controller
36
-
37
- # Run locally
38
- aifabrix run miso-controller
39
- ```
40
-
41
- **Access your app:** <http://dev.aifabrix:3000>
42
-
43
- **View logs:**
44
-
45
- ```bash
46
- docker logs aifabrix-miso-controller -f
47
- ```
48
-
49
- **Stop:**
50
-
51
- ```bash
52
- docker stop aifabrix-miso-controller
53
- ```
54
-
55
- ### 4. Deploy to Azure
56
-
57
- ```bash
58
- # Build with version tag
59
- aifabrix build miso-controller --tag v1.0.0
60
-
61
- # Push to registry
62
- aifabrix push miso-controller --registry myacr.azurecr.io --tag "v1.0.0,latest"
63
-
64
- # Deploy to miso-controller
65
- aifabrix deploy miso-controller --controller https://controller.aifabrix.ai --environment dev
66
- ```
67
-
68
- ---
69
-
70
- ## Using miso-client
71
-
72
- > [miso-client](https://github.com/esystemsdev/aifabrix-miso-client)
73
-
74
- After registering your app, you automatically get credentials in your secret file. Use miso-client for login, RBAC, audit logs, etc.
75
-
76
- **Rotate credentials if needed:**
77
-
78
- ```bash
79
- aifabrix app rotate-secret miso-controller --environment dev
80
- ```
81
-
82
- ---
83
-
84
- ## Reference
85
-
86
- ### Common Commands
87
-
88
- ```bash
89
- # Development
90
- aifabrix build miso-controller # Build app
91
- aifabrix run miso-controller # Run locally
92
- aifabrix dockerfile miso-controller --force # Generate Dockerfile
93
- aifabrix resolve miso-controller # Generate .env file
94
-
95
- # Deployment
96
- aifabrix json miso-controller # Generate deployment manifest
97
- aifabrix push miso-controller --registry myacr.azurecr.io # Push to ACR
98
- aifabrix deploy miso-controller --controller <url> # Deploy to Azure
99
-
100
- # Management
101
- aifabrix app register miso-controller --environment dev
102
- aifabrix app list --environment dev
103
- aifabrix app rotate-secret miso-controller --environment dev
104
-
105
- # Utilities
106
- aifabrix doctor # Check environment
107
- aifabrix login --method device --environment dev # Login
108
- aifabrix --help # Get help
109
- ```
110
-
111
- ### Build Options
112
-
113
- ```bash
114
- aifabrix build miso-controller --tag v1.0.0 # Custom tag
115
- aifabrix build miso-controller --force-template # Force template regeneration
116
- aifabrix build miso-controller --language typescript # Override language detection
117
- ```
118
-
119
- ### Run Options
120
-
121
- ```bash
122
- aifabrix run miso-controller --port 3000 # Custom port
123
- aifabrix run miso-controller --debug # Debug output
124
- ```
125
-
126
- ### Push Options
127
-
128
- ```bash
129
- aifabrix push miso-controller --registry myacr.azurecr.io --tag v1.0.0
130
- aifabrix push miso-controller --registry myacr.azurecr.io --tag "v1.0.0,latest,stable"
131
- ```
132
-
133
- ### Deploy Options
134
-
135
- ```bash
136
- aifabrix deploy miso-controller --controller <url> --environment dev
137
- aifabrix deploy miso-controller --controller <url> --environment dev --no-poll
138
- ```
139
-
140
- ### Login Methods
141
-
142
- ```bash
143
- # Device code flow
144
- aifabrix login --method device --environment dev
145
-
146
- # Credentials (reads from secrets.local.yaml)
147
- aifabrix login --method credentials --app miso-controller --environment dev
148
-
149
- # Explicit credentials
150
- aifabrix login --method credentials --app miso-controller --client-id $CLIENT_ID --client-secret $CLIENT_SECRET --environment dev
151
- ```
152
-
153
- ### Environment Variables
154
-
155
- ```bash
156
- export AIFABRIX_HOME=/custom/path
157
- export AIFABRIX_SECRETS=/path/to/secrets.yaml
158
- ```
159
-
160
- #### Rate Limiting Configuration
161
-
162
- For local development, you can disable or configure rate limiting to avoid HTTP 429 errors:
163
-
164
- ```bash
165
- # Disable rate limiting entirely (local development only)
166
- export DISABLE_RATE_LIMIT=true
167
-
168
- # Or configure rate limits
169
- export RATE_LIMIT_WINDOW_MS=900000 # 15 minutes in milliseconds (default: 900000)
170
- export RATE_LIMIT_MAX=100 # Max requests per window (default: 100)
171
- ```
172
-
173
- **Note:** Disabling rate limiting should only be used for local development. Production deployments should always have rate limiting enabled.
174
-
175
- ---
176
-
177
- ## Troubleshooting
178
-
179
- ### Common Issues
180
-
181
- - **"Docker not running"** โ†’ Start Docker Desktop
182
- - **"Not logged in"** โ†’ Run `aifabrix login` first
183
- - **"Port already in use"** โ†’ Use `--port` flag or change `build.localPort` in `variables.yaml` (default: 3000)
184
- - **"Authentication failed"** โ†’ Run `aifabrix login` again
185
- - **"Build fails"** โ†’ Check Docker is running and `variables.yaml` โ†’ `build.secrets` path is correct
186
- - **"Can't connect"** โ†’ Verify infrastructure is running and PostgreSQL is accessible
187
-
188
- #### Authentication Token Validation Issues
189
-
190
- If you get "Authentication Failed" or "Your authentication token is invalid or has expired" when using Docker:
191
-
192
- **Problem**: Token validation fails because the token's issuer (`iss` claim) doesn't match the Keycloak URL configured in the Docker container.
193
-
194
- **Solution**:
195
-
196
- 1. **Ensure `keycloak-public-server-urlKeyVault` is set correctly**:
197
-
198
- ```bash
199
- # Check your Keycloak port (typically 8182 for dev01)
200
- docker ps | grep keycloak
201
-
202
- # Set the public Keycloak URL to match your Keycloak instance
203
- aifabrix secrets set keycloak-public-server-urlKeyVault "http://localhost:8182"
204
- ```
205
-
206
- 2. **Login with the same Keycloak URL that Docker uses**:
207
-
208
- ```bash
209
- # Login using the Keycloak URL that matches your Docker container's configuration
210
- # The token issuer must match KEYCLOAK_PUBLIC_SERVER_URL in the container
211
- aifabrix login --method device --environment miso --controller http://localhost:3100 --offline
212
- ```
213
-
214
- 3. **Verify Keycloak configuration in Docker**:
215
-
216
- ```bash
217
- # Check what Keycloak URL the Docker container is using
218
- docker exec aifabrix-dev01-miso-controller env | grep KEYCLOAK_PUBLIC_SERVER_URL
219
- ```
220
-
221
- 4. **Restart Docker container after changing secrets**:
222
- ```bash
223
- # Regenerate environment variables and restart
224
- aifabrix resolve miso-controller --force
225
- docker restart aifabrix-dev01-miso-controller
226
- ```
227
-
228
- **Root Cause**: When you login with `aifabrix login --controller http://localhost:3110`, the token is issued with an issuer URL. If the Docker container (port 3100) has a different `KEYCLOAK_PUBLIC_SERVER_URL` configured, token validation will fail because the issuer doesn't match.
229
-
230
- **IMPORTANT**: After making any changes to secrets or environment variables:
231
-
232
- 1. **Regenerate environment variables**:
233
-
234
- ```bash
235
- aifabrix resolve miso-controller --force
236
- ```
237
-
238
- 2. **Restart the Docker container**:
239
-
240
- ```bash
241
- docker restart aifabrix-dev01-miso-controller
242
- ```
243
-
244
- 3. **Login again with the Docker container URL** (to get a token with the correct issuer):
245
-
246
- ```bash
247
- # Clear any existing tokens first
248
- aifabrix logout
249
-
250
- # Login with the Docker container URL
251
- aifabrix login --method device --environment miso --controller http://localhost:3100 --offline
252
- ```
253
-
254
- 4. **Verify the token works**:
255
- ```bash
256
- # Try registering again
257
- aifabrix app register miso-controller --environment miso --controller http://localhost:3100
258
- ```
259
-
260
- **Debugging**: If authentication still fails, check the Docker logs for detailed error messages:
261
-
262
- ```bash
263
- docker logs aifabrix-dev01-miso-controller --tail 50 | grep -i "auth\|token\|keycloak"
264
- ```
265
-
266
- ### Deployment Issues
267
-
268
- #### Mock Mode Configuration
269
-
270
- If deployments are not creating actual Azure resources, check the `MOCK` environment variable:
271
-
272
- ```bash
273
- # In env.template or .env file
274
- MOCK=false # Must be false for production deployments
275
- ```
276
-
277
- **Symptoms:**
278
-
279
- - Logs show `[AzureClientFactory] isMockMode() called - returning true`
280
- - No actual Azure resources are created
281
- - Deployment appears to succeed but resources don't exist
282
-
283
- **Solution:**
284
-
285
- - Set `MOCK=false` in your environment configuration for production deployments
286
- - Only use `MOCK=true` for local development/testing when you don't want to create real Azure resources
287
-
288
- #### Azure Permission Errors
289
-
290
- If you see permission denied errors during deployment:
291
-
292
- ```
293
- Permission denied: Service principal does not have permission to assign roles.
294
- Grant "User Access Administrator" or "Owner" role to the service principal
295
- ```
296
-
297
- **Solution:**
298
-
299
- - Grant the service principal (identified by `AZURE_CLIENT_ID`) one of these roles:
300
- - **User Access Administrator** (recommended for least privilege)
301
- - **Owner** (full access, use with caution)
302
- - Assign the role at either:
303
- - Subscription level (for all resource groups)
304
- - Resource group level (for specific resource groups)
305
-
306
- **Azure CLI commands:**
307
-
308
- ```bash
309
- # Get service principal object ID
310
- az ad sp show --id <AZURE_CLIENT_ID> --query id -o tsv
311
-
312
- # Assign User Access Administrator role at subscription level
313
- az role assignment create \
314
- --assignee <SERVICE_PRINCIPAL_OBJECT_ID> \
315
- --role "User Access Administrator" \
316
- --scope /subscriptions/<SUBSCRIPTION_ID>
317
-
318
- # Or assign at resource group level
319
- az role assignment create \
320
- --assignee <SERVICE_PRINCIPAL_OBJECT_ID> \
321
- --role "User Access Administrator" \
322
- --scope /subscriptions/<SUBSCRIPTION_ID>/resourceGroups/<RESOURCE_GROUP_NAME>
323
- ```
324
-
325
- #### Secret Not Found Errors
326
-
327
- If deployment fails with "Secret not found" errors:
328
-
329
- ```
330
- Failed to getSecret postgres-adminPassword: Secret not found
331
- ```
332
-
333
- **Possible causes:**
334
-
335
- 1. Secret doesn't exist in Key Vault
336
- 2. Secret name mismatch (e.g., `postgres-adminPassword` vs `postgres-admin-password`)
337
- 3. Service principal doesn't have Key Vault access
338
-
339
- **Solution:**
340
-
341
- - Verify the secret exists in Key Vault with the correct name
342
- - Ensure the service principal has "Key Vault Secrets User" role on the Key Vault
343
- - Check secret naming convention matches infrastructure deployment (typically `{prefix}-postgres-admin-password`)
344
-
345
- **Regenerate files:**
346
-
347
- ```bash
348
- aifabrix resolve miso-controller --force
349
- aifabrix json miso-controller
350
- ```
351
-
352
- ---
353
-
354
- ## Prerequisites
355
-
356
- - `@aifabrix/builder` installed globally
357
- - Docker Desktop running
358
- - Azure CLI installed (for push command)
359
- - Authenticated with controller (for deploy command)
360
- - PostgreSQL database (ensure infrastructure is running)
361
- - Redis (ensure infrastructure is running)
362
- - File storage configured
363
- - Authentication/RBAC configured
364
-
365
- ---
366
-
367
- **Application**: miso-controller | **Port**: 3000 | **Registry**: myacr.azurecr.io | **Image**: aifabrix/miso-controller:latest
@@ -1,34 +0,0 @@
1
- # Deploy {{systemKey}} external system and datasources using aifabrix CLI
2
-
3
- $ErrorActionPreference = "Stop"
4
-
5
- $SCRIPT_DIR = $PSScriptRoot
6
- $env:ENVIRONMENT = if ($env:ENVIRONMENT) { $env:ENVIRONMENT } else { "dev" }
7
- $env:CONTROLLER = if ($env:CONTROLLER) { $env:CONTROLLER } else { "http://localhost:3000" }
8
-
9
- Write-Host "๐Ÿ” Validating {{systemKey}} configuration files..."
10
- {{#each allJsonFiles}}
11
- aifabrix validate "${SCRIPT_DIR}\{{this}}"
12
- if ($LASTEXITCODE -ne 0) { exit 1 }
13
- {{/each}}
14
-
15
- Write-Host "โœ… Validation passed"
16
-
17
- Write-Host "๐Ÿš€ Deploying {{systemKey}} external system and datasources..."
18
- Write-Host " Environment: $env:ENVIRONMENT"
19
- Write-Host " Controller: $env:CONTROLLER"
20
-
21
- # Deploy datasources
22
- {{#each datasourceFileNames}}
23
- aifabrix datasource deploy {{../systemKey}} "${SCRIPT_DIR}\{{this}}" --environment $env:ENVIRONMENT --controller $env:CONTROLLER
24
- if ($LASTEXITCODE -ne 0) { exit 1 }
25
- {{/each}}
26
-
27
- Write-Host "โœ… Deployment complete"
28
-
29
- # Optional: Run tests
30
- if ($env:RUN_TESTS -eq "true") {
31
- Write-Host "๐Ÿงช Running integration tests..."
32
- aifabrix test-integration {{systemKey}} --environment $env:ENVIRONMENT --controller $env:CONTROLLER
33
- }
34
-
@@ -1,34 +0,0 @@
1
- #!/bin/bash
2
- # Deploy {{systemKey}} external system and datasources using aifabrix CLI
3
-
4
- set -e
5
-
6
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
7
- ENVIRONMENT="${ENVIRONMENT:-dev}"
8
- CONTROLLER="${CONTROLLER:-http://localhost:3000}"
9
-
10
- echo "๐Ÿ” Validating {{systemKey}} configuration files..."
11
- {{#each allJsonFiles}}
12
- aifabrix validate "${SCRIPT_DIR}/{{this}}" || exit 1
13
- {{/each}}
14
-
15
- echo "โœ… Validation passed"
16
-
17
- echo "๐Ÿš€ Deploying {{systemKey}} external system and datasources..."
18
- echo " Environment: ${ENVIRONMENT}"
19
- echo " Controller: ${CONTROLLER}"
20
-
21
- # Deploy datasources
22
- {{#each datasourceFileNames}}
23
- aifabrix datasource deploy {{../systemKey}} "${SCRIPT_DIR}/{{this}}" \
24
- --environment "${ENVIRONMENT}" --controller "${CONTROLLER}" || exit 1
25
- {{/each}}
26
-
27
- echo "โœ… Deployment complete"
28
-
29
- # Optional: Run tests
30
- if [ "${RUN_TESTS:-false}" = "true" ]; then
31
- echo "๐Ÿงช Running integration tests..."
32
- aifabrix test-integration {{systemKey}} --environment "${ENVIRONMENT}" --controller "${CONTROLLER}"
33
- fi
34
-