feat: Upgrade to Next.js 16 and refactor deployment to use an external database with a simplified Docker Compose setup.

This commit is contained in:
Moh Dzulfikri Maulana
2026-03-09 03:05:39 +07:00
parent b8a5ce72c1
commit dca848666e
3 changed files with 61 additions and 117 deletions

View File

@@ -1,51 +1,30 @@
#!/bin/bash
# Exit immediately if a command exits with a non-zero status
# Berhenti jika ada error
set -e
echo "Starting Production Deployment..."
echo "🚀 Memulai Deployment Aplikasi (TANPA DATABASE)..."
# Load environment variables from .env if it exists
# Load environment variabel
if [ -f .env ]; then
echo "Loading environment variables from .env..."
echo "📄 Loading .env..."
export $(grep -v '^#' .env | xargs)
fi
# Check if 'docker compose' (v2) or 'docker-compose' (v1) is available
# Deteksi perintah docker compose
if docker compose version >/dev/null 2>&1; then
COMPOSE_CMD="docker compose"
elif docker-compose version >/dev/null 2>&1; then
else
COMPOSE_CMD="docker-compose"
else
echo "Error: Docker Compose not found. Please install Docker Compose first."
exit 1
fi
# Configuration
DB_CONTAINER_NAME="fikri-portfolio-db"
DB_PORT="5429"
echo "📦 Membangun dan menjalankan container aplikasi..."
# Langsung jalankan perintah docker-compose up
# --build memastikan image terbaru selalu dibuat
$COMPOSE_CMD up -d --build app
# Check if any container is using the DB port or if our specific container is running
EXISTING_DB=$(docker ps -q -f publish=${DB_PORT})
if [ ! -z "$EXISTING_DB" ]; then
echo "Database is already running on port ${DB_PORT}. Container ID: $EXISTING_DB"
echo "Building and updating only the application..."
# --build ensures we use the latest code
# --no-deps ensures we don't restart the DB if it's healthy
$COMPOSE_CMD up -d --build --no-deps app
else
echo "Database not found on port ${DB_PORT}."
echo "Full deployment (Database + App)..."
$COMPOSE_CMD up -d --build
fi
# Health check - optional but recommended
echo "Waiting for application to be healthy..."
# You could add a curl check here if desired
# Cleanup: remove dangling images to save disk space
echo "Cleaning up old images..."
# Membersihkan image sampah
echo "🧹 Membersihkan image lama..."
docker image prune -f
echo "Deployment script finished successfully!"
echo "Deployment Selesai! Aplikasi berjalan di port 4000."