This commit is contained in:
smhk1376 committed 2026-10-15 10:10:30 +03:30
1 parent a99af426db
commit 8886aa8640
91 files changed
+2823 -773

No files matched your search

+11 -2
View File
@@ -8,17 +8,20 @@ flock 9
ENV_FILE=/etc/edu-production.env
CONTAINER=aut-management-faculty
NETWORK=shared_web_network
UPLOAD_VOLUME=edu-uploads
REVISION=$(git rev-parse HEAD)
IMAGE="aut-management-faculty:$REVISION"
test -s "$ENV_FILE" || { echo "Missing protected production environment: $ENV_FILE" >&2; exit 1; }
docker network inspect "$NETWORK" >/dev/null
docker inspect insaight-postgres --format '{{json .NetworkSettings.Networks}}' | grep -q '"shared_web_network"'
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" .
# Back up before applying the repository's transactional, versioned migrations.
# Migrations are forward-only and idempotent (schema_migrations); dump is the safety net.
install -d -m 700 /opt/backups/edu
BACKUP="/opt/backups/edu/database-$(date -u +%Y%m%dT%H%M%SZ).dump"
docker exec insaight-postgres sh -c 'pg_dump -U "$POSTGRES_USER" -d ManagmentWebSite_Db -Fc' > "$BACKUP"
@@ -29,7 +32,10 @@ docker run --rm --network "$NETWORK" --env-file "$ENV_FILE" \
# Check the database and rendered pages before switching the public upstream.
CANDIDATE="edu-candidate-${REVISION:0:12}"
docker run -d --name "$CANDIDATE" --network "$NETWORK" --env-file "$ENV_FILE" "$IMAGE"
docker run -d --name "$CANDIDATE" --network "$NETWORK" --env-file "$ENV_FILE" \
-e UPLOAD_DIR=/app/public/uploads \
-v "$UPLOAD_VOLUME:/app/public/uploads" \
"$IMAGE"
cleanup_candidate() { docker rm -f "$CANDIDATE" >/dev/null 2>&1 || true; }
trap cleanup_candidate EXIT
READY=false
@@ -73,7 +79,10 @@ rollback() {
}
trap rollback ERR
docker run -d --name "$CONTAINER" --restart unless-stopped \
--network "$NETWORK" --env-file "$ENV_FILE" -p 127.0.0.1:3000:3000 "$IMAGE"
--network "$NETWORK" --env-file "$ENV_FILE" \
-e UPLOAD_DIR=/app/public/uploads \
-v "$UPLOAD_VOLUME:/app/public/uploads" \
-p 127.0.0.1:3000:3000 "$IMAGE"
READY=false
for attempt in $(seq 1 30); do
if curl -fsS --max-time 5 --resolve edu.mstaut.ir:443:127.0.0.1 https://edu.mstaut.ir/ >/dev/null; then