@aifabrix/builder 2.0.0 → 2.0.3
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.
- package/README.md +5 -3
- package/bin/aifabrix.js +9 -3
- package/jest.config.integration.js +30 -0
- package/lib/app-config.js +157 -0
- package/lib/app-deploy.js +233 -82
- package/lib/app-dockerfile.js +112 -0
- package/lib/app-prompts.js +244 -0
- package/lib/app-push.js +172 -0
- package/lib/app-run.js +235 -144
- package/lib/app.js +208 -274
- package/lib/audit-logger.js +2 -0
- package/lib/build.js +177 -125
- package/lib/cli.js +76 -86
- package/lib/commands/app.js +414 -0
- package/lib/commands/login.js +304 -0
- package/lib/config.js +78 -0
- package/lib/deployer.js +225 -81
- package/lib/env-reader.js +45 -30
- package/lib/generator.js +308 -191
- package/lib/github-generator.js +67 -7
- package/lib/infra.js +156 -61
- package/lib/push.js +105 -10
- package/lib/schema/application-schema.json +30 -2
- package/lib/schema/env-config.yaml +9 -1
- package/lib/schema/infrastructure-schema.json +589 -0
- package/lib/secrets.js +229 -24
- package/lib/template-validator.js +205 -0
- package/lib/templates.js +305 -170
- package/lib/utils/api.js +329 -0
- package/lib/utils/cli-utils.js +97 -0
- package/lib/utils/compose-generator.js +185 -0
- package/lib/utils/docker-build.js +173 -0
- package/lib/utils/dockerfile-utils.js +131 -0
- package/lib/utils/environment-checker.js +125 -0
- package/lib/utils/error-formatter.js +61 -0
- package/lib/utils/health-check.js +187 -0
- package/lib/utils/logger.js +53 -0
- package/lib/utils/template-helpers.js +223 -0
- package/lib/utils/variable-transformer.js +271 -0
- package/lib/validator.js +27 -112
- package/package.json +14 -10
- package/templates/README.md +75 -3
- package/templates/applications/keycloak/Dockerfile +36 -0
- package/templates/applications/keycloak/env.template +32 -0
- package/templates/applications/keycloak/rbac.yaml +37 -0
- package/templates/applications/keycloak/variables.yaml +56 -0
- package/templates/applications/miso-controller/Dockerfile +125 -0
- package/templates/applications/miso-controller/env.template +129 -0
- package/templates/applications/miso-controller/rbac.yaml +214 -0
- package/templates/applications/miso-controller/variables.yaml +56 -0
- package/templates/github/release.yaml.hbs +5 -26
- package/templates/github/steps/npm.hbs +24 -0
- package/templates/infra/compose.yaml +6 -6
- package/templates/python/docker-compose.hbs +19 -12
- package/templates/python/main.py +80 -0
- package/templates/python/requirements.txt +4 -0
- package/templates/typescript/Dockerfile.hbs +2 -2
- package/templates/typescript/docker-compose.hbs +19 -12
- package/templates/typescript/index.ts +116 -0
- package/templates/typescript/package.json +26 -0
- package/templates/typescript/tsconfig.json +24 -0
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# Environment Variables Template
|
|
2
|
+
# Use kv:// references for secrets (resolved from secrets.local.yaml)
|
|
3
|
+
# Use ${VAR} for environment-specific values
|
|
4
|
+
|
|
5
|
+
# =============================================================================
|
|
6
|
+
# APPLICATION ENVIRONMENT
|
|
7
|
+
# =============================================================================
|
|
8
|
+
|
|
9
|
+
NODE_ENV=development
|
|
10
|
+
PORT=3000
|
|
11
|
+
AUTO_CREATE_TABLES=true
|
|
12
|
+
FAST_STARTUP=false
|
|
13
|
+
ALLOWED_ORIGINS=http://localhost:3000,http://localhost:5173
|
|
14
|
+
ENABLE_API_DOCS=true
|
|
15
|
+
|
|
16
|
+
# Package Version (auto-set by npm/pnpm, optional override)
|
|
17
|
+
# npm_package_version=1.0.0
|
|
18
|
+
|
|
19
|
+
# =============================================================================
|
|
20
|
+
# DATABASE CONFIGURATION
|
|
21
|
+
# =============================================================================
|
|
22
|
+
# Connects to external postgres from aifabrix-setup
|
|
23
|
+
|
|
24
|
+
DATABASE_URL=kv://databases-miso-controller-0-urlKeyVault
|
|
25
|
+
DATABASELOG_URL=kv://databases-miso-controller-1-urlKeyVault
|
|
26
|
+
MISO_ADMIN_PASSWORD=kv://miso-controller-admin-passwordKeyVault
|
|
27
|
+
|
|
28
|
+
# =============================================================================
|
|
29
|
+
# REDIS CONFIGURATION
|
|
30
|
+
# =============================================================================
|
|
31
|
+
# Connects to external redis from aifabrix-setup
|
|
32
|
+
|
|
33
|
+
REDIS_URL=kv://redis-urlKeyVault
|
|
34
|
+
REDIS_HOST=localhost
|
|
35
|
+
REDIS_PORT=6379
|
|
36
|
+
REDIS_PASSWORD=kv://redis-passwordKeyVault
|
|
37
|
+
REDIS_DB=0
|
|
38
|
+
REDIS_KEY_PREFIX=miso
|
|
39
|
+
REDIS_ROLES_TTL=900
|
|
40
|
+
REDIS_PERMISSIONS_TTL=900
|
|
41
|
+
|
|
42
|
+
# =============================================================================
|
|
43
|
+
# KEYCLOAK CONFIGURATION
|
|
44
|
+
# =============================================================================
|
|
45
|
+
# Connects to external keycloak from aifabrix-setup
|
|
46
|
+
|
|
47
|
+
KEYCLOAK_REALM=aifabrix
|
|
48
|
+
KEYCLOAK_AUTH_SERVER_URL=kv://keycloak-auth-server-urlKeyVault
|
|
49
|
+
KEYCLOAK_CLIENT_ID=miso-controller
|
|
50
|
+
KEYCLOAK_CLIENT_SECRET=kv://keycloak-client-secretKeyVault
|
|
51
|
+
KEYCLOAK_ADMIN_USERNAME=admin
|
|
52
|
+
KEYCLOAK_ADMIN_PASSWORD=kv://keycloak-admin-passwordKeyVault
|
|
53
|
+
KEYCLOAK_PUBLIC_KEY=
|
|
54
|
+
KEYCLOAK_VERIFY_AUDIENCE=false
|
|
55
|
+
KEYCLOAK_TOKEN_TIMEOUT=5000
|
|
56
|
+
KEYCLOAK_DEFAULT_PASSWORD=kv://keycloak-admin-passwordKeyVault
|
|
57
|
+
|
|
58
|
+
# Keycloak Events Configuration
|
|
59
|
+
KEYCLOAK_EVENTS_ENABLED=true
|
|
60
|
+
KEYCLOAK_EVENTS_VERIFY_SIGNATURE=true
|
|
61
|
+
KEYCLOAK_EVENTS_SECRET=kv://keycloak-events-secretKeyVault
|
|
62
|
+
|
|
63
|
+
# =============================================================================
|
|
64
|
+
# AZURE AD PROVIDER CONFIGURATION
|
|
65
|
+
# =============================================================================
|
|
66
|
+
|
|
67
|
+
AZURE_SUBSCRIPTION_ID=kv://azure-subscription-idKeyVault
|
|
68
|
+
AZURE_TENANT_ID=kv://azure-tenant-idKeyVault
|
|
69
|
+
AZURE_SERVICE_NAME=kv://azure-service-nameKeyVault
|
|
70
|
+
MOCK=true
|
|
71
|
+
AZURE_CLIENT_ID=kv://azure-client-idKeyVault
|
|
72
|
+
AZURE_CLIENT_SECRET=kv://azure-client-secretKeyVault
|
|
73
|
+
|
|
74
|
+
# Mock Mode (set to false for production)
|
|
75
|
+
MOCK=true
|
|
76
|
+
|
|
77
|
+
# =============================================================================
|
|
78
|
+
# SECURITY & ENCRYPTION
|
|
79
|
+
# =============================================================================
|
|
80
|
+
|
|
81
|
+
# Encryption Key for Database Secrets
|
|
82
|
+
ENCRYPTION_KEY=kv://secrets-encryptionKeyVault
|
|
83
|
+
|
|
84
|
+
# JWT Configuration (for client token generation)
|
|
85
|
+
JWT_SECRET=kv://miso-controller-jwt-secretKeyVault
|
|
86
|
+
|
|
87
|
+
# When API_KEY is set, a matching Bearer token bypasses OAuth2 validation
|
|
88
|
+
API_KEY=kv://miso-controller-api-key-secretKeyVault
|
|
89
|
+
|
|
90
|
+
# =============================================================================
|
|
91
|
+
# MISO CONTROLLER CONFIGURATION
|
|
92
|
+
# =============================================================================
|
|
93
|
+
|
|
94
|
+
# MISO Controller URL
|
|
95
|
+
MISO_CONTROLLER_URL=kv://miso-controller-url
|
|
96
|
+
|
|
97
|
+
# Web Server URL (for OpenAPI documentation server URLs)
|
|
98
|
+
# Used to generate correct server URLs in OpenAPI spec
|
|
99
|
+
WEB_SERVER_URL=kv ://web-server-url
|
|
100
|
+
|
|
101
|
+
# MISO Environment Configuration (miso, dev, tst, pro)
|
|
102
|
+
MISO_ENVIRONMENT=miso
|
|
103
|
+
|
|
104
|
+
# MISO Application Client Credentials (per application)
|
|
105
|
+
MISO_CLIENTID=kv ://miso-client-idKeyVault
|
|
106
|
+
MISO_CLIENTSECRET=kv ://miso-client-secretKeyVault
|
|
107
|
+
|
|
108
|
+
# =============================================================================
|
|
109
|
+
# MORI SERVICE CONFIGURATION
|
|
110
|
+
# =============================================================================
|
|
111
|
+
|
|
112
|
+
MORI_BASE_URL=kv://mori-base-urlKeyVault
|
|
113
|
+
MORI_API_KEY=kv ://mori-api-keyKeyVault
|
|
114
|
+
|
|
115
|
+
# =============================================================================
|
|
116
|
+
# LOGGING CONFIGURATION
|
|
117
|
+
# =============================================================================
|
|
118
|
+
|
|
119
|
+
LOG_TO_FILE=true
|
|
120
|
+
LOG_FILE_PATH=/mnt/data/logs
|
|
121
|
+
|
|
122
|
+
# =============================================================================
|
|
123
|
+
# STORAGE CONFIGURATION
|
|
124
|
+
# =============================================================================
|
|
125
|
+
|
|
126
|
+
# Mount Volume Configuration
|
|
127
|
+
MOUNT_VOLUME=C:/git/esystemsdev/aifabrix-miso/mount
|
|
128
|
+
|
|
129
|
+
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
roles:
|
|
2
|
+
- name: "AI Fabrix Platform Admin"
|
|
3
|
+
value: "aifabrix-platform-admin"
|
|
4
|
+
description: "Full platform infrastructure management and enterprise controller access"
|
|
5
|
+
Groups: ["AI-Fabrix-Platform-Admins"]
|
|
6
|
+
|
|
7
|
+
- name: "AI Fabrix Security Admin"
|
|
8
|
+
value: "aifabrix-security-admin"
|
|
9
|
+
description: "Security and compliance management for enterprise controller"
|
|
10
|
+
Groups: ["AI-Fabrix-Security-Admins"]
|
|
11
|
+
|
|
12
|
+
- name: "AI Fabrix Infrastructure Admin"
|
|
13
|
+
value: "aifabrix-infrastructure-admin"
|
|
14
|
+
description: "Infrastructure deployment and management across environments"
|
|
15
|
+
Groups: ["AI-Fabrix-Infrastructure-Admins"]
|
|
16
|
+
|
|
17
|
+
- name: "AI Fabrix Deployment Admin"
|
|
18
|
+
value: "aifabrix-deployment-admin"
|
|
19
|
+
description: "Application deployment orchestration and environment management"
|
|
20
|
+
Groups: ["AI-Fabrix-Deployment-Admins"]
|
|
21
|
+
|
|
22
|
+
- name: "AI Fabrix Compliance Admin"
|
|
23
|
+
value: "aifabrix-compliance-admin"
|
|
24
|
+
description: "ISO 27001 compliance monitoring and audit management"
|
|
25
|
+
Groups: ["AI-Fabrix-Compliance-Admins"]
|
|
26
|
+
|
|
27
|
+
- name: "AI Fabrix Developer"
|
|
28
|
+
value: "aifabrix-developer"
|
|
29
|
+
description: "Developer access to deploy applications via GitHub Actions"
|
|
30
|
+
Groups: ["AI-Fabrix-Developers"]
|
|
31
|
+
|
|
32
|
+
- name: "AI Fabrix Observer"
|
|
33
|
+
value: "aifabrix-observer"
|
|
34
|
+
description: "Read-only access to monitoring, logs, and compliance reports"
|
|
35
|
+
Groups: ["AI-Fabrix-Observers"]
|
|
36
|
+
|
|
37
|
+
permissions:
|
|
38
|
+
# Service User Management
|
|
39
|
+
- name: "service-user:create"
|
|
40
|
+
roles: ["aifabrix-platform-admin", "aifabrix-security-admin"]
|
|
41
|
+
description: "Create service users and API clients"
|
|
42
|
+
|
|
43
|
+
- name: "service-user:read"
|
|
44
|
+
roles: ["aifabrix-platform-admin", "aifabrix-security-admin", "aifabrix-observer"]
|
|
45
|
+
description: "View service users and their configurations"
|
|
46
|
+
|
|
47
|
+
- name: "service-user:update"
|
|
48
|
+
roles: ["aifabrix-platform-admin", "aifabrix-security-admin"]
|
|
49
|
+
description: "Update service user configurations and regenerate secrets"
|
|
50
|
+
|
|
51
|
+
- name: "service-user:delete"
|
|
52
|
+
roles: ["aifabrix-platform-admin", "aifabrix-security-admin"]
|
|
53
|
+
description: "Deactivate service users"
|
|
54
|
+
|
|
55
|
+
# User Management
|
|
56
|
+
- name: "users:create"
|
|
57
|
+
roles: ["aifabrix-platform-admin", "aifabrix-security-admin"]
|
|
58
|
+
description: "Create new users"
|
|
59
|
+
|
|
60
|
+
- name: "users:read"
|
|
61
|
+
roles: ["aifabrix-platform-admin", "aifabrix-security-admin", "aifabrix-observer"]
|
|
62
|
+
description: "View user information and profiles"
|
|
63
|
+
|
|
64
|
+
- name: "users:update"
|
|
65
|
+
roles: ["aifabrix-platform-admin", "aifabrix-security-admin"]
|
|
66
|
+
description: "Update user information and manage group memberships"
|
|
67
|
+
|
|
68
|
+
- name: "users:delete"
|
|
69
|
+
roles: ["aifabrix-platform-admin", "aifabrix-security-admin"]
|
|
70
|
+
description: "Delete users"
|
|
71
|
+
|
|
72
|
+
# Group Management
|
|
73
|
+
- name: "groups:create"
|
|
74
|
+
roles: ["aifabrix-platform-admin", "aifabrix-security-admin"]
|
|
75
|
+
description: "Create new groups"
|
|
76
|
+
|
|
77
|
+
- name: "groups:read"
|
|
78
|
+
roles: ["aifabrix-platform-admin", "aifabrix-security-admin", "aifabrix-observer"]
|
|
79
|
+
description: "View group information and members"
|
|
80
|
+
|
|
81
|
+
- name: "groups:update"
|
|
82
|
+
roles: ["aifabrix-platform-admin", "aifabrix-security-admin"]
|
|
83
|
+
description: "Update group information"
|
|
84
|
+
|
|
85
|
+
- name: "groups:delete"
|
|
86
|
+
roles: ["aifabrix-platform-admin", "aifabrix-security-admin"]
|
|
87
|
+
description: "Delete groups"
|
|
88
|
+
|
|
89
|
+
# Administrative Permissions
|
|
90
|
+
- name: "admin:read"
|
|
91
|
+
roles: ["aifabrix-platform-admin"]
|
|
92
|
+
description: "Administrative read access to all resources"
|
|
93
|
+
|
|
94
|
+
- name: "admin:write"
|
|
95
|
+
roles: ["aifabrix-platform-admin"]
|
|
96
|
+
description: "Administrative write access to all resources"
|
|
97
|
+
|
|
98
|
+
- name: "admin:delete"
|
|
99
|
+
roles: ["aifabrix-platform-admin"]
|
|
100
|
+
description: "Administrative delete access to all resources"
|
|
101
|
+
|
|
102
|
+
# Template Applications (environment = null)
|
|
103
|
+
- name: "applications:create"
|
|
104
|
+
roles: ["aifabrix-platform-admin", "aifabrix-infrastructure-admin", "aifabrix-deployment-admin"]
|
|
105
|
+
description: "Register new application templates"
|
|
106
|
+
|
|
107
|
+
- name: "applications:read"
|
|
108
|
+
roles: ["aifabrix-platform-admin", "aifabrix-infrastructure-admin", "aifabrix-deployment-admin", "aifabrix-developer", "aifabrix-observer"]
|
|
109
|
+
description: "View application templates"
|
|
110
|
+
|
|
111
|
+
- name: "applications:update"
|
|
112
|
+
roles: ["aifabrix-platform-admin", "aifabrix-infrastructure-admin", "aifabrix-deployment-admin"]
|
|
113
|
+
description: "Update application templates"
|
|
114
|
+
|
|
115
|
+
- name: "applications:delete"
|
|
116
|
+
roles: ["aifabrix-platform-admin", "aifabrix-infrastructure-admin"]
|
|
117
|
+
description: "Remove application templates"
|
|
118
|
+
|
|
119
|
+
# Environments
|
|
120
|
+
- name: "environments:create"
|
|
121
|
+
roles: ["aifabrix-platform-admin", "aifabrix-infrastructure-admin"]
|
|
122
|
+
description: "Create new environments (dev, tst, pro, miso)"
|
|
123
|
+
|
|
124
|
+
- name: "environments:read"
|
|
125
|
+
roles: ["aifabrix-platform-admin", "aifabrix-infrastructure-admin", "aifabrix-deployment-admin", "aifabrix-developer", "aifabrix-observer"]
|
|
126
|
+
description: "View environments and their status"
|
|
127
|
+
|
|
128
|
+
- name: "environments:update"
|
|
129
|
+
roles: ["aifabrix-platform-admin", "aifabrix-infrastructure-admin"]
|
|
130
|
+
description: "Update environment configuration"
|
|
131
|
+
|
|
132
|
+
- name: "environments:delete"
|
|
133
|
+
roles: ["aifabrix-platform-admin", "aifabrix-infrastructure-admin"]
|
|
134
|
+
description: "Delete environments"
|
|
135
|
+
|
|
136
|
+
# Environment Applications
|
|
137
|
+
- name: "environments_applications:create"
|
|
138
|
+
roles: ["aifabrix-platform-admin", "aifabrix-deployment-admin", "aifabrix-developer"]
|
|
139
|
+
description: "Create applications within environments"
|
|
140
|
+
|
|
141
|
+
- name: "environments_applications:read"
|
|
142
|
+
roles: ["aifabrix-platform-admin", "aifabrix-deployment-admin", "aifabrix-developer", "aifabrix-observer"]
|
|
143
|
+
description: "View applications within environments"
|
|
144
|
+
|
|
145
|
+
- name: "environments_applications:update"
|
|
146
|
+
roles: ["aifabrix-platform-admin", "aifabrix-deployment-admin", "aifabrix-developer"]
|
|
147
|
+
description: "Update applications within environments"
|
|
148
|
+
|
|
149
|
+
- name: "environments_applications:delete"
|
|
150
|
+
roles: ["aifabrix-platform-admin", "aifabrix-deployment-admin"]
|
|
151
|
+
description: "Remove applications from environments"
|
|
152
|
+
|
|
153
|
+
# Pipeline & Deployment
|
|
154
|
+
- name: "applications:deploy"
|
|
155
|
+
roles: ["aifabrix-platform-admin", "aifabrix-deployment-admin", "aifabrix-developer"]
|
|
156
|
+
description: "Deploy applications to environments"
|
|
157
|
+
|
|
158
|
+
- name: "deployments:read"
|
|
159
|
+
roles: ["aifabrix-platform-admin", "aifabrix-deployment-admin", "aifabrix-developer", "aifabrix-observer"]
|
|
160
|
+
description: "View deployment history and status"
|
|
161
|
+
|
|
162
|
+
# Controller Operations
|
|
163
|
+
- name: "controller:admin"
|
|
164
|
+
roles: ["aifabrix-platform-admin"]
|
|
165
|
+
description: "Full administrative access to controller operations"
|
|
166
|
+
|
|
167
|
+
- name: "controller:deploy"
|
|
168
|
+
roles: ["aifabrix-platform-admin", "aifabrix-infrastructure-admin", "aifabrix-deployment-admin"]
|
|
169
|
+
description: "Deploy infrastructure and manage environments"
|
|
170
|
+
|
|
171
|
+
- name: "controller:monitor"
|
|
172
|
+
roles: ["aifabrix-platform-admin", "aifabrix-security-admin", "aifabrix-observer"]
|
|
173
|
+
description: "Monitor system health and view logs"
|
|
174
|
+
|
|
175
|
+
- name: "controller:compliance"
|
|
176
|
+
roles: ["aifabrix-platform-admin", "aifabrix-compliance-admin"]
|
|
177
|
+
description: "Access compliance reports and audit logs"
|
|
178
|
+
|
|
179
|
+
# Authentication & Authorization
|
|
180
|
+
- name: "auth:read"
|
|
181
|
+
roles: ["aifabrix-platform-admin", "aifabrix-security-admin", "aifabrix-developer", "aifabrix-observer"]
|
|
182
|
+
description: "View user roles and permissions"
|
|
183
|
+
|
|
184
|
+
# Logs
|
|
185
|
+
- name: "logs:read"
|
|
186
|
+
roles: ["aifabrix-platform-admin", "aifabrix-security-admin", "aifabrix-compliance-admin", "aifabrix-observer"]
|
|
187
|
+
description: "View application and audit logs"
|
|
188
|
+
|
|
189
|
+
- name: "logs:write"
|
|
190
|
+
roles: ["aifabrix-platform-admin", "aifabrix-developer"]
|
|
191
|
+
description: "Write audit and error logs"
|
|
192
|
+
|
|
193
|
+
# Admin Operations
|
|
194
|
+
- name: "admin.sync"
|
|
195
|
+
roles: ["aifabrix-platform-admin", "aifabrix-infrastructure-admin"]
|
|
196
|
+
description: "Full system synchronization operations"
|
|
197
|
+
|
|
198
|
+
- name: "admin.keycloak"
|
|
199
|
+
roles: ["aifabrix-platform-admin", "aifabrix-security-admin"]
|
|
200
|
+
description: "Keycloak administration and configuration"
|
|
201
|
+
|
|
202
|
+
# Cache Management
|
|
203
|
+
- name: "cache:read"
|
|
204
|
+
roles: ["aifabrix-platform-admin", "aifabrix-security-admin", "aifabrix-observer"]
|
|
205
|
+
description: "View cache statistics and performance metrics"
|
|
206
|
+
|
|
207
|
+
- name: "cache:admin"
|
|
208
|
+
roles: ["aifabrix-platform-admin"]
|
|
209
|
+
description: "Manage cache (clear, invalidate patterns)"
|
|
210
|
+
|
|
211
|
+
# Dashboard
|
|
212
|
+
- name: "dashboard:read"
|
|
213
|
+
roles: ["aifabrix-platform-admin", "aifabrix-deployment-admin", "aifabrix-developer", "aifabrix-observer"]
|
|
214
|
+
description: "View dashboard summaries and aggregates"
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Application Metadata
|
|
2
|
+
app:
|
|
3
|
+
key: miso-controller
|
|
4
|
+
displayName: "Miso Controller"
|
|
5
|
+
description: "AI Fabrix Miso Controller - Backend API and orchestration service"
|
|
6
|
+
type: webapp
|
|
7
|
+
|
|
8
|
+
# Image Configuration
|
|
9
|
+
image:
|
|
10
|
+
name: aifabrix/miso-controller
|
|
11
|
+
registry: devflowiseacr.azurecr.io
|
|
12
|
+
registryMode: acr
|
|
13
|
+
|
|
14
|
+
# Port Configuration
|
|
15
|
+
port: 3000
|
|
16
|
+
|
|
17
|
+
# Azure Requirements
|
|
18
|
+
requires:
|
|
19
|
+
database: true
|
|
20
|
+
databases:
|
|
21
|
+
- name: miso
|
|
22
|
+
- name: miso-logs
|
|
23
|
+
redis: true
|
|
24
|
+
storage: true
|
|
25
|
+
|
|
26
|
+
# Health Check
|
|
27
|
+
healthCheck:
|
|
28
|
+
path: /health
|
|
29
|
+
interval: 30
|
|
30
|
+
probePath: /health
|
|
31
|
+
probeRequestType: GET
|
|
32
|
+
probeProtocol: Https
|
|
33
|
+
probeIntervalInSeconds: 120
|
|
34
|
+
|
|
35
|
+
# Authentication
|
|
36
|
+
authentication:
|
|
37
|
+
type: keycloak
|
|
38
|
+
enableSSO: true
|
|
39
|
+
requiredRoles:
|
|
40
|
+
- aifabrix-user
|
|
41
|
+
endpoints:
|
|
42
|
+
local: http://localhost:3000/auth/callback
|
|
43
|
+
|
|
44
|
+
# Build Configuration
|
|
45
|
+
build:
|
|
46
|
+
context: .. # Docker build context (relative to builder/)
|
|
47
|
+
dockerfile: builder/miso-controller/Dockerfile # Dockerfile name (empty = use template)
|
|
48
|
+
envOutputPath: # Copy .env to repo root for local dev (relative to builder/) (if null, no .env file is copied) (if empty, .env file is copied to repo root)
|
|
49
|
+
localPort: 3010 # Port for local development (different from Docker port)
|
|
50
|
+
language: typescript # Runtime language for template selection (typescript or python)
|
|
51
|
+
secrets: # Path to secrets file
|
|
52
|
+
|
|
53
|
+
# Docker Compose
|
|
54
|
+
compose:
|
|
55
|
+
file: docker-compose.yaml
|
|
56
|
+
service: miso-controller
|
|
@@ -33,37 +33,16 @@ jobs:
|
|
|
33
33
|
exit 1
|
|
34
34
|
fi
|
|
35
35
|
|
|
36
|
-
{{#
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
runs-on: ubuntu-latest
|
|
40
|
-
needs: validate
|
|
41
|
-
steps:
|
|
42
|
-
- uses: actions/checkout@v4
|
|
43
|
-
|
|
44
|
-
- name: Setup Node.js
|
|
45
|
-
uses: actions/setup-node@v4
|
|
46
|
-
with:
|
|
47
|
-
node-version: '20'
|
|
48
|
-
registry-url: 'https://registry.npmjs.org'
|
|
49
|
-
cache: 'npm'
|
|
50
|
-
|
|
51
|
-
- name: Install dependencies
|
|
52
|
-
run: npm ci
|
|
53
|
-
|
|
54
|
-
- name: Build package
|
|
55
|
-
run: npm run build
|
|
56
|
-
|
|
57
|
-
- name: Publish to NPM
|
|
58
|
-
run: npm publish --access public
|
|
59
|
-
env:
|
|
60
|
-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
36
|
+
{{#each githubSteps}}
|
|
37
|
+
{{#if (lookup ../stepContent this)}}
|
|
38
|
+
{{{lookup ../stepContent this}}}
|
|
61
39
|
{{/if}}
|
|
40
|
+
{{/each}}
|
|
62
41
|
|
|
63
42
|
create-release:
|
|
64
43
|
name: Create GitHub Release
|
|
65
44
|
runs-on: ubuntu-latest
|
|
66
|
-
needs: {{#if
|
|
45
|
+
needs: {{#if hasNpmStep}}publish-npm{{else}}validate{{/if}}
|
|
67
46
|
steps:
|
|
68
47
|
- uses: actions/checkout@v4
|
|
69
48
|
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
publish-npm:
|
|
2
|
+
name: Publish to NPM
|
|
3
|
+
runs-on: ubuntu-latest
|
|
4
|
+
needs: validate
|
|
5
|
+
steps:
|
|
6
|
+
- uses: actions/checkout@v4
|
|
7
|
+
|
|
8
|
+
- name: Setup Node.js
|
|
9
|
+
uses: actions/setup-node@v4
|
|
10
|
+
with:
|
|
11
|
+
node-version: '20'
|
|
12
|
+
registry-url: 'https://registry.npmjs.org'
|
|
13
|
+
cache: 'npm'
|
|
14
|
+
|
|
15
|
+
- name: Install dependencies
|
|
16
|
+
run: npm ci
|
|
17
|
+
|
|
18
|
+
- name: Build package
|
|
19
|
+
run: npm run build
|
|
20
|
+
|
|
21
|
+
- name: Publish to NPM
|
|
22
|
+
run: npm publish --access public
|
|
23
|
+
env:
|
|
24
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
@@ -20,7 +20,7 @@ services:
|
|
|
20
20
|
- postgres_data:/var/lib/postgresql/data
|
|
21
21
|
- ./init-scripts:/docker-entrypoint-initdb.d
|
|
22
22
|
networks:
|
|
23
|
-
-
|
|
23
|
+
- infra_aifabrix-network
|
|
24
24
|
healthcheck:
|
|
25
25
|
test: ["CMD-SHELL", "pg_isready -U pgadmin -d postgres"]
|
|
26
26
|
interval: 10s
|
|
@@ -38,7 +38,7 @@ services:
|
|
|
38
38
|
volumes:
|
|
39
39
|
- redis_data:/data
|
|
40
40
|
networks:
|
|
41
|
-
-
|
|
41
|
+
- infra_aifabrix-network
|
|
42
42
|
healthcheck:
|
|
43
43
|
test: ["CMD", "redis-cli", "ping"]
|
|
44
44
|
interval: 10s
|
|
@@ -61,7 +61,7 @@ services:
|
|
|
61
61
|
postgres:
|
|
62
62
|
condition: service_healthy
|
|
63
63
|
networks:
|
|
64
|
-
-
|
|
64
|
+
- infra_aifabrix-network
|
|
65
65
|
|
|
66
66
|
# Optional: Redis Commander for Redis management
|
|
67
67
|
redis-commander:
|
|
@@ -79,7 +79,7 @@ services:
|
|
|
79
79
|
redis:
|
|
80
80
|
condition: service_healthy
|
|
81
81
|
networks:
|
|
82
|
-
-
|
|
82
|
+
- infra_aifabrix-network
|
|
83
83
|
|
|
84
84
|
volumes:
|
|
85
85
|
postgres_data:
|
|
@@ -88,6 +88,6 @@ volumes:
|
|
|
88
88
|
driver: local
|
|
89
89
|
|
|
90
90
|
networks:
|
|
91
|
-
|
|
91
|
+
infra_aifabrix-network:
|
|
92
92
|
driver: bridge
|
|
93
|
-
name:
|
|
93
|
+
name: infra_aifabrix-network
|
|
@@ -8,11 +8,12 @@ services:
|
|
|
8
8
|
{{app.key}}:
|
|
9
9
|
image: {{image.name}}:{{image.tag}}
|
|
10
10
|
container_name: aifabrix-{{app.key}}
|
|
11
|
-
env_file:
|
|
11
|
+
env_file:
|
|
12
|
+
- {{envFile}}
|
|
12
13
|
ports:
|
|
13
14
|
- "{{build.localPort}}:{{port}}"
|
|
14
15
|
networks:
|
|
15
|
-
-
|
|
16
|
+
- infra_aifabrix-network
|
|
16
17
|
{{#if requiresStorage}}
|
|
17
18
|
volumes:
|
|
18
19
|
- "{{mountVolume}}:/mnt/data"
|
|
@@ -39,31 +40,37 @@ services:
|
|
|
39
40
|
- ${ADMIN_SECRETS_PATH}
|
|
40
41
|
environment:
|
|
41
42
|
POSTGRES_DB: postgres
|
|
43
|
+
PGHOST: postgres
|
|
44
|
+
PGPORT: "5432"
|
|
45
|
+
PGUSER: pgadmin
|
|
42
46
|
networks:
|
|
43
|
-
-
|
|
47
|
+
- infra_aifabrix-network
|
|
44
48
|
command: >
|
|
45
49
|
sh -c "
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
psql -d postgres -c 'GRANT ALL PRIVILEGES ON DATABASE {{app.key}} TO {{app.key}}_user;' &&
|
|
50
|
-
psql -d {{app.key}} -c 'ALTER SCHEMA public OWNER TO {{app.key}}_user;' &&
|
|
51
|
-
psql -d {{app.key}} -c 'GRANT ALL ON SCHEMA public TO {{app.key}}_user;' &&
|
|
50
|
+
export PGHOST=postgres PGPORT=5432 PGUSER=pgadmin &&
|
|
51
|
+
export PGPASSWORD="${POSTGRES_PASSWORD}" &&
|
|
52
|
+
{{#if databases}}
|
|
52
53
|
{{#each databases}}
|
|
53
|
-
{{#unless @first}}
|
|
54
54
|
echo 'Creating {{name}} database and user...' &&
|
|
55
55
|
psql -d postgres -c 'CREATE DATABASE {{name}};' || echo '{{name}} database exists' &&
|
|
56
56
|
psql -d postgres -c \"CREATE USER {{name}}_user WITH PASSWORD '{{name}}_pass123';\" || echo '{{name}}_user exists' &&
|
|
57
57
|
psql -d postgres -c 'GRANT ALL PRIVILEGES ON DATABASE {{name}} TO {{name}}_user;' &&
|
|
58
58
|
psql -d {{name}} -c 'ALTER SCHEMA public OWNER TO {{name}}_user;' &&
|
|
59
59
|
psql -d {{name}} -c 'GRANT ALL ON SCHEMA public TO {{name}}_user;' &&
|
|
60
|
-
{{/unless}}
|
|
61
60
|
{{/each}}
|
|
61
|
+
{{else}}
|
|
62
|
+
echo 'Creating {{app.key}} database and user...' &&
|
|
63
|
+
psql -d postgres -c 'CREATE DATABASE {{app.key}};' || echo '{{app.key}} database exists' &&
|
|
64
|
+
psql -d postgres -c \"CREATE USER {{app.key}}_user WITH PASSWORD '{{app.key}}_pass123';\" || echo '{{app.key}}_user exists' &&
|
|
65
|
+
psql -d postgres -c 'GRANT ALL PRIVILEGES ON DATABASE {{app.key}} TO {{app.key}}_user;' &&
|
|
66
|
+
psql -d {{app.key}} -c 'ALTER SCHEMA public OWNER TO {{app.key}}_user;' &&
|
|
67
|
+
psql -d {{app.key}} -c 'GRANT ALL ON SCHEMA public TO {{app.key}}_user;' &&
|
|
68
|
+
{{/if}}
|
|
62
69
|
echo 'Database initialization complete!'
|
|
63
70
|
"
|
|
64
71
|
restart: "no"
|
|
65
72
|
{{/if}}
|
|
66
73
|
|
|
67
74
|
networks:
|
|
68
|
-
|
|
75
|
+
infra_aifabrix-network:
|
|
69
76
|
external: true
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from datetime import datetime
|
|
3
|
+
from flask import Flask, jsonify
|
|
4
|
+
|
|
5
|
+
app = Flask(__name__)
|
|
6
|
+
PORT = int(os.environ.get('PORT', 3000))
|
|
7
|
+
|
|
8
|
+
def check_database():
|
|
9
|
+
"""Check database connection"""
|
|
10
|
+
database_url = os.environ.get('DATABASE_URL')
|
|
11
|
+
|
|
12
|
+
try:
|
|
13
|
+
import psycopg2
|
|
14
|
+
|
|
15
|
+
# If DATABASE_URL is set, use it
|
|
16
|
+
if database_url:
|
|
17
|
+
from urllib.parse import urlparse
|
|
18
|
+
# Parse DATABASE_URL (format: postgresql://user:password@host:port/database)
|
|
19
|
+
parsed = urlparse(database_url)
|
|
20
|
+
|
|
21
|
+
conn = psycopg2.connect(
|
|
22
|
+
host=parsed.hostname or os.environ.get('DATABASE_HOST', 'postgres'),
|
|
23
|
+
port=parsed.port or int(os.environ.get('DATABASE_PORT', 5432)),
|
|
24
|
+
database=parsed.path[1:] if parsed.path else os.environ.get('DATABASE_NAME', 'postgres'),
|
|
25
|
+
user=parsed.username or os.environ.get('DATABASE_USER', 'pgadmin'),
|
|
26
|
+
password=parsed.password or os.environ.get('DATABASE_PASSWORD', 'admin123')
|
|
27
|
+
)
|
|
28
|
+
else:
|
|
29
|
+
# Fallback to individual environment variables
|
|
30
|
+
conn = psycopg2.connect(
|
|
31
|
+
host=os.environ.get('DATABASE_HOST', os.environ.get('DB_HOST', 'postgres')),
|
|
32
|
+
port=int(os.environ.get('DATABASE_PORT', os.environ.get('DB_PORT', 5432))),
|
|
33
|
+
database=os.environ.get('DATABASE_NAME', os.environ.get('DB_NAME', 'postgres')),
|
|
34
|
+
user=os.environ.get('DATABASE_USER', os.environ.get('DB_USER', 'pgadmin')),
|
|
35
|
+
password=os.environ.get('DATABASE_PASSWORD', os.environ.get('DB_PASSWORD', 'admin123'))
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
conn.close()
|
|
39
|
+
return True
|
|
40
|
+
except ImportError:
|
|
41
|
+
return 'psycopg2 not installed'
|
|
42
|
+
except Exception as e:
|
|
43
|
+
return str(e)
|
|
44
|
+
|
|
45
|
+
@app.route('/health', methods=['GET'])
|
|
46
|
+
def health():
|
|
47
|
+
"""Health check endpoint with database connectivity check"""
|
|
48
|
+
health_status = {
|
|
49
|
+
'status': 'ok',
|
|
50
|
+
'timestamp': datetime.utcnow().isoformat() + 'Z'
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
# Check database connection if database is configured (DATABASE_URL or individual vars)
|
|
54
|
+
database_url = os.environ.get('DATABASE_URL')
|
|
55
|
+
database_host = os.environ.get('DATABASE_HOST') or os.environ.get('DB_HOST')
|
|
56
|
+
database_name = os.environ.get('DATABASE_NAME') or os.environ.get('DB_NAME')
|
|
57
|
+
|
|
58
|
+
# Only check database if database is configured
|
|
59
|
+
if database_url or database_host or database_name:
|
|
60
|
+
db_check = check_database()
|
|
61
|
+
if db_check is True:
|
|
62
|
+
health_status['database'] = 'connected'
|
|
63
|
+
else:
|
|
64
|
+
health_status['database'] = 'error'
|
|
65
|
+
health_status['database_error'] = str(db_check)
|
|
66
|
+
return jsonify(health_status), 503
|
|
67
|
+
|
|
68
|
+
return jsonify(health_status), 200
|
|
69
|
+
|
|
70
|
+
@app.route('/', methods=['GET'])
|
|
71
|
+
def root():
|
|
72
|
+
"""Root endpoint"""
|
|
73
|
+
return jsonify({
|
|
74
|
+
'message': 'AI Fabrix Application',
|
|
75
|
+
'version': '1.0.0'
|
|
76
|
+
}), 200
|
|
77
|
+
|
|
78
|
+
if __name__ == '__main__':
|
|
79
|
+
app.run(host='0.0.0.0', port=PORT, debug=False)
|
|
80
|
+
|
|
@@ -16,8 +16,8 @@ RUN apk add --no-cache \
|
|
|
16
16
|
# Copy package files first for better layer caching
|
|
17
17
|
COPY package*.json ./
|
|
18
18
|
|
|
19
|
-
# Install dependencies
|
|
20
|
-
RUN npm
|
|
19
|
+
# Install dependencies (including devDependencies for ts-node)
|
|
20
|
+
RUN npm install && npm cache clean --force
|
|
21
21
|
|
|
22
22
|
# Copy application code
|
|
23
23
|
COPY . .
|