fix: deploy.sh deploy-auto.sh Dockerfile docker-compose.yml gitea-post-receive-hook.sh

This commit is contained in:
2026-05-31 16:18:53 -05:00
parent 0f29f8ef61
commit 4c6e207f28
6 changed files with 11 additions and 142 deletions
+3 -3
View File
@@ -23,7 +23,7 @@ FROM node:20-alpine AS runner
WORKDIR /app WORKDIR /app
ENV NODE_ENV=production ENV NODE_ENV=production
ENV PORT=3000 ENV PORT=3020
ENV HOSTNAME=0.0.0.0 ENV HOSTNAME=0.0.0.0
# Create non-root user # Create non-root user
@@ -40,9 +40,9 @@ COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
USER nextjs USER nextjs
EXPOSE 3000 EXPOSE 3020
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \ 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"] CMD ["node", "server.js"]
+2 -2
View File
@@ -5,7 +5,7 @@
set -e set -e
APP_DIR="/opt/cirux" APP_DIR="/home/ubuntu/cirux"
LOG_FILE="/var/log/cirux-deploy.log" LOG_FILE="/var/log/cirux-deploy.log"
BRANCH="main" BRANCH="main"
@@ -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
+3 -3
View File
@@ -6,7 +6,7 @@ set -e
# Example: ./deploy.sh cirux.silvioalzate.shop silvio@example.com # Example: ./deploy.sh cirux.silvioalzate.shop silvio@example.com
DOMAIN=${1:-cirux.silvioalzate.shop} DOMAIN=${1:-cirux.silvioalzate.shop}
EMAIL=${2:-silvio@example.com} EMAIL=${2:-help@silvioalzate.shop}
APP_DIR=$(pwd) APP_DIR=$(pwd)
echo "🚀 EnFlow Deploy Script" echo "🚀 EnFlow Deploy Script"
@@ -80,8 +80,8 @@ docker-compose up -d
echo "✅ Verifying deployment..." echo "✅ Verifying deployment..."
sleep 10 sleep 10
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 "✅ App is responding on port 3000" echo "✅ App is responding on port 3020"
else else
echo "⚠️ App health check failed. Check logs: docker-compose logs cirux-app" echo "⚠️ App health check failed. Check logs: docker-compose logs cirux-app"
fi fi
+1 -1
View File
@@ -14,7 +14,7 @@ services:
environment: environment:
- NODE_ENV=production - NODE_ENV=production
expose: expose:
- "3000" - "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:3000/api/health', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})"]
interval: 30s interval: 30s
+2 -2
View File
@@ -6,7 +6,7 @@
set -e set -e
APP_DIR="/opt/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="/opt/cirux/deploy-auto.sh"
@@ -26,7 +26,7 @@ while read oldrev newrev refname; do
# Verify health # Verify health
sleep 5 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" echo "$(date '+%Y-%m-%d %H:%M:%S') - Deploy successful ✅" >> "$LOG_FILE"
else else
echo "$(date '+%Y-%m-%d %H:%M:%S') - Health check failed ⚠️" >> "$LOG_FILE" echo "$(date '+%Y-%m-%d %H:%M:%S') - Health check failed ⚠️" >> "$LOG_FILE"
-131
View File
@@ -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;
}
}
}