Fix deploy health check for /mstcontroller and cut ready-loop waste.
Deploy edu.mstaut.ir / deploy (push) Successful in 5m56s

Admin login moved off /admin; old path caused 404 spam for up to two minutes. Slim smoke checks, shorter retries, quieter migrate logs, and npm ci without audit in the image build.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
smhk1376andCursor committed 2026-10-16 16:57:31 +03:30
1 parent 69bdaf0113
commit c97498a2ae
4 files changed
+48 -20

No files matched your search

+4 -1
View File
@@ -1,8 +1,11 @@
# syntax=docker/dockerfile:1
# ---- Dependencies ----
FROM node:22-alpine AS deps
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
# Skip audit/fund in image builds (saves ~30–60s); keep npm cache across deploys.
RUN --mount=type=cache,target=/root/.npm \
npm ci --no-audit --no-fund
# ---- Builder ----
FROM node:22-alpine AS builder
+5 -5
View File
@@ -74,16 +74,16 @@ async function main() {
}
const tables = await client.query(`
SELECT table_name
SELECT count(*)::int AS n
FROM information_schema.tables
WHERE table_schema = 'public' AND table_type = 'BASE TABLE'
ORDER BY table_name
`);
console.log(`applied_count: ${appliedCount}`);
console.log(`skipped (already applied): ${skipped.length ? skipped.join(", ") : "none"}`);
console.log(`tables_count: ${tables.rows.length}`);
console.log(JSON.stringify(tables.rows.map((r) => r.table_name)));
if (skipped.length) {
console.log(`skipped_count: ${skipped.length}`);
}
console.log(`tables_count: ${tables.rows[0].n}`);
} finally {
await client.end().catch(() => {});
}
+13
View File
@@ -39,3 +39,16 @@
- [x] 19. سرچ آیکونی؛ با انیمیشن جایگزین دسته/تگ (هدر بدون دسته)
- [x] 20. کل کارت دوره قابل کلیک
- [x] 21. لیبل دسته/تگ روی کارت و جزئیات دوره کلیک‌پذیر (فیلتر)
---
## قفل‌کنندهٔ نسخه‌های بعدی (الان نکن)
منبع: لاگ دیپلوی پروداکشن `69bdaf0` (2026-10-16). وضعیت فعلی دیپلوی سالم است؛ این‌ها بدهی/به‌روزرسانی اختیاری‌اند و نباید وسط فیچر جاری باز شوند.
- [ ] **V-LOCK npm audit** — در `npm ci` داخل Docker: ۱۲ vulnerability (۱۱ high + ۱ critical). در نسخهٔ بعدی: `npm audit` / `npm audit fix` (بدون `--force` مگر بعد از تست)، سپس بیلد+دیپلوی استیجینگ.
- [ ] **V-LOCK ESLint EOL** — هشدار `eslint@9.39.5` deprecated / version-support. در نسخهٔ بعدی: ارتقا به خط پشتیبانی‌شدهٔ ESLint و هم‌تراز کردن config/پلاگین‌ها.
- [ ] **V-LOCK npm toolchain** — notice: npm داخل ایمیج `10.9.9` → پیشنهاد `12.x`. در نسخهٔ بعدی: تصمیم pinned (packageManager / image tag) و تست `npm ci` روی همان نسخه.
- [ ] **V-LOCK deploy checkout noise** — git detach روی `/opt/prod/...` هشدار «leaving 1 commit behind» می‌دهد (طبیعی برای shallow+detach). در نسخهٔ بعدی: در ورک‌فلو `fetch --prune` / پاکسازی refهای یتیم یا ساکت‌کردن هشدار غیرضروری تا لاگ تمیزتر شود.
- [ ] **V-LOCK Docker build context size** — transfer context حدود ۵۵MB در بیلد. در نسخهٔ بعدی: بازبینی `.dockerignore` و دارایی‌های سنگین `public/` تا کش deps کمتر invalidate شود و بیلد سبک‌تر شود.
- [ ] **V-LOCK Docker build wall-time** — بیلد پروداکشن ~۱۵–۲۰ دقیقه (npm ci + copy node_modules + Next webpack/TS با ۱ worker). در نسخهٔ بعدی: کش لایه/registry، کاهش دارایی در context، و در صورت امکان افزایش CPU برای workerهای Next.
+26 -14
View File
@@ -18,7 +18,9 @@ docker inspect insaight-postgres --format '{{json .NetworkSettings.Networks}}' |
docker volume create "$UPLOAD_VOLUME" >/dev/null
# Keep the current app running throughout the build.
docker build --build-arg NEXT_PUBLIC_SITE_URL=https://edu.mstaut.ir -t "$IMAGE" .
DOCKER_BUILDKIT=1 docker build \
--build-arg NEXT_PUBLIC_SITE_URL=https://edu.mstaut.ir \
-t "$IMAGE" .
# Back up before applying the repository's transactional, versioned migrations.
# Migrations are forward-only and idempotent (schema_migrations); dump is the safety net.
@@ -30,7 +32,7 @@ test -s "$BACKUP"
docker run --rm --network "$NETWORK" --env-file "$ENV_FILE" \
-v "$PWD/db:/app/db:ro" --entrypoint node "$IMAGE" db/migrate.mjs
# Check the database and rendered pages before switching the public upstream.
# Check the database and a minimal page set before switching the public upstream.
CANDIDATE="edu-candidate-${REVISION:0:12}"
docker run -d --name "$CANDIDATE" --network "$NETWORK" --env-file "$ENV_FILE" \
-e UPLOAD_DIR=/app/public/uploads \
@@ -39,24 +41,34 @@ docker run -d --name "$CANDIDATE" --network "$NETWORK" --env-file "$ENV_FILE" \
cleanup_candidate() { docker rm -f "$CANDIDATE" >/dev/null 2>&1 || true; }
trap cleanup_candidate EXIT
READY=false
for attempt in $(seq 1 60); do
for attempt in $(seq 1 24); do
if docker exec "$CANDIDATE" node -e '
(async () => {
const { Pool } = require("pg");
const pool = new Pool({connectionString: process.env.DATABASE_URL, connectionTimeoutMillis: 5000});
await pool.query("SELECT 1"); await pool.end();
for (const route of ["/", "/programs", "/professional", "/admin/login"]) {
const pool = new Pool({
connectionString: process.env.DATABASE_URL,
connectionTimeoutMillis: 3000,
});
await pool.query("SELECT 1");
await pool.end();
// Minimal smoke: home + admin login (path moved from /admin).
for (const route of ["/", "/mstcontroller/login"]) {
const response = await fetch("http://127.0.0.1:3000" + route);
if (!response.ok) throw new Error(route + ": " + response.status);
}
for (const resource of ["courses", "programs", "events", "articles"]) {
const response = await fetch("http://127.0.0.1:3000/api/" + resource);
const body = await response.json();
if (!response.ok || !Array.isArray(body.data)) throw new Error("API check failed: " + resource);
const api = await fetch("http://127.0.0.1:3000/api/courses");
const body = await api.json();
if (!api.ok || !Array.isArray(body.data)) {
throw new Error("API check failed: courses");
}
})().catch(error => { console.error(error.message); process.exit(1); });
})().catch((error) => {
console.error(error.message || error);
process.exit(1);
});
'; then READY=true; break; fi
sleep 2
sleep 1
done
if [ "$READY" != true ]; then docker logs --tail 50 "$CANDIDATE"; exit 1; fi
cleanup_candidate
@@ -84,11 +96,11 @@ docker run -d --name "$CONTAINER" --restart unless-stopped \
-v "$UPLOAD_VOLUME:/app/public/uploads" \
-p 127.0.0.1:3000:3000 "$IMAGE"
READY=false
for attempt in $(seq 1 30); do
for attempt in $(seq 1 20); do
if curl -fsS --max-time 5 --resolve edu.mstaut.ir:443:127.0.0.1 https://edu.mstaut.ir/ >/dev/null; then
READY=true; break
fi
sleep 2
sleep 1
done
test "$READY" = true
trap - ERR