#!/bin/bash # Fix Docker startup for all templates - make them start faster templates=( "devforge" "mobilefirst" "saasify" "startupkit" "analyticsdash" "blog" "changelog" "ai-chat" "search" "ecommerce" "api-docs" ) for template in "${templates[@]}"; do dir="templates-repos/$template" if [ -d "$dir" ]; then echo "📦 Fixing $template Docker..." cd "$dir" # Create optimized Dockerfile cat > Dockerfile << 'EOF' FROM node:20-slim WORKDIR /app # Copy only package files first for better caching COPY package*.json ./ # Install dependencies with legacy peer deps RUN npm ci --legacy-peer-deps # Copy the rest of the application COPY . . # Build the Next.js app RUN npm run build # Expose the port EXPOSE 3000 # Use Node directly to avoid npm overhead CMD ["node", ".next/standalone/server.js"] EOF # Update next.config.js to enable standalone build if ! grep -q "output: 'standalone'" next.config.js 2>/dev/null; then cat > next.config.js << 'EOF' /** @type {import('next').NextConfig} */ const nextConfig = { output: 'standalone', reactStrictMode: true, swcMinify: true, } module.exports = nextConfig EOF fi # Commit and push git add Dockerfile next.config.js git commit -m "Optimize Docker for faster startup" 2>/dev/null || true git push hf main --force cd ../.. echo " ✅ Fixed $template" fi done echo "" echo "✅ All Dockerfiles optimized!"