เว็บแอปที่ใช้ PostgreSQL สร้างขึ้นทีละขั้นตอน
แอปพลิเคชัน1/ ถึง 4/ และ
aggregate.yaml ทุกrelease.yaml หรือ manifest.yaml ก็
diff 1/aggregate.yaml 2/aggregate.yamlแอปพลิเคชันhub.aggrega.ai/tools/quickstart-web:1.1.0 ภายPGHOST, PGPORT, PGUSER, PGPASSWORD และ PGDATABASE สำหรับ PostgreSQL และ REDIS_HOST และ REDIS_PORT สำหรับREDIS_HOST ไว้ แอปsource ของ
บล็อก
สิ่งที่คุณต้องมี
- CLI
aggregaสำหรับทุก ขั้น ตอน - Docker พร้อม Compose สำหรับ
1/และ2/ซึ่งรัน บน เครื่อง ของ คุณ - ไม่
ต้อง มี สิ่ง อื่น สำหรับ 3/และ4/เพราะทั้ง สอง บิลด์ ไฟล์ Terraform แล้ว หยุด การ บิลด์ ครั้ง แรก ของ แต่ละ ขั้น ตอน ดึง โมดูล RDS และ ElastiCache จาก ที่ เก็บ git ของ โมดูล การ วางแผน และ นำ ไฟล์ เหล่า นั้น ไป ใช้ เป็น อีก การก ระ ทำ หนึ่ง ที่ แยก ออก ไป ทำ ด้วย บัญชี AWS และ ข้อมูล รับรอง ของ คุณ เอง หลัง จาก แทนที่ ตัว ยึด ตำแหน่ง แล้ว
รันด้วยคำสั่งเดียว
คุณ
เลือก
export QUICKSTART_DB_PASSWORD=choose-a-passwordcurl -fsSL https://aggrega.ai/quickstart-web.sh | shบน Windows ใน PowerShell:
$env:QUICKSTART_DB_PASSWORD = 'choose-a-password'irm https://aggrega.ai/quickstart-web.ps1 | iexต้อง
สคริปต์aggrega พบ และ Docker ตอบquickstart-web หรือ
หาก2, 3 หรือ 4 โดยsh -s -- และ--yes ตรง
curl -fsSL https://aggrega.ai/quickstart-web.sh | sh -s -- 2ใน PowerShell ตั้งQUICKSTART_STEP ก่อน ค่าRemove-Item Env:QUICKSTART_STEP:
$env:QUICKSTART_STEP=2; irm https://aggrega.ai/quickstart-web.ps1 | iexร่างตัวอย่าง
หาก
aggrega draft --example quickstart-webจาก
cd quickstart-webบิลด์
คำ
cd 1aggrega build --release release.yaml --auto-pullexport QUICKSTART_DB_PASSWORD=choose-a-passworddocker compose -p quickstart-web -f dist/compose/docker-compose.yaml up -d --wait# then open http://127.0.0.1:8080/ in your browserบิลด์dist/compose/docker-compose.yaml และ docker compose เริ่มquickstart-web และ
กับผู้ช่วย AI
ผู้
ใช้เครื่องมือของ Aggrega เท่านั้น และอย่าสร้างโฟลเดอร์เอง หากโฟลเดอร์ Workspace ยังไม่มีโฟลเดอร์ `quickstart-web` ให้เรียกเครื่องมือ `draft` หนึ่งครั้งโดยตั้ง `example` เป็น `quickstart-web` และไม่ระบุ `dir` เครื่องมือนี้จะเขียนตัวอย่างลงในโฟลเดอร์ `quickstart-web` ใหม่ พร้อม README และโฟลเดอร์ขั้นตอน `1` ถึง `4` จากนั้นเรียกเครื่องมือ `build` โดยตั้ง `workspace_root` เป็น `quickstart-web/1` ตั้ง `release` เป็น `release.yaml` ตั้ง `auto_pull` เป็น true และตั้ง `write` เป็น true บอกฉันว่าการบิลด์เขียนไฟล์ใดบ้าง ไฟล์เหล่านั้นอยู่ใน `quickstart-web/1/dist/`เว็บแอปและ PostgreSQL ของเว็บแอป — 1/
Aggregate ประกาศweb ชนิด core/compute/server และ db ชนิด core/datastore/postgres แอปพลิเคชัน
uses: database: db: target: db inject: env: - in: PGHOST from: host - in: PGPORT from: port - in: PGUSER from: user - in: PGDATABASE from: databaseรหัสcore/secret-value บน${QUICKSTART_DB_PASSWORD} Release ระบุport: 8080 และ published_port: 8080 ซึ่งpublished_port จะweb ใน dist/compose/docker-compose.yaml:
web: image: hub.aggrega.ai/tools/quickstart-web:1.1.0@sha256:72d42d6db51d34d1268108eca1989e1467ccb2c66d15ed3e50ca97e09003c8fb environment: PGDATABASE: appdb PGHOST: db PGPASSWORD: ${QUICKSTART_DB_PASSWORD} PGPORT: "5432" PGUSER: appuser ports: - 127.0.0.1:8080:8080 [… omitted: the aggrega.ai/ labels every service carries] networks: - compose depends_on: - db deploy: resources: limits: cpus: "0.1" memory: "134217728" reservations: cpus: "0.1" memory: "134217728"PGHOST คือ db ซึ่ง
เปิด http://127.0.0.1:8080/ ใน
จาก
curl -s http://localhost:8080/curl -s -X POST --data 'hello from the quickstart' http://localhost:8080/notescurl -s http://localhost:8080/notes/1{ "cache": "not wired", "database": "postgresql at db:5432/appdb", "service": "quickstart-web"}{ "id": 1, "text": "hello from the quickstart", "created_at": "2026-11-01T17:22:34.261989Z", "source": "postgresql"}{ "id": 1, "text": "hello from the quickstart", "created_at": "2026-11-01T17:22:34.261989Z", "source": "postgresql"}เพิ่มแคช — 2/
Aggregate เพิ่มcache ชนิด core/datastore/redis และ
cache: cache: target: cache inject: env: - in: REDIS_HOST from: host - in: REDIS_PORT from: portManifest แมปcompose/redis และ Release วาง
cd ../2aggrega build --release release.yaml --auto-pulldocker compose -p quickstart-web -f dist/compose/docker-compose.yaml up -d --waitDocker Compose ปล่อย1/ และ1/ ยัง
curl -s http://localhost:8080/curl -s http://localhost:8080/notes/1curl -s http://localhost:8080/notes/1{ "cache": "cache:6379", "database": "postgresql at db:5432/appdb", "service": "quickstart-web"}{ "id": 1, "text": "hello from the quickstart", "created_at": "2026-11-01T17:22:34.261989Z", "source": "postgresql"}{ "id": 1, "text": "hello from the quickstart", "created_at": "2026-11-01T17:22:34.261989Z", "source": "cache"}การ
เมื่อ
docker compose -p quickstart-web -f dist/compose/docker-compose.yaml down -vฐานข้อมูลเดียวกัน ให้ AWS จัดการ — 3/
ส่วนterraform/server-ecs ซึ่งterraform/postgres-rds-terraform-aws-modules ซึ่ง vendor โมดูล RDS ที่terraform/redis-elasticache ซึ่ง vendor โมดูล ElastiCache ของ
สิ่งPGPASSWORD เท่านั้น จะ
Release ระบุinfra.overrides ถึงengine_version ของ7.1 เพราะ ElastiCache รัน Redis OSS ได้123456789012 คือsubnet-… และ sg-… กลุ่ม
cd ../3aggrega build --release release.yaml --auto-pullการdist/terraform/aggrega.modules.tf:
# Root configuration for this boundary. Each component rendered here is one# module block below, and the directory that block points at holds that# component's own files. One configuration means one dependency graph, which is# what lets a reference or a depends_on reach from one component to another.
module "cache" { source = "./modules/cache"
create_security_group = false create_subnet_group = false engine = "redis" engine_version = "7.1" node_type = "cache.t3.small" port = 6379 replication_group_id = "cache" security_group_ids = ["sg-0123456789abcdef1"] subnet_group_name = "example-private-cache-subnets" transit_encryption_enabled = false}
module "db" { source = "./modules/db"
allocated_storage = 10 backup_retention_period = 7 create_db_subnet_group = false db_name = "appdb" db_subnet_group_name = "example-private-db-subnets" engine = "postgres" engine_version = "16" family = "postgres16" identifier = "db" instance_class = "db.t3.small" manage_master_user_password = true multi_az = false port = "5432" skip_final_snapshot = false storage_type = "gp3" username = "appuser" vpc_security_group_ids = ["sg-0123456789abcdef0"]}
module "web" { source = "./modules/web"
assign_public_ip = false cluster = "example-cluster" cpu = "256" desired_count = 1 environment = {"PGDATABASE":"appdb","PGHOST":"${module.db.db_instance_address}","PGPORT":"5432","PGUSER":"appuser","REDIS_HOST":"${module.cache.replication_group_primary_endpoint_address}","REDIS_PORT":"6379"} execution_role_arn = "arn:aws:iam::123456789012:role/example-ecs-task-execution" image = "hub.aggrega.ai/tools/quickstart-web:1.1.0@sha256:72d42d6db51d34d1268108eca1989e1467ccb2c66d15ed3e50ca97e09003c8fb" memory = "512" name = "web" port = 8080 security_groups = ["sg-0fedcba9876543210"] subnet_ids = ["subnet-0123456789abcdef0","subnet-0fedcba9876543210"]}แอปพลิเคชันPGHOST และ REDIS_HOST เป็นการdist/terraform คำtofu init -backend=false โหลดtofu validate จะ
Success! The configuration is valid.เพิ่มการสำรอง — 4/
RDS เก็บbackup_retention_period = 7 ข้างcore/backup กับ
db: features: backup: type: core/backup infra: retention_days: 14 schedule: "30 2 * * *"และ Manifest ผูก Feature เข้าterraform/backup-native ซึ่ง
cd ../4aggrega build --release release.yaml --auto-pullการ3/ ที่db เท่านั้น และ tofu validate บนSuccess! The configuration is valid. เช่น
backup_retention_period = 7backup_retention_period = 14backup_window = "02:30-03:00"การบิลด์ไม่ใช่การปรับใช้
3/ และ 4/ เขียนdist/ แล้ว
การตรวจสอบทุกขั้นตอน
ในaggrega draft --example เขียน./check.sh ในdist/, .aggrega/ และ*.lock เป็น