From 4c6e207f28be9116f45121200286b27da2b863de Mon Sep 17 00:00:00 2001 From: Silvio Date: Sun, 31 May 2026 16:18:53 -0500 Subject: [PATCH] fix: deploy.sh deploy-auto.sh Dockerfile docker-compose.yml gitea-post-receive-hook.sh --- Dockerfile | 6 +- deploy-auto.sh | 4 +- deploy.sh | 6 +- docker-compose.yml | 2 +- gitea-post-receive-hook.sh | 4 +- nginx.conf | 131 ------------------------------------- 6 files changed, 11 insertions(+), 142 deletions(-) delete mode 100644 nginx.conf diff --git a/Dockerfile b/Dockerfile index 20661f6..3a0480c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,7 +23,7 @@ FROM node:20-alpine AS runner WORKDIR /app ENV NODE_ENV=production -ENV PORT=3000 +ENV PORT=3020 ENV HOSTNAME=0.0.0.0 # Create non-root user @@ -40,9 +40,9 @@ COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static USER nextjs -EXPOSE 3000 +EXPOSE 3020 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 + CMD node -e "require('http').get('http://localhost:3020/api/health', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})" || exit 1 CMD ["node", "server.js"] diff --git a/deploy-auto.sh b/deploy-auto.sh index 08ec8ed..42fbbc1 100644 --- a/deploy-auto.sh +++ b/deploy-auto.sh @@ -5,7 +5,7 @@ set -e -APP_DIR="/opt/cirux" +APP_DIR="/home/ubuntu/cirux" LOG_FILE="/var/log/cirux-deploy.log" BRANCH="main" @@ -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/deploy.sh b/deploy.sh index 67aa52c..ce0e71e 100644 --- a/deploy.sh +++ b/deploy.sh @@ -6,7 +6,7 @@ set -e # Example: ./deploy.sh cirux.silvioalzate.shop silvio@example.com DOMAIN=${1:-cirux.silvioalzate.shop} -EMAIL=${2:-silvio@example.com} +EMAIL=${2:-help@silvioalzate.shop} APP_DIR=$(pwd) echo "🚀 EnFlow Deploy Script" @@ -80,8 +80,8 @@ docker-compose up -d echo "✅ Verifying deployment..." sleep 10 -if curl -sf http://localhost:3000/api/health > /dev/null 2>&1; then - echo "✅ App is responding on port 3000" +if curl -sf http://localhost:3020/api/health > /dev/null 2>&1; then + echo "✅ App is responding on port 3020" else echo "⚠️ App health check failed. Check logs: docker-compose logs cirux-app" fi diff --git a/docker-compose.yml b/docker-compose.yml index 9c01344..a5a0a80 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,7 +14,7 @@ services: environment: - NODE_ENV=production expose: - - "3000" + - "3020" healthcheck: test: ["CMD", "node", "-e", "require('http').get('http://localhost:3000/api/health', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})"] interval: 30s diff --git a/gitea-post-receive-hook.sh b/gitea-post-receive-hook.sh index a70bbc5..e9dd3af 100644 --- a/gitea-post-receive-hook.sh +++ b/gitea-post-receive-hook.sh @@ -6,7 +6,7 @@ set -e -APP_DIR="/opt/cirux" +APP_DIR="/home/ubuntu/cirux" LOG_FILE="/var/log/cirux-deploy.log" BRANCH="main" DEPLOY_SCRIPT="/opt/cirux/deploy-auto.sh" @@ -26,7 +26,7 @@ while read oldrev newrev refname; do # Verify health sleep 5 - 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" else echo "$(date '+%Y-%m-%d %H:%M:%S') - Health check failed ⚠️" >> "$LOG_FILE" diff --git a/nginx.conf b/nginx.conf deleted file mode 100644 index 6fc8a65..0000000 --- a/nginx.conf +++ /dev/null @@ -1,131 +0,0 @@ -# ─── EnFlow Nginx Configuration ──────────────────────────────────────────── - -user nginx; -worker_processes auto; -error_log /var/log/nginx/error.log warn; -pid /var/run/nginx.pid; - -events { - worker_connections 1024; -} - -http { - include /etc/nginx/mime.types; - default_type application/octet-stream; - - # Logging format - log_format main '$remote_addr - $remote_user [$time_local] "$request" ' - '$status $body_bytes_sent "$http_referer" ' - '"$http_user_agent" "$http_x_forwarded_for"'; - - access_log /var/log/nginx/access.log main; - - # Performance - sendfile on; - tcp_nopush on; - tcp_nodelay on; - keepalive_timeout 65; - types_hash_max_size 2048; - - # Gzip compression - gzip on; - gzip_vary on; - gzip_proxied any; - gzip_comp_level 6; - gzip_types text/plain text/css text/xml application/json application/javascript application/rss+xml application/atom+xml image/svg+xml; - - # Rate limiting zones - limit_req_zone $binary_remote_addr zone=api:10m rate=30r/s; - limit_req_zone $binary_remote_addr zone=general:10m rate=100r/s; - - # Upstream to Next.js app - upstream cirux_app { - server cirux-app:3000; - } - - # ─── HTTP → HTTPS Redirect ─────────────────────────────────────────────── - server { - listen 80; - server_name _; - - # Certbot challenge - location /.well-known/acme-challenge/ { - root /var/www/certbot; - } - - location / { - return 301 https://$host$request_uri; - } - } - - # ─── HTTPS Server ──────────────────────────────────────────────────────── - server { - listen 443 ssl http2; - server_name _; - - # SSL certificates (mount via certbot volume) - ssl_certificate /etc/letsencrypt/live/cirux.silvioalzate.shop/fullchain.pem; - ssl_certificate_key /etc/letsencrypt/live/cirux.silvioalzate.shop/privkey.pem; - - # SSL settings - ssl_protocols TLSv1.2 TLSv1.3; - ssl_ciphers HIGH:!aNULL:!MD5; - ssl_prefer_server_ciphers on; - ssl_session_cache shared:SSL:10m; - ssl_session_timeout 1d; - - # Security headers - add_header X-Frame-Options "SAMEORIGIN" always; - add_header X-Content-Type-Options "nosniff" always; - add_header X-XSS-Protection "1; mode=block" always; - add_header Referrer-Policy "strict-origin-when-cross-origin" always; - - # Proxy to Next.js - location / { - limit_req zone=general burst=50 nodelay; - proxy_pass http://cirux_app; - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection 'upgrade'; - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; - proxy_cache_bypass $http_upgrade; - proxy_read_timeout 86400; - } - - # API routes with stricter rate limiting - location /api/ { - limit_req zone=api burst=20 nodelay; - proxy_pass http://cirux_app; - proxy_http_version 1.1; - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; - } - - # Static files caching - location /_next/static/ { - proxy_pass http://cirux_app; - proxy_cache_valid 200 365d; - add_header Cache-Control "public, immutable"; - } - - location /static/ { - 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://cirux_app; - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "upgrade"; - proxy_read_timeout 86400; - } - } -}