Corrección Dockerfile
Deploy con Docker Compose / deploy (push) Has been cancelled

This commit is contained in:
2026-05-31 12:12:56 -05:00
parent 027c36b15c
commit 617c4dedb6
4 changed files with 29 additions and 33 deletions
+13 -17
View File
@@ -1,21 +1,16 @@
# ─── Stage 1: Dependencies ─────────────────────────────────────────────────── # ─── Stage 1: Builder (install ALL deps + build) ────────────────────────────
FROM node:20-alpine AS deps FROM node:20-alpine AS builder
RUN apk add --no-cache libc6-compat RUN apk add --no-cache libc6-compat
WORKDIR /app WORKDIR /app
# Copy dependency files first (cache layer)
COPY package.json package-lock.json ./ 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 ──────────────────────────────────────────────────────── # Copy source code
FROM node:20-alpine AS builder
WORKDIR /app
# Copy dependencies from deps stage
COPY --from=deps /app/node_modules ./node_modules
COPY . . COPY . .
# Build the application (requires all env vars for static analysis) # Build requires these env vars for static analysis
# These are provided at build time via --build-arg or .env
ARG NEXT_PUBLIC_SUPABASE_URL ARG NEXT_PUBLIC_SUPABASE_URL
ARG NEXT_PUBLIC_SUPABASE_ANON_KEY ARG NEXT_PUBLIC_SUPABASE_ANON_KEY
ENV NEXT_PUBLIC_SUPABASE_URL=$NEXT_PUBLIC_SUPABASE_URL 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 RUN npm run build
# ─── Stage 3: Production Runner ──────────────────────────────────────────── # ─── Stage 2: Production Runner ────────────────────────────────────────────
FROM node:20-alpine AS runner FROM node:20-alpine AS runner
WORKDIR /app WORKDIR /app
@@ -31,21 +26,22 @@ ENV NODE_ENV=production
ENV PORT=3000 ENV PORT=3000
ENV HOSTNAME=0.0.0.0 ENV HOSTNAME=0.0.0.0
# Add non-root user for security # Create non-root user
RUN addgroup --system --gid 1001 nodejs RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs RUN adduser --system --uid 1001 nextjs
# Next.js 15 standalone output puts files in a subdir named after the project. # Next.js standalone output includes a subdir named after the project.
# Copy everything from standalone/cirux/* to /app # 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/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/public ./public
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
USER nextjs USER nextjs
EXPOSE 3000 EXPOSE 3000
# Health check
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:3000/api/health', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})" || exit 1
+6 -6
View File
@@ -19,8 +19,8 @@
### 1. Clone & Prepare ### 1. Clone & Prepare
```bash ```bash
git clone <your-repo> /opt/enflow git clone <your-repo> /opt/cirux
cd /opt/enflow cd /opt/cirux
``` ```
### 2. Configure Environment ### 2. Configure Environment
@@ -59,7 +59,7 @@ The script will:
docker-compose ps docker-compose ps
# Check app logs # Check app logs
docker-compose logs -f enflow-app docker-compose logs -f cirux-app
# Health check # Health check
curl https://cirux.silvioalzate.shop/api/health curl https://cirux.silvioalzate.shop/api/health
@@ -92,7 +92,7 @@ docker-compose up -d
```bash ```bash
# App logs # App logs
docker-compose logs -f enflow-app docker-compose logs -f cirux-app
# Nginx logs # Nginx logs
docker-compose logs -f nginx docker-compose logs -f nginx
@@ -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/enflow cd /opt/cirux
git pull git pull
docker-compose down docker-compose down
docker-compose build --no-cache docker-compose build --no-cache
@@ -176,7 +176,7 @@ sudo systemctl stop apache2 # or nginx
### Container won't start ### Container won't start
```bash ```bash
docker-compose logs enflow-app docker-compose logs cirux-app
# Check if .env.local is present and valid # Check if .env.local is present and valid
``` ```
+3 -3
View File
@@ -83,7 +83,7 @@ sleep 10
if curl -sf http://localhost:3000/api/health > /dev/null 2>&1; then if curl -sf http://localhost:3000/api/health > /dev/null 2>&1; then
echo "✅ App is responding on port 3000" echo "✅ App is responding on port 3000"
else 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 fi
echo "" echo ""
@@ -91,8 +91,8 @@ echo "────────────────────────
echo "🎉 Deployment Complete!" echo "🎉 Deployment Complete!"
echo "" echo ""
echo " App: https://$DOMAIN" echo " App: https://$DOMAIN"
echo " Logs: docker-compose logs -f enflow-app" echo " Logs: docker-compose logs -f cirux-app"
echo " Restart: docker-compose restart enflow-app" echo " Restart: docker-compose restart cirux-app"
echo " Update: git pull && ./deploy.sh" echo " Update: git pull && ./deploy.sh"
echo "" echo ""
echo " SSL cert will auto-renew via certbot." echo " SSL cert will auto-renew via certbot."
+7 -7
View File
@@ -39,8 +39,8 @@ http {
limit_req_zone $binary_remote_addr zone=general:10m rate=100r/s; limit_req_zone $binary_remote_addr zone=general:10m rate=100r/s;
# Upstream to Next.js app # Upstream to Next.js app
upstream enflow_app { upstream cirux_app {
server enflow-app:3000; server cirux-app:3000;
} }
# ─── HTTP → HTTPS Redirect ─────────────────────────────────────────────── # ─── HTTP → HTTPS Redirect ───────────────────────────────────────────────
@@ -83,7 +83,7 @@ http {
# Proxy to Next.js # Proxy to Next.js
location / { location / {
limit_req zone=general burst=50 nodelay; limit_req zone=general burst=50 nodelay;
proxy_pass http://enflow_app; proxy_pass http://cirux_app;
proxy_http_version 1.1; proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade; proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade'; proxy_set_header Connection 'upgrade';
@@ -98,7 +98,7 @@ http {
# API routes with stricter rate limiting # API routes with stricter rate limiting
location /api/ { location /api/ {
limit_req zone=api burst=20 nodelay; limit_req zone=api burst=20 nodelay;
proxy_pass http://enflow_app; proxy_pass http://cirux_app;
proxy_http_version 1.1; proxy_http_version 1.1;
proxy_set_header Host $host; proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Real-IP $remote_addr;
@@ -108,20 +108,20 @@ http {
# Static files caching # Static files caching
location /_next/static/ { location /_next/static/ {
proxy_pass http://enflow_app; proxy_pass http://cirux_app;
proxy_cache_valid 200 365d; proxy_cache_valid 200 365d;
add_header Cache-Control "public, immutable"; add_header Cache-Control "public, immutable";
} }
location /static/ { location /static/ {
proxy_pass http://enflow_app; proxy_pass http://cirux_app;
proxy_cache_valid 200 365d; proxy_cache_valid 200 365d;
add_header Cache-Control "public, immutable"; add_header Cache-Control "public, immutable";
} }
# WebSocket support for Supabase Realtime # WebSocket support for Supabase Realtime
location /realtime/ { location /realtime/ {
proxy_pass http://enflow_app; proxy_pass http://cirux_app;
proxy_http_version 1.1; proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade; proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade"; proxy_set_header Connection "upgrade";