Refactor deployment workflow to utilize GitHub Actions for improved efficiency. Updated deploy.yml to include actions for checkout and Node.js setup, streamlined build process for Next.js with prebuilt assets, and revised deployment script to eliminate unnecessary steps. Enhanced documentation for clarity on automated deployment process.
This commit is contained in:
1 parent
bd2cfa5a26
commit
e1b5286946
5 files changed
+90
-39
No files matched your search
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env bash
|
||||
# Assemble a Next.js standalone tree ready for Dockerfile.prebuilt (runtime-only image).
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
OUT="${1:-$ROOT/prebuilt}"
|
||||
|
||||
test -f "$ROOT/.next/standalone/server.js"
|
||||
test -f "$ROOT/.next/BUILD_ID"
|
||||
|
||||
rm -rf "$OUT"
|
||||
mkdir -p "$OUT"
|
||||
|
||||
cp -a "$ROOT/.next/standalone/." "$OUT/"
|
||||
|
||||
rm -rf "$OUT/static" "$OUT/.next/static"
|
||||
mkdir -p "$OUT/.next"
|
||||
cp -a "$ROOT/.next/static/." "$OUT/.next/static/"
|
||||
|
||||
if [ -d "$ROOT/public" ]; then
|
||||
rm -rf "$OUT/public"
|
||||
cp -a "$ROOT/public" "$OUT/public"
|
||||
else
|
||||
mkdir -p "$OUT/public"
|
||||
fi
|
||||
|
||||
cp "$ROOT/Dockerfile.prebuilt" "$OUT/Dockerfile"
|
||||
printf '%s\n' 'Dockerfile' '.dockerignore' > "$OUT/.dockerignore"
|
||||
|
||||
test -f "$OUT/server.js"
|
||||
test -f "$OUT/.next/BUILD_ID"
|
||||
test -d "$OUT/.next/static"
|
||||
test -d "$OUT/node_modules"
|
||||
if [ -e "$OUT/static" ]; then
|
||||
echo "ERROR: root-level static/ must not exist" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Prebuilt tree ready at $OUT"
|
||||
@@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
export DISABLE_REACT_COMPILER=1
|
||||
export NEXT_TELEMETRY_DISABLED=1
|
||||
export NEXT_PUBLIC_SITE_URL="${NEXT_PUBLIC_SITE_URL:-https://edu.mstaut.ir}"
|
||||
export NODE_OPTIONS="${NODE_OPTIONS:---max-old-space-size=3072}"
|
||||
|
||||
npm ci --no-audit --no-fund
|
||||
npm run build
|
||||
test -f .next/standalone/server.js
|
||||
test -f .next/BUILD_ID
|
||||
|
||||
bash scripts/assemble-prebuilt.sh "$(pwd)/prebuilt"
|
||||
@@ -18,9 +18,18 @@ docker inspect insaight-postgres --format '{{json .NetworkSettings.Networks}}' |
|
||||
docker volume create "$UPLOAD_VOLUME" >/dev/null
|
||||
|
||||
# Keep the current app running throughout the build.
|
||||
DOCKER_BUILDKIT=1 docker build \
|
||||
--build-arg NEXT_PUBLIC_SITE_URL=https://edu.mstaut.ir \
|
||||
-t "$IMAGE" .
|
||||
# PREBUILT_DIR: CI-assembled standalone tree (Dockerfile.prebuilt). Skips npm ci + next build on VPS (~1–2 min).
|
||||
PREBUILT_DIR="${PREBUILT_DIR:-}"
|
||||
if [ -n "$PREBUILT_DIR" ]; then
|
||||
test -f "$PREBUILT_DIR/server.js"
|
||||
test -f "$PREBUILT_DIR/Dockerfile"
|
||||
rm -rf "$PREBUILT_DIR/static"
|
||||
DOCKER_BUILDKIT=1 docker build -t "$IMAGE" "$PREBUILT_DIR"
|
||||
else
|
||||
DOCKER_BUILDKIT=1 docker build \
|
||||
--build-arg NEXT_PUBLIC_SITE_URL=https://edu.mstaut.ir \
|
||||
-t "$IMAGE" .
|
||||
fi
|
||||
|
||||
# Back up before applying the repository's transactional, versioned migrations.
|
||||
# Migrations are forward-only and idempotent (schema_migrations); dump is the safety net.
|
||||
|
||||
Reference in new issue
Block a user