From d99aec2f1ade0974de49b5eebd268b6d5c18e3ab Mon Sep 17 00:00:00 2001 From: Silvio Date: Sun, 31 May 2026 17:25:27 -0500 Subject: [PATCH] fix: port 3000 > 3020, APP_DIR /opt/cirux > /home/ubuntu/cirux --- Dockerfile | 17 ++++++++++------- README-DEPLOY.md | 10 +++++----- deploy-auto.sh | 4 ++-- docker-compose.yml | 2 +- gitea-post-receive-hook.sh | 4 ++-- 5 files changed, 20 insertions(+), 17 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1c5ff17..9255c4b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,13 +18,16 @@ ENV NEXT_PUBLIC_SUPABASE_ANON_KEY=$NEXT_PUBLIC_SUPABASE_ANON_KEY RUN npm run build -# Next.js standalone creates a subdirectory named after the project folder. -# We flatten it to a known location so the runner doesn't depend on the name. -RUN echo "=== Standalone output structure ===" && \ +# Flatten standalone output — find the single subdir Next.js creates +RUN set -e && \ + echo "=== Standalone output ===" && \ ls -la /app/.next/standalone/ && \ mkdir -p /app/.next/standalone-export && \ - cp -r /app/.next/standalone/*/ /app/.next/standalone-export/ && \ - ls -la /app/.next/standalone-export/ + STANDALONE_DIR=$(find /app/.next/standalone -maxdepth 1 -mindepth 1 -type d | head -1) && \ + echo "Copying from: $STANDALONE_DIR" && \ + cp -r "$STANDALONE_DIR"/* /app/.next/standalone-export/ && \ + ls -la /app/.next/standalone-export/ && \ + test -f /app/.next/standalone-export/server.js && echo "✅ server.js found" || (echo "❌ server.js NOT FOUND" && exit 1) # ─── Stage 2: Production Runner ──────────────────────────────────────────── FROM node:20-alpine AS runner @@ -38,10 +41,10 @@ ENV HOSTNAME=0.0.0.0 RUN addgroup --system --gid 1001 nodejs RUN adduser --system --uid 1001 nextjs -# Copy flattened standalone output (server.js is now directly in /app) +# Copy flattened standalone output (server.js directly in /app) COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone-export/ ./ -# Copy static assets (images, fonts, etc.) +# Copy static assets COPY --from=builder --chown=nextjs:nodejs /app/public ./public COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static diff --git a/README-DEPLOY.md b/README-DEPLOY.md index cb0e3fc..30ff862 100644 --- a/README-DEPLOY.md +++ b/README-DEPLOY.md @@ -5,7 +5,7 @@ ``` ┌─────────────┐ ┌──────────────┐ ┌─────────────┐ │ Internet │────▶│ Nginx (80/443) │───▶│ Next.js │ -│ │ │ Reverse Proxy │ │ (port 3000)│ +│ │ │ Reverse Proxy │ │ (port 3020)│ └─────────────┘ └──────────────┘ └─────────────┘ │ ┌──────┴──────┐ @@ -19,8 +19,8 @@ ### 1. Clone & Prepare ```bash -git clone /opt/cirux -cd /opt/cirux +git clone /home/ubuntu/cirux +cd /home/ubuntu/cirux ``` ### 2. Configure Environment @@ -159,7 +159,7 @@ jobs: username: ${{ secrets.VPS_USER }} key: ${{ secrets.VPS_SSH_KEY }} script: | - cd /opt/cirux + cd /home/ubuntu/cirux git pull docker-compose down docker-compose build --no-cache @@ -189,7 +189,7 @@ docker-compose restart nginx ### Health check fails ```bash # Test locally -curl http://localhost:3000/api/health +curl http://localhost:3020/api/health # Should return {"status":"ok"} ``` diff --git a/deploy-auto.sh b/deploy-auto.sh index ee49643..5dd5e9f 100644 --- a/deploy-auto.sh +++ b/deploy-auto.sh @@ -1,7 +1,7 @@ #!/bin/bash # ─── EnFlow Auto-Deploy Script ─────────────────────────────────────────────── # Called by Gitea post-receive hook or manually -# Usage: /opt/cirux/deploy-auto.sh +# Usage: /home/ubuntu/cirux/deploy-auto.sh set -e @@ -40,7 +40,7 @@ sleep 10 RETRIES=5 while [ $RETRIES -gt 0 ]; do - if curl -sf http://localhost:3000/api/health > /dev/null 2>&1; then + if curl -sf http://localhost:3020/api/health > /dev/null 2>&1; then echo "$(date '+%Y-%m-%d %H:%M:%S') - Deploy successful ✅" >> "$LOG_FILE" exit 0 fi diff --git a/docker-compose.yml b/docker-compose.yml index 248edc9..002e95b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,7 +16,7 @@ services: ports: - "127.0.0.1:3020:3020" healthcheck: - test: ["CMD", "node", "-e", "require('http').get('http://localhost:3000/api/health', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})"] + test: ["CMD", "node", "-e", "require('http').get('http://localhost:3020/api/health', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})"] interval: 30s timeout: 5s retries: 3 diff --git a/gitea-post-receive-hook.sh b/gitea-post-receive-hook.sh index e9dd3af..aa9ee60 100644 --- a/gitea-post-receive-hook.sh +++ b/gitea-post-receive-hook.sh @@ -9,7 +9,7 @@ set -e APP_DIR="/home/ubuntu/cirux" LOG_FILE="/var/log/cirux-deploy.log" BRANCH="main" -DEPLOY_SCRIPT="/opt/cirux/deploy-auto.sh" +DEPLOY_SCRIPT="/home/ubuntu/cirux/deploy-auto.sh" echo "$(date '+%Y-%m-%d %H:%M:%S') - Push received, starting deploy..." >> "$LOG_FILE" @@ -22,7 +22,7 @@ while read oldrev newrev refname; do cd "$APP_DIR" # Run deploy script - /opt/cirux/deploy-auto.sh >> "$LOG_FILE" 2>&1 + /home/ubuntu/cirux/deploy-auto.sh >> "$LOG_FILE" 2>&1 # Verify health sleep 5