ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.
Python astracloudflarecontrol-panelcyberpaneldnsfablehosting-control-panelhosting-panelkimi-k3server-managementserverkitubuntu-web-panelwebserver
Build frontend on host to avoid Docker memory issues
Juan Denis0b7dcf69cfa3
diff --git a/frontend/Dockerfile b/frontend/Dockerfileindex 3db7b0e4..c4d01f90 100644--- a/frontend/Dockerfile+++ b/frontend/Dockerfile@@ -1,29 +1,13 @@# Frontend Dockerfile for ServerKit-# Stage 1: Build-FROM node:20-alpine AS builder--WORKDIR /app--# Copy package files-COPY package*.json ./--# Install dependencies-RUN npm ci--# Copy source code-COPY . .--# Build the application-RUN NODE_OPTIONS="--max-old-space-size=4096" npm run build--# Stage 2: Production+# Pre-built assets are copied in — the Vite build runs on the host+# to avoid memory issues on low-RAM VPS servers.FROM nginx:alpine# Copy custom nginx configCOPY nginx.conf /etc/nginx/conf.d/default.conf-# Copy built assets from builder stage-COPY --from=builder /app/dist /usr/share/nginx/html+# Copy pre-built frontend assets+COPY dist /usr/share/nginx/html# Create non-root user for nginxRUN chown -R nginx:nginx /usr/share/nginx/html && \diff --git a/install.sh b/install.shindex f44ccdc9..c2da3031 100644--- a/install.sh+++ b/install.sh@@ -111,6 +111,16 @@ elseprint_success "Docker Compose already installed"fi+# Install Node.js for frontend build (builds on host to avoid Docker memory issues)+if ! command -v node &> /dev/null; then+ print_info "Installing Node.js..."+ curl -fsSL https://deb.nodesource.com/setup_20.x | bash -+ apt-get install -y nodejs+ print_success "Node.js $(node --version) installed"+else+ print_success "Node.js $(node --version) already installed"+fi+# Clone or update repositoryprint_info "Installing ServerKit to $INSTALL_DIR..."@@ -241,12 +251,31 @@ cp "$INSTALL_DIR/nginx/sites-available/example.conf.template" /etc/nginx/sites-aprint_success "Nginx proxy configured"-# Clean up Docker networks to prevent issues+# Clean up Docker to prevent issuesprint_info "Cleaning up Docker..."docker network prune -f 2>/dev/null || truedocker container prune -f 2>/dev/null || true-# Build and start frontend container+# Ensure swap exists for low-RAM VPS servers (Vite build needs ~512MB+)+SWAP_TOTAL=$(free -m | awk '/^Swap:/ {print $2}')+if [ "$SWAP_TOTAL" -lt 512 ]; then+ print_info "Creating swap space for build..."+ if [ ! -f /swapfile ]; then+ fallocate -l 1G /swapfile 2>/dev/null || dd if=/dev/zero of=/swapfile bs=1M count=1024 status=none+ chmod 600 /swapfile+ mkswap /swapfile >/dev/null+ fi+ swapon /swapfile 2>/dev/null || true+fi++# Build frontend on host (avoids Docker memory overhead on low-RAM VPS)+print_info "Building frontend..."+cd "$INSTALL_DIR/frontend"+npm ci --prefer-offline 2>&1 | tail -1+NODE_OPTIONS="--max-old-space-size=1024" npm run build+print_success "Frontend built"++# Package frontend into nginx containerprint_info "Building frontend container..."cd "$INSTALL_DIR"docker compose build