-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompose.yaml
More file actions
137 lines (134 loc) · 4.37 KB
/
Copy pathcompose.yaml
File metadata and controls
137 lines (134 loc) · 4.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
name: self-improving
services:
# The production to-do app. Runs a Next.js production build with no source
# code, no agent, and no admin UI. Exactly one ingress port keeps it
# stateless and scale-friendly (Cloud Run on GCP, Fargate on AWS).
app:
restart: unless-stopped
build:
context: ./todo-app
dockerfile: Dockerfile
ports:
- target: 3000
published: 3000
mode: ingress
environment:
DATABASE_URL: postgres://postgres:${POSTGRES_PASSWORD}@db:5432/postgres?sslmode=no-verify
BETTER_AUTH_SECRET:
ADMIN_UI: "false"
depends_on:
db:
condition: service_healthy
healthcheck:
test:
- CMD
- curl
- -f
- http://localhost:3000/api/health
interval: 15s
timeout: 5s
retries: 10
start_period: 20s
deploy:
resources:
reservations:
cpus: "0.5"
memory: 1024M
# The live "dev environment" service: Caddy in front of a Next.js dev server
# plus a separate Hono server running the Mastra coding agent, which edits
# the to-do app's source in place (hot reload). This service carries the full
# sample source tree. replicas: 1 and the private host port pin it to a single
# always-on instance so everyone previews the same edited copy (and so GCP
# uses Compute Engine rather than a scale-to-zero Cloud Run service).
dev:
restart: unless-stopped
build:
context: .
dockerfile: Dockerfile.dev
ports:
- target: 3000
published: 3000
mode: ingress
- target: 8081
mode: host
environment:
DATABASE_URL: postgres://postgres:${POSTGRES_PASSWORD}@db:5432/postgres?sslmode=no-verify
BETTER_AUTH_SECRET:
ADMIN_UI: "true"
# Break-glass token for the admin console (served by the agent server,
# outside the app the agent edits). Lets an admin reach the console even
# if the main app is down and their login session has expired.
ADMIN_TOKEN:
# Enable the admin-triggered self-redeploy. Fabric auth is a per-publish
# interactive `defang login` (no stored token). Defang supplies the
# resolved provider and stack so self-redeploys target the same place.
PUBLISH_ENABLED: "true"
PUBLISH_PROVIDER: "${DEFANG_PROVIDER}"
PUBLISH_STACK: "${DEFANG_STACK}"
# CHAT_URL, CHAT_MODEL, and OPENAI_API_KEY (the gateway's master key) are
# injected automatically by the `models:` binding below; the coding agent
# reads them in agent/src/model.ts.
models:
chat:
endpoint_var: CHAT_URL
model_var: CHAT_MODEL
depends_on:
db:
condition: service_healthy
healthcheck:
test:
- CMD
- curl
- -f
- http://localhost:3000/api/health
interval: 15s
timeout: 5s
retries: 10
start_period: 60s
deploy:
replicas: 1
resources:
reservations:
cpus: "1.0"
memory: 4096M
# Self-publish uses the workload's ambient identity. The selected cloud
# env file supplies either an AWS managed-policy ARN or a GCP project role.
# The empty default is only for repository validation; every cloud deploy
# must use a committed stack, which supplies the policy.
x-defang-policies:
- ${PUBLISH_POLICY:-}
# Shared database: todos, users/sessions (Better Auth), feedback, and the
# Mastra agent's storage. Both app and dev point here.
db:
image: postgres:16
x-defang-postgres: true
restart: always
environment:
POSTGRES_PASSWORD:
POSTGRES_DB: postgres
POSTGRES_USER: postgres
ports:
- mode: host
target: 5432
healthcheck:
test:
- CMD-SHELL
- pg_isready -U postgres -d postgres
interval: 10s
timeout: 5s
retries: 10
start_period: 10s
deploy:
resources:
reservations:
cpus: "0.5"
memory: 512M
# Managed LLM the coding agent talks to. Defang synthesizes a LiteLLM access
# gateway from this entry and injects CHAT_URL / CHAT_MODEL / OPENAI_API_KEY
# into any service that binds it (see `dev`). `chat-default` is a
# provider-portable alias the CLI maps to the cloud's managed inference
# (Amazon Nova on AWS Bedrock, Gemini on GCP Vertex AI). The gateway uses the
# CLI's default memory reservation.
models:
chat:
model: ${CHAT_MODEL:-chat-default}