Fix deploy health check for /mstcontroller and cut ready-loop waste.
Deploy edu.mstaut.ir / deploy (push) Successful in 5m56s
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:
1 parent
69bdaf0113
commit
c97498a2ae
4 files changed
+48
-20
No files matched your search
+4
-1
@@ -1,8 +1,11 @@
|
|||||||
|
# syntax=docker/dockerfile:1
|
||||||
# ---- Dependencies ----
|
# ---- Dependencies ----
|
||||||
FROM node:22-alpine AS deps
|
FROM node:22-alpine AS deps
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY package.json package-lock.json ./
|
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 ----
|
# ---- Builder ----
|
||||||
FROM node:22-alpine AS builder
|
FROM node:22-alpine AS builder
|
||||||
|
|||||||
+5
-5
@@ -74,16 +74,16 @@ async function main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const tables = await client.query(`
|
const tables = await client.query(`
|
||||||
SELECT table_name
|
SELECT count(*)::int AS n
|
||||||
FROM information_schema.tables
|
FROM information_schema.tables
|
||||||
WHERE table_schema = 'public' AND table_type = 'BASE TABLE'
|
WHERE table_schema = 'public' AND table_type = 'BASE TABLE'
|
||||||
ORDER BY table_name
|
|
||||||
`);
|
`);
|
||||||
|
|
||||||
console.log(`applied_count: ${appliedCount}`);
|
console.log(`applied_count: ${appliedCount}`);
|
||||||
console.log(`skipped (already applied): ${skipped.length ? skipped.join(", ") : "none"}`);
|
if (skipped.length) {
|
||||||
console.log(`tables_count: ${tables.rows.length}`);
|
console.log(`skipped_count: ${skipped.length}`);
|
||||||
console.log(JSON.stringify(tables.rows.map((r) => r.table_name)));
|
}
|
||||||
|
console.log(`tables_count: ${tables.rows[0].n}`);
|
||||||
} finally {
|
} finally {
|
||||||
await client.end().catch(() => {});
|
await client.end().catch(() => {});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,3 +39,16 @@
|
|||||||
- [x] 19. سرچ آیکونی؛ با انیمیشن جایگزین دسته/تگ (هدر بدون دسته)
|
- [x] 19. سرچ آیکونی؛ با انیمیشن جایگزین دسته/تگ (هدر بدون دسته)
|
||||||
- [x] 20. کل کارت دوره قابل کلیک
|
- [x] 20. کل کارت دوره قابل کلیک
|
||||||
- [x] 21. لیبل دسته/تگ روی کارت و جزئیات دوره کلیکپذیر (فیلتر)
|
- [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.
|
||||||
@@ -18,7 +18,9 @@ docker inspect insaight-postgres --format '{{json .NetworkSettings.Networks}}' |
|
|||||||
docker volume create "$UPLOAD_VOLUME" >/dev/null
|
docker volume create "$UPLOAD_VOLUME" >/dev/null
|
||||||
|
|
||||||
# Keep the current app running throughout the build.
|
# 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.
|
# Back up before applying the repository's transactional, versioned migrations.
|
||||||
# Migrations are forward-only and idempotent (schema_migrations); dump is the safety net.
|
# 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" \
|
docker run --rm --network "$NETWORK" --env-file "$ENV_FILE" \
|
||||||
-v "$PWD/db:/app/db:ro" --entrypoint node "$IMAGE" db/migrate.mjs
|
-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}"
|
CANDIDATE="edu-candidate-${REVISION:0:12}"
|
||||||
docker run -d --name "$CANDIDATE" --network "$NETWORK" --env-file "$ENV_FILE" \
|
docker run -d --name "$CANDIDATE" --network "$NETWORK" --env-file "$ENV_FILE" \
|
||||||
-e UPLOAD_DIR=/app/public/uploads \
|
-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; }
|
cleanup_candidate() { docker rm -f "$CANDIDATE" >/dev/null 2>&1 || true; }
|
||||||
trap cleanup_candidate EXIT
|
trap cleanup_candidate EXIT
|
||||||
READY=false
|
READY=false
|
||||||
for attempt in $(seq 1 60); do
|
for attempt in $(seq 1 24); do
|
||||||
if docker exec "$CANDIDATE" node -e '
|
if docker exec "$CANDIDATE" node -e '
|
||||||
(async () => {
|
(async () => {
|
||||||
const { Pool } = require("pg");
|
const { Pool } = require("pg");
|
||||||
const pool = new Pool({connectionString: process.env.DATABASE_URL, connectionTimeoutMillis: 5000});
|
const pool = new Pool({
|
||||||
await pool.query("SELECT 1"); await pool.end();
|
connectionString: process.env.DATABASE_URL,
|
||||||
for (const route of ["/", "/programs", "/professional", "/admin/login"]) {
|
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);
|
const response = await fetch("http://127.0.0.1:3000" + route);
|
||||||
if (!response.ok) throw new Error(route + ": " + response.status);
|
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 api = await fetch("http://127.0.0.1:3000/api/courses");
|
||||||
const body = await response.json();
|
const body = await api.json();
|
||||||
if (!response.ok || !Array.isArray(body.data)) throw new Error("API check failed: " + resource);
|
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
|
'; then READY=true; break; fi
|
||||||
sleep 2
|
sleep 1
|
||||||
done
|
done
|
||||||
if [ "$READY" != true ]; then docker logs --tail 50 "$CANDIDATE"; exit 1; fi
|
if [ "$READY" != true ]; then docker logs --tail 50 "$CANDIDATE"; exit 1; fi
|
||||||
cleanup_candidate
|
cleanup_candidate
|
||||||
@@ -84,11 +96,11 @@ docker run -d --name "$CONTAINER" --restart unless-stopped \
|
|||||||
-v "$UPLOAD_VOLUME:/app/public/uploads" \
|
-v "$UPLOAD_VOLUME:/app/public/uploads" \
|
||||||
-p 127.0.0.1:3000:3000 "$IMAGE"
|
-p 127.0.0.1:3000:3000 "$IMAGE"
|
||||||
READY=false
|
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
|
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
|
READY=true; break
|
||||||
fi
|
fi
|
||||||
sleep 2
|
sleep 1
|
||||||
done
|
done
|
||||||
test "$READY" = true
|
test "$READY" = true
|
||||||
trap - ERR
|
trap - ERR
|
||||||
|
|||||||
Reference in new issue
Block a user