fix: port 3000 > 3020, APP_DIR /opt/cirux > /home/ubuntu/cirux

This commit is contained in:
2026-05-31 17:25:27 -05:00
parent 1004707d8f
commit d99aec2f1a
5 changed files with 20 additions and 17 deletions
+10 -7
View File
@@ -18,13 +18,16 @@ ENV NEXT_PUBLIC_SUPABASE_ANON_KEY=$NEXT_PUBLIC_SUPABASE_ANON_KEY
RUN npm run build RUN npm run build
# Next.js standalone creates a subdirectory named after the project folder. # Flatten standalone output — find the single subdir Next.js creates
# We flatten it to a known location so the runner doesn't depend on the name. RUN set -e && \
RUN echo "=== Standalone output structure ===" && \ echo "=== Standalone output ===" && \
ls -la /app/.next/standalone/ && \ ls -la /app/.next/standalone/ && \
mkdir -p /app/.next/standalone-export && \ mkdir -p /app/.next/standalone-export && \
cp -r /app/.next/standalone/*/ /app/.next/standalone-export/ && \ STANDALONE_DIR=$(find /app/.next/standalone -maxdepth 1 -mindepth 1 -type d | head -1) && \
ls -la /app/.next/standalone-export/ 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 ──────────────────────────────────────────── # ─── Stage 2: Production Runner ────────────────────────────────────────────
FROM node:20-alpine AS runner FROM node:20-alpine AS runner
@@ -38,10 +41,10 @@ ENV HOSTNAME=0.0.0.0
RUN addgroup --system --gid 1001 nodejs RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs 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 --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/public ./public
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
+5 -5
View File
@@ -5,7 +5,7 @@
``` ```
┌─────────────┐ ┌──────────────┐ ┌─────────────┐ ┌─────────────┐ ┌──────────────┐ ┌─────────────┐
│ Internet │────▶│ Nginx (80/443) │───▶│ Next.js │ │ Internet │────▶│ Nginx (80/443) │───▶│ Next.js │
│ │ │ Reverse Proxy │ │ (port 3000)│ │ │ │ Reverse Proxy │ │ (port 3020)│
└─────────────┘ └──────────────┘ └─────────────┘ └─────────────┘ └──────────────┘ └─────────────┘
┌──────┴──────┐ ┌──────┴──────┐
@@ -19,8 +19,8 @@
### 1. Clone & Prepare ### 1. Clone & Prepare
```bash ```bash
git clone <your-repo> /opt/cirux git clone <your-repo> /home/ubuntu/cirux
cd /opt/cirux cd /home/ubuntu/cirux
``` ```
### 2. Configure Environment ### 2. Configure Environment
@@ -159,7 +159,7 @@ jobs:
username: ${{ secrets.VPS_USER }} username: ${{ secrets.VPS_USER }}
key: ${{ secrets.VPS_SSH_KEY }} key: ${{ secrets.VPS_SSH_KEY }}
script: | script: |
cd /opt/cirux cd /home/ubuntu/cirux
git pull git pull
docker-compose down docker-compose down
docker-compose build --no-cache docker-compose build --no-cache
@@ -189,7 +189,7 @@ docker-compose restart nginx
### Health check fails ### Health check fails
```bash ```bash
# Test locally # Test locally
curl http://localhost:3000/api/health curl http://localhost:3020/api/health
# Should return {"status":"ok"} # Should return {"status":"ok"}
``` ```
+2 -2
View File
@@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# ─── EnFlow Auto-Deploy Script ─────────────────────────────────────────────── # ─── EnFlow Auto-Deploy Script ───────────────────────────────────────────────
# Called by Gitea post-receive hook or manually # Called by Gitea post-receive hook or manually
# Usage: /opt/cirux/deploy-auto.sh # Usage: /home/ubuntu/cirux/deploy-auto.sh
set -e set -e
@@ -40,7 +40,7 @@ sleep 10
RETRIES=5 RETRIES=5
while [ $RETRIES -gt 0 ]; do 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" echo "$(date '+%Y-%m-%d %H:%M:%S') - Deploy successful ✅" >> "$LOG_FILE"
exit 0 exit 0
fi fi
+1 -1
View File
@@ -16,7 +16,7 @@ services:
ports: ports:
- "127.0.0.1:3020:3020" - "127.0.0.1:3020:3020"
healthcheck: 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 interval: 30s
timeout: 5s timeout: 5s
retries: 3 retries: 3
+2 -2
View File
@@ -9,7 +9,7 @@ set -e
APP_DIR="/home/ubuntu/cirux" APP_DIR="/home/ubuntu/cirux"
LOG_FILE="/var/log/cirux-deploy.log" LOG_FILE="/var/log/cirux-deploy.log"
BRANCH="main" 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" 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" cd "$APP_DIR"
# Run deploy script # Run deploy script
/opt/cirux/deploy-auto.sh >> "$LOG_FILE" 2>&1 /home/ubuntu/cirux/deploy-auto.sh >> "$LOG_FILE" 2>&1
# Verify health # Verify health
sleep 5 sleep 5