#!/bin/bash
# Exit on error
set -e

# Change directory to the Next.js project
echo "🚀 Building Next.js application..."
cd ../doormile-next
npm install
npm run build

# Go back to the build directory
echo "🧹 Preparing build context..."
cd ../doormile-build
rm -rf build

# Copy the static export into the build folder
echo "📦 Copying static export..."
cp -R ../doormile-next/out ./build

# Run the docker build
echo "🐳 Building Docker image..."
docker build -t doormile-app .

echo "✅ Docker build completed successfully!"
