Docker/Compose, сети, env/secrets, PostgreSQL, Payload/Next.js, Meilisearch, Gorse, healthchecks, migrations, backups, restore и безопасный release workflow.
Система должна разворачиваться воспроизводимо из репозитория без ручных правок production-контейнеров.
Internet ↓ Reverse Proxy / HTTPS ↓ Mathchast web Payload CMS + Next.js │ ├── PostgreSQL ├── Meilisearch ├── Gorse └── media storage Worker/jobs ↓ Payload / PostgreSQL
| Service | Role | Public? |
|---|---|---|
| web | Next.js + Payload | через reverse proxy |
| postgres | source of truth | NO |
| meilisearch | search index | NO |
| gorse-master | recommendation coordinator | NO |
| gorse-server | recommendation serving | NO |
| gorse-worker | recommendation worker | NO |
| backup | scheduled backup | NO |
networks:
edge:
external: true
app_internal:
internal: truepostgres_data — обязательно backup.meili_data — rebuildable.media_data — backup, если не S3-compatible.NODE_ENV=production DATABASE_URL=postgresql://... PAYLOAD_SECRET=... NEXT_PUBLIC_SERVER_URL=https://... MEILI_HOST=http://meilisearch:7700 MEILI_MASTER_KEY=... GORSE_API_URL=http://gorse-server:8087 GORSE_API_KEY=... D30_SERVICE_TOKEN=...
multi-stage: 1. deps 2. build 3. runner runner: - production dependencies only - non-root user - build artifacts - no source secrets
services:
web:
build: .
restart: unless-stopped
env_file: [.env.production]
depends_on:
postgres:
condition: service_healthy
meilisearch:
condition: service_healthy
postgres:
image: postgres:<pinned-version>
restart: unless-stopped
volumes:
- postgres_data:/var/lib/postgresql/data
meilisearch:
image: getmeili/meilisearch:<pinned-version>
restart: unless-stopped
volumes:
- meili_data:/meili_data| Service | Check |
|---|---|
| web | HTTP /api/health |
| postgres | pg_isready |
| meilisearch | health endpoint |
| gorse | service health endpoint |
{
app: "ok",
database: "ok",
search: "ok|degraded",
recommendations: "ok|degraded"
}Search/Gorse могут быть degraded, но core определяется доступностью Payload/PostgreSQL.
backup current DB ↓ run migrations ↓ start new web version ↓ health checks ↓ traffic
package.json: migrate migrate:status seed reindex backup restore:test
pg_dump -Fc DATABASE > backup.dump
new empty PostgreSQL ↓ restore backup ↓ run required migrations ↓ start app ↓ verify counts ↓ sample public pages
git commit/tag ↓ build image ↓ test ↓ backup ↓ migrate ↓ deploy ↓ healthcheck ↓ smoke tests
Если jobs мешают web traffic, вынести worker process/container. Иначе отдельный worker не обязателен.
/opt/mathchast/
├── compose.yml
├── .env.production
├── backups/
└── scripts/
├── backup.sh
├── restore-test.sh
└── deploy.sh| # | Проверка | PASS |
|---|---|---|
| DP01 | Fresh Compose start | services healthy |
| DP02 | DB migrations | success |
| DP03 | Public home | 200 |
| DP04 | Payload Admin | auth works |
| DP05 | Search | works/degraded |
| DP06 | Gorse unavailable | site works |
| DP07 | Restart web | data preserved |
| DP08 | Restart postgres | volume preserved |
| DP09 | Backup | valid dump |
| DP10 | Restore test | content recovered |
1. Dockerfile 2. compose.yml 3. .env.example 4. health endpoint 5. healthchecks 6. migration script 7. deploy script 8. backup script 9. restore-test script 10. reindex command 11. reverse-proxy config/example 12. deploy test report 13. restore test report 14. security report 15. deviations.md 16. commit hash
build_12_coder_master_instruction.html — единая последовательная инструкция ИИ-кодеру, связывающая Build 01–11 в один контролируемый процесс сборки.