From 617c4dedb6ddd22a46351f2c3385c27486e62df3 Mon Sep 17 00:00:00 2001 From: Silvio Date: Sun, 31 May 2026 12:12:56 -0500 Subject: [PATCH] =?UTF-8?q?Correcci=C3=B3n=20Dockerfile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 30 +++++++++++++----------------- README-DEPLOY.md | 12 ++++++------ deploy.sh | 6 +++--- nginx.conf | 14 +++++++------- 4 files changed, 29 insertions(+), 33 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1ce2d72..20661f6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,21 +1,16 @@ -# ─── Stage 1: Dependencies ─────────────────────────────────────────────────── -FROM node:20-alpine AS deps +# ─── Stage 1: Builder (install ALL deps + build) ──────────────────────────── +FROM node:20-alpine AS builder RUN apk add --no-cache libc6-compat WORKDIR /app +# Copy dependency files first (cache layer) COPY package.json package-lock.json ./ -RUN npm ci --only=production && npm cache clean --force +RUN npm ci && npm cache clean --force -# ─── Stage 2: Builder ──────────────────────────────────────────────────────── -FROM node:20-alpine AS builder -WORKDIR /app - -# Copy dependencies from deps stage -COPY --from=deps /app/node_modules ./node_modules +# Copy source code COPY . . -# Build the application (requires all env vars for static analysis) -# These are provided at build time via --build-arg or .env +# Build requires these env vars for static analysis ARG NEXT_PUBLIC_SUPABASE_URL ARG NEXT_PUBLIC_SUPABASE_ANON_KEY ENV NEXT_PUBLIC_SUPABASE_URL=$NEXT_PUBLIC_SUPABASE_URL @@ -23,7 +18,7 @@ ENV NEXT_PUBLIC_SUPABASE_ANON_KEY=$NEXT_PUBLIC_SUPABASE_ANON_KEY RUN npm run build -# ─── Stage 3: Production Runner ──────────────────────────────────────────── +# ─── Stage 2: Production Runner ──────────────────────────────────────────── FROM node:20-alpine AS runner WORKDIR /app @@ -31,21 +26,22 @@ ENV NODE_ENV=production ENV PORT=3000 ENV HOSTNAME=0.0.0.0 -# Add non-root user for security +# Create non-root user RUN addgroup --system --gid 1001 nodejs RUN adduser --system --uid 1001 nextjs -# Next.js 15 standalone output puts files in a subdir named after the project. -# Copy everything from standalone/cirux/* to /app +# Next.js standalone output includes a subdir named after the project. +# Copy from standalone/cirux/ directly to /app COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone/cirux/ ./ -COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static + +# Copy static assets (images, fonts, etc.) COPY --from=builder --chown=nextjs:nodejs /app/public ./public +COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static USER nextjs EXPOSE 3000 -# Health check HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \ CMD node -e "require('http').get('http://localhost:3000/api/health', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})" || exit 1 diff --git a/README-DEPLOY.md b/README-DEPLOY.md index 1c2e183..cb0e3fc 100644 --- a/README-DEPLOY.md +++ b/README-DEPLOY.md @@ -19,8 +19,8 @@ ### 1. Clone & Prepare ```bash -git clone /opt/enflow -cd /opt/enflow +git clone /opt/cirux +cd /opt/cirux ``` ### 2. Configure Environment @@ -59,7 +59,7 @@ The script will: docker-compose ps # Check app logs -docker-compose logs -f enflow-app +docker-compose logs -f cirux-app # Health check curl https://cirux.silvioalzate.shop/api/health @@ -92,7 +92,7 @@ docker-compose up -d ```bash # App logs -docker-compose logs -f enflow-app +docker-compose logs -f cirux-app # Nginx logs docker-compose logs -f nginx @@ -159,7 +159,7 @@ jobs: username: ${{ secrets.VPS_USER }} key: ${{ secrets.VPS_SSH_KEY }} script: | - cd /opt/enflow + cd /opt/cirux git pull docker-compose down docker-compose build --no-cache @@ -176,7 +176,7 @@ sudo systemctl stop apache2 # or nginx ### Container won't start ```bash -docker-compose logs enflow-app +docker-compose logs cirux-app # Check if .env.local is present and valid ``` diff --git a/deploy.sh b/deploy.sh index 8263f91..67aa52c 100644 --- a/deploy.sh +++ b/deploy.sh @@ -83,7 +83,7 @@ sleep 10 if curl -sf http://localhost:3000/api/health > /dev/null 2>&1; then echo "✅ App is responding on port 3000" else - echo "⚠️ App health check failed. Check logs: docker-compose logs enflow-app" + echo "⚠️ App health check failed. Check logs: docker-compose logs cirux-app" fi echo "" @@ -91,8 +91,8 @@ echo "──────────────────────── echo "🎉 Deployment Complete!" echo "" echo " App: https://$DOMAIN" -echo " Logs: docker-compose logs -f enflow-app" -echo " Restart: docker-compose restart enflow-app" +echo " Logs: docker-compose logs -f cirux-app" +echo " Restart: docker-compose restart cirux-app" echo " Update: git pull && ./deploy.sh" echo "" echo " SSL cert will auto-renew via certbot." diff --git a/nginx.conf b/nginx.conf index 36c5d3c..6fc8a65 100644 --- a/nginx.conf +++ b/nginx.conf @@ -39,8 +39,8 @@ http { limit_req_zone $binary_remote_addr zone=general:10m rate=100r/s; # Upstream to Next.js app - upstream enflow_app { - server enflow-app:3000; + upstream cirux_app { + server cirux-app:3000; } # ─── HTTP → HTTPS Redirect ─────────────────────────────────────────────── @@ -83,7 +83,7 @@ http { # Proxy to Next.js location / { limit_req zone=general burst=50 nodelay; - proxy_pass http://enflow_app; + proxy_pass http://cirux_app; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; @@ -98,7 +98,7 @@ http { # API routes with stricter rate limiting location /api/ { limit_req zone=api burst=20 nodelay; - proxy_pass http://enflow_app; + proxy_pass http://cirux_app; proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; @@ -108,20 +108,20 @@ http { # Static files caching location /_next/static/ { - proxy_pass http://enflow_app; + proxy_pass http://cirux_app; proxy_cache_valid 200 365d; add_header Cache-Control "public, immutable"; } location /static/ { - proxy_pass http://enflow_app; + proxy_pass http://cirux_app; proxy_cache_valid 200 365d; add_header Cache-Control "public, immutable"; } # WebSocket support for Supabase Realtime location /realtime/ { - proxy_pass http://enflow_app; + proxy_pass http://cirux_app; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade";