fix: use Node.js wrapper for cross-platform PORT fallback
Replace cross-env with a simple Node.js wrapper script that: - Respects externally supplied PORT environment variable - Falls back to 8502 if PORT is not set - Works cross-platform without extra dependencies - No runtime dependencies beyond Node.js itself Changes: - Add start-server.js wrapper script - Update package.json to use wrapper - Remove cross-env dependency - Copy start-server.js in Dockerfile This fixes both issues: 1. Preserves PORT fallback behavior (PORT can be overridden) 2. No extra runtime dependencies needed
This commit is contained in:
parent
948ab04896
commit
5caf62946e
4 changed files with 11 additions and 28 deletions
|
|
@ -74,6 +74,7 @@ ENV VIRTUAL_ENV=/app/.venv
|
|||
COPY --from=builder /app/frontend/.next/standalone /app/frontend/
|
||||
COPY --from=builder /app/frontend/.next/static /app/frontend/.next/static
|
||||
COPY --from=builder /app/frontend/public /app/frontend/public
|
||||
COPY --from=builder /app/frontend/start-server.js /app/frontend/start-server.js
|
||||
|
||||
# Expose ports for Frontend and API
|
||||
EXPOSE 8502 5055
|
||||
|
|
|
|||
26
frontend/package-lock.json
generated
26
frontend/package-lock.json
generated
|
|
@ -54,7 +54,6 @@
|
|||
"@types/node": "^20",
|
||||
"@types/react": "^19",
|
||||
"@types/react-dom": "^19",
|
||||
"cross-env": "^10.1.0",
|
||||
"eslint": "^9",
|
||||
"eslint-config-next": "15.4.2",
|
||||
"tailwindcss": "^4",
|
||||
|
|
@ -126,13 +125,6 @@
|
|||
"tslib": "^2.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@epic-web/invariant": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@epic-web/invariant/-/invariant-1.0.0.tgz",
|
||||
"integrity": "sha512-lrTPqgvfFQtR/eY/qkIzp98OGdNJu0m5ji3q/nJI8v3SXkRKEnWiOxMmbvcSoAIzv/cGiuvRy57k4suKQSAdwA==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@eslint-community/eslint-utils": {
|
||||
"version": "4.7.0",
|
||||
"resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.7.0.tgz",
|
||||
|
|
@ -4046,24 +4038,6 @@
|
|||
"integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/cross-env": {
|
||||
"version": "10.1.0",
|
||||
"resolved": "https://registry.npmjs.org/cross-env/-/cross-env-10.1.0.tgz",
|
||||
"integrity": "sha512-GsYosgnACZTADcmEyJctkJIoqAhHjttw7RsFrVoJNXbsWWqaq6Ym+7kZjq6mS45O0jij6vtiReppKQEtqWy6Dw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@epic-web/invariant": "^1.0.0",
|
||||
"cross-spawn": "^7.0.6"
|
||||
},
|
||||
"bin": {
|
||||
"cross-env": "dist/bin/cross-env.js",
|
||||
"cross-env-shell": "dist/bin/cross-env-shell.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
}
|
||||
},
|
||||
"node_modules/cross-spawn": {
|
||||
"version": "7.0.6",
|
||||
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz",
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
"scripts": {
|
||||
"dev": "next dev",
|
||||
"build": "next build",
|
||||
"start": "cross-env PORT=8502 node .next/standalone/server.js",
|
||||
"start": "node start-server.js",
|
||||
"lint": "next lint"
|
||||
},
|
||||
"dependencies": {
|
||||
|
|
@ -55,7 +55,6 @@
|
|||
"@types/node": "^20",
|
||||
"@types/react": "^19",
|
||||
"@types/react-dom": "^19",
|
||||
"cross-env": "^10.1.0",
|
||||
"eslint": "^9",
|
||||
"eslint-config-next": "15.4.2",
|
||||
"tailwindcss": "^4",
|
||||
|
|
|
|||
9
frontend/start-server.js
Normal file
9
frontend/start-server.js
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
// Set default PORT if not already set
|
||||
if (!process.env.PORT) {
|
||||
process.env.PORT = '8502';
|
||||
}
|
||||
|
||||
// Start the Next.js standalone server
|
||||
require('./.next/standalone/server.js');
|
||||
Loading…
Reference in a new issue