From 492d8445237926bba5c9619576ebd57e9df65dd8 Mon Sep 17 00:00:00 2001 From: msaldain Date: Mon, 18 Aug 2025 20:35:47 +0000 Subject: [PATCH] =?UTF-8?q?Todos=20los=20problemas=20de=20dependencias,=20?= =?UTF-8?q?credenciales=20y=20renderizado=20de=20raiz=20se=20solucionaron?= =?UTF-8?q?=20hasta=20qu=C3=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- services/app/Dockerfile.production | 7 +++---- services/app/src/index.js | 8 +++----- services/auth/Dockerfile.production | 7 +++---- services/auth/src/index.js | 16 +++++++--------- services/{app => auth}/src/pages/index.html | 0 5 files changed, 16 insertions(+), 22 deletions(-) rename services/{app => auth}/src/pages/index.html (100%) diff --git a/services/app/Dockerfile.production b/services/app/Dockerfile.production index fdca08b..7e33bed 100644 --- a/services/app/Dockerfile.production +++ b/services/app/Dockerfile.production @@ -1,8 +1,8 @@ # Dockerfile.dev -FROM node:20.17 +FROM node:22.18 # Definir variables de entorno con valores predeterminados -ARG NODE_ENV=development +ARG NODE_ENV=production ARG PORT=3000 RUN apt-get update @@ -20,5 +20,4 @@ COPY . . # Expone el puerto EXPOSE 3000 -# Usa nodemon para hot reload si lo tenés -CMD ["npm", "run", "dev"] \ No newline at end of file +CMD ["npm", "run", "start"] \ No newline at end of file diff --git a/services/app/src/index.js b/services/app/src/index.js index bb6489f..14ecb35 100644 --- a/services/app/src/index.js +++ b/services/app/src/index.js @@ -21,10 +21,10 @@ try { console.log(`Activando entorno de ->${chalk.green(` DEVELOPMENT `)}`); } else if (process.env.NODE_ENV === 'stage') { dotenv.config({ path: path.resolve(__dirname, '../.env.test' )}); - console.log(`Activando entorno de ->->${chalk.yellow(` TESTING `)}`); + console.log(`Activando entorno de ->${chalk.yellow(` TESTING `)}`); } else if (process.env.NODE_ENV === 'production') { dotenv.config({ path: path.resolve(__dirname, '../.env.production' )}); - console.log(`Activando entorno de ->->${chalk.red(` PRODUCTION `)}`); + console.log(`Activando entorno de ->${chalk.red(` PRODUCTION `)}`); } } catch (error) { console.log("A ocurrido un error al seleccionar el entorno. \nError: " + error); @@ -34,6 +34,7 @@ try { const app = express(); app.use(cors()); app.use(express.json()); +app.use(express.static(path.join(__dirname, 'pages'))); // Configuración de conexión PostgreSQL @@ -64,9 +65,6 @@ async function verificarConexion() { // === Servir páginas estáticas === -app.use(express.static(path.join(__dirname, 'pages'))); - -app.get('/',(req, res) => res.sendFile(path.join(__dirname, 'pages', 'index.html'))); app.get('/roles', (req, res) => res.sendFile(path.join(__dirname, 'pages', 'roles.html'))); app.get('/usuarios', (req, res) => res.sendFile(path.join(__dirname, 'pages', 'usuarios.html'))); diff --git a/services/auth/Dockerfile.production b/services/auth/Dockerfile.production index 3bed048..9e28426 100644 --- a/services/auth/Dockerfile.production +++ b/services/auth/Dockerfile.production @@ -1,8 +1,8 @@ # Dockerfile.dev -FROM node:20.17 +FROM node:22.18 # Definir variables de entorno con valores predeterminados -ARG NODE_ENV=development +ARG NODE_ENV=production ARG PORT=4000 RUN apt-get update @@ -20,5 +20,4 @@ COPY . . # Expone el puerto EXPOSE 4000 -# Usa nodemon para hot reload si lo tenés -CMD ["npm", "run", "dev"] \ No newline at end of file +CMD ["npm", "run", "start"] \ No newline at end of file diff --git a/services/auth/src/index.js b/services/auth/src/index.js index 19ca656..0d3ece8 100644 --- a/services/auth/src/index.js +++ b/services/auth/src/index.js @@ -22,20 +22,22 @@ try { console.log(`Activando entorno de ->${chalk.green(` DEVELOPMENT `)}`); } else if (process.env.NODE_ENV === 'stage') { dotenv.config({ path: path.resolve(__dirname, '../.env.test' )}); - console.log(`Activando entorno de ->->${chalk.yellow(` TESTING `)}`); + console.log(`Activando entorno de ->${chalk.yellow(` TESTING `)}`); } else if (process.env.NODE_ENV === 'production') { dotenv.config({ path: path.resolve(__dirname, '../.env.production' )}); - console.log(`Activando entorno de ->->${chalk.red(` PRODUCTION `)}`); + console.log(`Activando entorno de ->${chalk.red(` PRODUCTION `)}`); } } catch (error) { console.log("A ocurrido un error al seleccionar el entorno. \nError: " + error); } -// Renderiado +// Configuración de renderizado const app = express(); app.use(cors()); app.use(express.json()); -app.set('trust proxy', 1); +app.set('trust proxy', true); +app.use(express.static(path.join(__dirname, 'pages'))); + // Configuración de conexión PostgreSQL @@ -64,13 +66,9 @@ async function verificarConexion() { } - // === Servir páginas estáticas === -app.set('trust proxy', true); - -app.use(express.static(path.join(__dirname, 'pages'))); - +app.get('/',(req, res) => res.sendFile(path.join(__dirname, 'pages', 'index.html'))); app.get('/planes', async (req, res) => { try { diff --git a/services/app/src/pages/index.html b/services/auth/src/pages/index.html similarity index 100% rename from services/app/src/pages/index.html rename to services/auth/src/pages/index.html