diff --git a/nuxt4/Dockerfile b/nuxt4/Dockerfile index 7987888..3f9e972 100644 --- a/nuxt4/Dockerfile +++ b/nuxt4/Dockerfile @@ -23,6 +23,9 @@ WORKDIR /app # Copy built application from builder stage COPY --from=builder /app/.output /app/.output +# Copy SQL files for seed endpoint +COPY --from=builder /app/server/database /app/server/database + # Expose port EXPOSE 3000 diff --git a/nuxt4/server/database/00_configure_auth.sh b/nuxt4/server/database/00_configure_auth.sh index 0659ebd..c8c5a74 100755 --- a/nuxt4/server/database/00_configure_auth.sh +++ b/nuxt4/server/database/00_configure_auth.sh @@ -13,3 +13,7 @@ if ! grep -q "host all all all md5" "$PGDATA/pg_hba.conf"; then fi echo "✓ Configuración de autenticación aplicada (md5)" + +# Nota: No es necesario recargar aquí porque este script corre ANTES +# de que PostgreSQL termine su inicialización. Los cambios se aplican +# automáticamente cuando PostgreSQL termina de iniciarse. diff --git a/nuxt4/server/utils/db.ts b/nuxt4/server/utils/db.ts index 59b560c..1379506 100644 --- a/nuxt4/server/utils/db.ts +++ b/nuxt4/server/utils/db.ts @@ -18,7 +18,7 @@ export function getPool(): pg.Pool { port: parseInt(process.env.POSTGRES_PORT || '5432'), max: 20, // máximo de conexiones en el pool idleTimeoutMillis: 30000, - connectionTimeoutMillis: 2000, + connectionTimeoutMillis: 10000, // Aumentado a 10s para la primera conexión } pool = new Pool(config) @@ -27,9 +27,12 @@ export function getPool(): pg.Pool { console.error('Error inesperado en el pool de PostgreSQL:', err) }) - pool.on('connect', () => { - console.log('Nueva conexión establecida con PostgreSQL') - }) + // Solo log en desarrollo para reducir ruido + if (process.env.NODE_ENV !== 'production') { + pool.on('connect', () => { + console.log('Nueva conexión establecida con PostgreSQL') + }) + } } return pool