From 97e7ecd1b2afb7174619fd7e532aa903141934b5 Mon Sep 17 00:00:00 2001 From: FragginWagon Date: Thu, 29 Jan 2026 06:36:28 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Update=20docker-compose=20modifi?= =?UTF-8?q?cation=20logic=20to=20include=20backend=20port=20mapping=20and?= =?UTF-8?q?=20refine=20frontend=20port=20handling?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- code/utils/deploy-pokedex.js | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/code/utils/deploy-pokedex.js b/code/utils/deploy-pokedex.js index 442e4dd..97c4934 100644 --- a/code/utils/deploy-pokedex.js +++ b/code/utils/deploy-pokedex.js @@ -120,26 +120,39 @@ function expandTilde(filepath) { } /** - * Create modified docker-compose.yml with custom ports - * @param {number} port - HTTP port to map to container - * @param {number|null} sslPort - HTTPS port to map to container (optional) + * Create modified docker-compose.production.yml with custom ports + * @param {number} port - HTTP port to map to frontend container + * @param {number|null} sslPort - HTTPS port to map to frontend container (optional) + * @param {number} backendPort - Port to map to backend container * @returns {string} Modified docker-compose content */ -function createModifiedDockerCompose(port, sslPort) { - const originalPath = path.join(SOURCE_DIR, 'docker-compose.yml'); +function createModifiedDockerCompose(port, sslPort, backendPort) { + const originalPath = path.join(SOURCE_DIR, 'docker-compose.production.yml'); let content = fs.readFileSync(originalPath, 'utf8'); - // Replace HTTP port mapping (handle both single and double quotes) - content = content.replace(/- ['"](\d+):80['"]/, `- '${port}:80'`); + // Replace frontend HTTP port mapping + content = content.replace( + /(frontend:[\s\S]*?ports:[\s\S]*?- ['"])(\d+)(:80['"])/, + `$1${port}$3` + ); - // Replace HTTPS port mapping if SSL port provided + // Replace frontend HTTPS port mapping if SSL port provided if (sslPort !== null) { - content = content.replace(/- ['"](\d+):443['"]/, `- '${sslPort}:443'`); + content = content.replace( + /(frontend:[\s\S]*?ports:[\s\S]*?- ['"])(\d+)(:443['"])/, + `$1${sslPort}$3` + ); } else { - // Remove HTTPS port mapping if no SSL port specified - content = content.replace(/\s*- ['"](\d+):443['"]/g, ''); + // Remove HTTPS port mapping line if no SSL port specified + content = content.replace(/\s*- ['"](\d+):443['"]\n?/g, ''); } + // Replace backend port mapping + content = content.replace( + /(backend:[\s\S]*?ports:[\s\S]*?- ['"])(\d+)(:3000['"])/, + `$1${backendPort}$3` + ); + return content; }