@aifabrix/builder 2.0.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.
- package/LICENSE +21 -0
- package/README.md +75 -0
- package/bin/aifabrix.js +51 -0
- package/lib/app-deploy.js +209 -0
- package/lib/app-run.js +291 -0
- package/lib/app.js +472 -0
- package/lib/audit-logger.js +162 -0
- package/lib/build.js +313 -0
- package/lib/cli.js +307 -0
- package/lib/deployer.js +256 -0
- package/lib/env-reader.js +250 -0
- package/lib/generator.js +361 -0
- package/lib/github-generator.js +220 -0
- package/lib/infra.js +300 -0
- package/lib/key-generator.js +93 -0
- package/lib/push.js +141 -0
- package/lib/schema/application-schema.json +649 -0
- package/lib/schema/env-config.yaml +15 -0
- package/lib/secrets.js +282 -0
- package/lib/templates.js +301 -0
- package/lib/validator.js +377 -0
- package/package.json +59 -0
- package/templates/README.md +51 -0
- package/templates/github/ci.yaml.hbs +15 -0
- package/templates/github/pr-checks.yaml.hbs +35 -0
- package/templates/github/release.yaml.hbs +79 -0
- package/templates/github/test.hbs +11 -0
- package/templates/github/test.yaml.hbs +11 -0
- package/templates/infra/compose.yaml +93 -0
- package/templates/python/Dockerfile.hbs +49 -0
- package/templates/python/docker-compose.hbs +69 -0
- package/templates/typescript/Dockerfile.hbs +46 -0
- package/templates/typescript/docker-compose.hbs +69 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# AI Fabrix Infrastructure Stack
|
|
2
|
+
# Shared infrastructure services only
|
|
3
|
+
# Generated by AI Fabrix Builder SDK
|
|
4
|
+
|
|
5
|
+
version: "3.9"
|
|
6
|
+
|
|
7
|
+
services:
|
|
8
|
+
# PostgreSQL Database with pgvector extension
|
|
9
|
+
postgres:
|
|
10
|
+
image: pgvector/pgvector:pg15
|
|
11
|
+
container_name: aifabrix-postgres
|
|
12
|
+
environment:
|
|
13
|
+
POSTGRES_DB: postgres
|
|
14
|
+
POSTGRES_USER: pgadmin
|
|
15
|
+
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
|
16
|
+
POSTGRES_INITDB_ARGS: "--encoding=UTF-8 --lc-collate=C --lc-ctype=C"
|
|
17
|
+
ports:
|
|
18
|
+
- "5432:5432"
|
|
19
|
+
volumes:
|
|
20
|
+
- postgres_data:/var/lib/postgresql/data
|
|
21
|
+
- ./init-scripts:/docker-entrypoint-initdb.d
|
|
22
|
+
networks:
|
|
23
|
+
- aifabrix-network
|
|
24
|
+
healthcheck:
|
|
25
|
+
test: ["CMD-SHELL", "pg_isready -U pgadmin -d postgres"]
|
|
26
|
+
interval: 10s
|
|
27
|
+
timeout: 5s
|
|
28
|
+
retries: 5
|
|
29
|
+
restart: unless-stopped
|
|
30
|
+
|
|
31
|
+
# Redis Cache
|
|
32
|
+
redis:
|
|
33
|
+
image: redis:7-alpine
|
|
34
|
+
container_name: aifabrix-redis
|
|
35
|
+
command: ["redis-server", "--appendonly", "yes"]
|
|
36
|
+
ports:
|
|
37
|
+
- "6379:6379"
|
|
38
|
+
volumes:
|
|
39
|
+
- redis_data:/data
|
|
40
|
+
networks:
|
|
41
|
+
- aifabrix-network
|
|
42
|
+
healthcheck:
|
|
43
|
+
test: ["CMD", "redis-cli", "ping"]
|
|
44
|
+
interval: 10s
|
|
45
|
+
timeout: 5s
|
|
46
|
+
retries: 5
|
|
47
|
+
restart: unless-stopped
|
|
48
|
+
|
|
49
|
+
# Optional: pgAdmin for database management
|
|
50
|
+
pgadmin:
|
|
51
|
+
image: dpage/pgadmin4:latest
|
|
52
|
+
container_name: aifabrix-pgadmin
|
|
53
|
+
environment:
|
|
54
|
+
PGADMIN_DEFAULT_EMAIL: ${PGADMIN_DEFAULT_EMAIL}
|
|
55
|
+
PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_DEFAULT_PASSWORD}
|
|
56
|
+
PGADMIN_CONFIG_SERVER_MODE: 'False'
|
|
57
|
+
ports:
|
|
58
|
+
- "5050:80"
|
|
59
|
+
restart: unless-stopped
|
|
60
|
+
depends_on:
|
|
61
|
+
postgres:
|
|
62
|
+
condition: service_healthy
|
|
63
|
+
networks:
|
|
64
|
+
- aifabrix-network
|
|
65
|
+
|
|
66
|
+
# Optional: Redis Commander for Redis management
|
|
67
|
+
redis-commander:
|
|
68
|
+
image: rediscommander/redis-commander:latest
|
|
69
|
+
container_name: aifabrix-redis-commander
|
|
70
|
+
environment:
|
|
71
|
+
REDIS_HOSTS: ${REDIS_HOST}
|
|
72
|
+
HTTP_USER: ${REDIS_COMMANDER_USER}
|
|
73
|
+
HTTP_PASSWORD: ${REDIS_COMMANDER_PASSWORD}
|
|
74
|
+
REDIS_PASSWORD: ""
|
|
75
|
+
ports:
|
|
76
|
+
- "8081:8081"
|
|
77
|
+
restart: unless-stopped
|
|
78
|
+
depends_on:
|
|
79
|
+
redis:
|
|
80
|
+
condition: service_healthy
|
|
81
|
+
networks:
|
|
82
|
+
- aifabrix-network
|
|
83
|
+
|
|
84
|
+
volumes:
|
|
85
|
+
postgres_data:
|
|
86
|
+
driver: local
|
|
87
|
+
redis_data:
|
|
88
|
+
driver: local
|
|
89
|
+
|
|
90
|
+
networks:
|
|
91
|
+
aifabrix-network:
|
|
92
|
+
driver: bridge
|
|
93
|
+
name: aifabrix-network
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Python Dockerfile Template
|
|
2
|
+
# Generated by AI Fabrix Builder SDK
|
|
3
|
+
# Base image: Python 3.11 Alpine for optimal size and security
|
|
4
|
+
|
|
5
|
+
FROM python:3.11-alpine
|
|
6
|
+
|
|
7
|
+
# Set working directory
|
|
8
|
+
WORKDIR /app
|
|
9
|
+
|
|
10
|
+
# Install system dependencies
|
|
11
|
+
RUN apk add --no-cache \
|
|
12
|
+
dumb-init \
|
|
13
|
+
curl \
|
|
14
|
+
gcc \
|
|
15
|
+
musl-dev \
|
|
16
|
+
libffi-dev \
|
|
17
|
+
&& rm -rf /var/cache/apk/*
|
|
18
|
+
|
|
19
|
+
# Copy requirements first for better layer caching
|
|
20
|
+
COPY requirements*.txt ./
|
|
21
|
+
|
|
22
|
+
# Install Python dependencies
|
|
23
|
+
RUN pip install --no-cache-dir -r requirements.txt
|
|
24
|
+
|
|
25
|
+
# Copy application code
|
|
26
|
+
COPY . .
|
|
27
|
+
|
|
28
|
+
# Create non-root user for security
|
|
29
|
+
RUN addgroup -g 1001 -S python && \
|
|
30
|
+
adduser -S python -u 1001
|
|
31
|
+
|
|
32
|
+
# Change ownership of app directory
|
|
33
|
+
RUN chown -R python:python /app
|
|
34
|
+
USER python
|
|
35
|
+
|
|
36
|
+
# Expose application port
|
|
37
|
+
# Template variable: {{port}} will be replaced with actual port number
|
|
38
|
+
EXPOSE {{port}}
|
|
39
|
+
|
|
40
|
+
# Health check
|
|
41
|
+
# Template variables: {{healthCheck.interval}} and {{healthCheck.path}} will be replaced
|
|
42
|
+
HEALTHCHECK --interval={{healthCheck.interval}}s --timeout=3s --start-period=5s --retries=3 \
|
|
43
|
+
CMD curl -f http://localhost:{{port}}{{healthCheck.path}} || exit 1
|
|
44
|
+
|
|
45
|
+
# Use dumb-init to handle signals properly
|
|
46
|
+
ENTRYPOINT ["dumb-init", "--"]
|
|
47
|
+
|
|
48
|
+
# Start application
|
|
49
|
+
CMD {{#if startupCommand}}["{{startupCommand}}"]{{else}}["python", "main.py"]{{/if}}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Python Docker Compose Template
|
|
2
|
+
# Generated by AI Fabrix Builder SDK
|
|
3
|
+
# Service definition for local development
|
|
4
|
+
|
|
5
|
+
version: "3.9"
|
|
6
|
+
|
|
7
|
+
services:
|
|
8
|
+
{{app.key}}:
|
|
9
|
+
image: {{image.name}}:{{image.tag}}
|
|
10
|
+
container_name: aifabrix-{{app.key}}
|
|
11
|
+
env_file: .env
|
|
12
|
+
ports:
|
|
13
|
+
- "{{build.localPort}}:{{port}}"
|
|
14
|
+
networks:
|
|
15
|
+
- aifabrix-network
|
|
16
|
+
{{#if requiresStorage}}
|
|
17
|
+
volumes:
|
|
18
|
+
- "{{mountVolume}}:/mnt/data"
|
|
19
|
+
{{/if}}
|
|
20
|
+
healthcheck:
|
|
21
|
+
test: ["CMD", "curl", "-f", "http://localhost:{{port}}{{healthCheck.path}}"]
|
|
22
|
+
interval: {{healthCheck.interval}}s
|
|
23
|
+
timeout: 10s
|
|
24
|
+
retries: 3
|
|
25
|
+
start_period: 40s
|
|
26
|
+
restart: unless-stopped
|
|
27
|
+
{{#if requiresDatabase}}
|
|
28
|
+
depends_on:
|
|
29
|
+
db-init:
|
|
30
|
+
condition: service_completed_successfully
|
|
31
|
+
{{/if}}
|
|
32
|
+
|
|
33
|
+
{{#if requiresDatabase}}
|
|
34
|
+
# Database Initialization
|
|
35
|
+
db-init:
|
|
36
|
+
image: pgvector/pgvector:pg15
|
|
37
|
+
container_name: aifabrix-{{app.key}}-db-init
|
|
38
|
+
env_file:
|
|
39
|
+
- ${ADMIN_SECRETS_PATH}
|
|
40
|
+
environment:
|
|
41
|
+
POSTGRES_DB: postgres
|
|
42
|
+
networks:
|
|
43
|
+
- aifabrix-network
|
|
44
|
+
command: >
|
|
45
|
+
sh -c "
|
|
46
|
+
echo 'Creating {{app.key}} database and user...' &&
|
|
47
|
+
psql -d postgres -c 'CREATE DATABASE {{app.key}};' || echo '{{app.key}} database exists' &&
|
|
48
|
+
psql -d postgres -c \"CREATE USER {{app.key}}_user WITH PASSWORD '{{app.key}}_pass123';\" || echo '{{app.key}}_user exists' &&
|
|
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;' &&
|
|
52
|
+
{{#each databases}}
|
|
53
|
+
{{#unless @first}}
|
|
54
|
+
echo 'Creating {{name}} database and user...' &&
|
|
55
|
+
psql -d postgres -c 'CREATE DATABASE {{name}};' || echo '{{name}} database exists' &&
|
|
56
|
+
psql -d postgres -c \"CREATE USER {{name}}_user WITH PASSWORD '{{name}}_pass123';\" || echo '{{name}}_user exists' &&
|
|
57
|
+
psql -d postgres -c 'GRANT ALL PRIVILEGES ON DATABASE {{name}} TO {{name}}_user;' &&
|
|
58
|
+
psql -d {{name}} -c 'ALTER SCHEMA public OWNER TO {{name}}_user;' &&
|
|
59
|
+
psql -d {{name}} -c 'GRANT ALL ON SCHEMA public TO {{name}}_user;' &&
|
|
60
|
+
{{/unless}}
|
|
61
|
+
{{/each}}
|
|
62
|
+
echo 'Database initialization complete!'
|
|
63
|
+
"
|
|
64
|
+
restart: "no"
|
|
65
|
+
{{/if}}
|
|
66
|
+
|
|
67
|
+
networks:
|
|
68
|
+
aifabrix-network:
|
|
69
|
+
external: true
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# TypeScript/Node.js Dockerfile Template
|
|
2
|
+
# Generated by AI Fabrix Builder SDK
|
|
3
|
+
# Base image: Node 20 Alpine for optimal size and security
|
|
4
|
+
|
|
5
|
+
FROM node:20-alpine
|
|
6
|
+
|
|
7
|
+
# Set working directory
|
|
8
|
+
WORKDIR /app
|
|
9
|
+
|
|
10
|
+
# Install system dependencies
|
|
11
|
+
RUN apk add --no-cache \
|
|
12
|
+
dumb-init \
|
|
13
|
+
curl \
|
|
14
|
+
&& rm -rf /var/cache/apk/*
|
|
15
|
+
|
|
16
|
+
# Copy package files first for better layer caching
|
|
17
|
+
COPY package*.json ./
|
|
18
|
+
|
|
19
|
+
# Install dependencies
|
|
20
|
+
RUN npm ci --only=production && npm cache clean --force
|
|
21
|
+
|
|
22
|
+
# Copy application code
|
|
23
|
+
COPY . .
|
|
24
|
+
|
|
25
|
+
# Create non-root user for security
|
|
26
|
+
RUN addgroup -g 1001 -S nodejs && \
|
|
27
|
+
adduser -S nextjs -u 1001
|
|
28
|
+
|
|
29
|
+
# Change ownership of app directory
|
|
30
|
+
RUN chown -R nextjs:nodejs /app
|
|
31
|
+
USER nextjs
|
|
32
|
+
|
|
33
|
+
# Expose application port
|
|
34
|
+
# Template variable: {{port}} will be replaced with actual port number
|
|
35
|
+
EXPOSE {{port}}
|
|
36
|
+
|
|
37
|
+
# Health check
|
|
38
|
+
# Template variables: {{healthCheck.interval}} and {{healthCheck.path}} will be replaced
|
|
39
|
+
HEALTHCHECK --interval={{healthCheck.interval}}s --timeout=3s --start-period=5s --retries=3 \
|
|
40
|
+
CMD curl -f http://localhost:{{port}}{{healthCheck.path}} || exit 1
|
|
41
|
+
|
|
42
|
+
# Use dumb-init to handle signals properly
|
|
43
|
+
ENTRYPOINT ["dumb-init", "--"]
|
|
44
|
+
|
|
45
|
+
# Start application
|
|
46
|
+
CMD {{#if startupCommand}}["{{startupCommand}}"]{{else}}["npm", "start"]{{/if}}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# TypeScript/Node.js Docker Compose Template
|
|
2
|
+
# Generated by AI Fabrix Builder SDK
|
|
3
|
+
# Service definition for local development
|
|
4
|
+
|
|
5
|
+
version: "3.9"
|
|
6
|
+
|
|
7
|
+
services:
|
|
8
|
+
{{app.key}}:
|
|
9
|
+
image: {{image.name}}:{{image.tag}}
|
|
10
|
+
container_name: aifabrix-{{app.key}}
|
|
11
|
+
env_file: .env
|
|
12
|
+
ports:
|
|
13
|
+
- "{{build.localPort}}:{{port}}"
|
|
14
|
+
networks:
|
|
15
|
+
- aifabrix-network
|
|
16
|
+
{{#if requiresStorage}}
|
|
17
|
+
volumes:
|
|
18
|
+
- "{{mountVolume}}:/mnt/data"
|
|
19
|
+
{{/if}}
|
|
20
|
+
healthcheck:
|
|
21
|
+
test: ["CMD", "curl", "-f", "http://localhost:{{port}}{{healthCheck.path}}"]
|
|
22
|
+
interval: {{healthCheck.interval}}s
|
|
23
|
+
timeout: 10s
|
|
24
|
+
retries: 3
|
|
25
|
+
start_period: 40s
|
|
26
|
+
restart: unless-stopped
|
|
27
|
+
{{#if requiresDatabase}}
|
|
28
|
+
depends_on:
|
|
29
|
+
db-init:
|
|
30
|
+
condition: service_completed_successfully
|
|
31
|
+
{{/if}}
|
|
32
|
+
|
|
33
|
+
{{#if requiresDatabase}}
|
|
34
|
+
# Database Initialization
|
|
35
|
+
db-init:
|
|
36
|
+
image: pgvector/pgvector:pg15
|
|
37
|
+
container_name: aifabrix-{{app.key}}-db-init
|
|
38
|
+
env_file:
|
|
39
|
+
- ${ADMIN_SECRETS_PATH}
|
|
40
|
+
environment:
|
|
41
|
+
POSTGRES_DB: postgres
|
|
42
|
+
networks:
|
|
43
|
+
- aifabrix-network
|
|
44
|
+
command: >
|
|
45
|
+
sh -c "
|
|
46
|
+
echo 'Creating {{app.key}} database and user...' &&
|
|
47
|
+
psql -d postgres -c 'CREATE DATABASE {{app.key}};' || echo '{{app.key}} database exists' &&
|
|
48
|
+
psql -d postgres -c \"CREATE USER {{app.key}}_user WITH PASSWORD '{{app.key}}_pass123';\" || echo '{{app.key}}_user exists' &&
|
|
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;' &&
|
|
52
|
+
{{#each databases}}
|
|
53
|
+
{{#unless @first}}
|
|
54
|
+
echo 'Creating {{name}} database and user...' &&
|
|
55
|
+
psql -d postgres -c 'CREATE DATABASE {{name}};' || echo '{{name}} database exists' &&
|
|
56
|
+
psql -d postgres -c \"CREATE USER {{name}}_user WITH PASSWORD '{{name}}_pass123';\" || echo '{{name}}_user exists' &&
|
|
57
|
+
psql -d postgres -c 'GRANT ALL PRIVILEGES ON DATABASE {{name}} TO {{name}}_user;' &&
|
|
58
|
+
psql -d {{name}} -c 'ALTER SCHEMA public OWNER TO {{name}}_user;' &&
|
|
59
|
+
psql -d {{name}} -c 'GRANT ALL ON SCHEMA public TO {{name}}_user;' &&
|
|
60
|
+
{{/unless}}
|
|
61
|
+
{{/each}}
|
|
62
|
+
echo 'Database initialization complete!'
|
|
63
|
+
"
|
|
64
|
+
restart: "no"
|
|
65
|
+
{{/if}}
|
|
66
|
+
|
|
67
|
+
networks:
|
|
68
|
+
aifabrix-network:
|
|
69
|
+
external: true
|