feat: add configurable PORT for dev and start servers (#179)

- package.json: dev and start scripts now use ${PORT:-3000}
- Dockerfile: healthcheck uses ${PORT:-3000}, ENV PORT=3000 as default
- docker-compose.yml: passes PORT env to container, maps MC_PORT to PORT
- .env.example: documents PORT variable

Set PORT=<number> to change the listening port. Defaults to 3000.
Previously dev used Next.js default (3000) and start hardcoded 3005.
This commit is contained in:
Patrick 2026-03-04 23:00:34 -05:00 committed by GitHub
parent 298fbef562
commit 6f2f0e74af
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 11 additions and 5 deletions

View File

@ -1,3 +1,7 @@
# === Server Port ===
# Port the Next.js server listens on (dev and production)
# PORT=3000
# === Authentication === # === Authentication ===
# Admin user seeded on first run (only if no users exist in DB) # Admin user seeded on first run (only if no users exist in DB)
AUTH_USER=admin AUTH_USER=admin

View File

@ -32,9 +32,9 @@ COPY --from=build /app/src/lib/schema.sql ./src/lib/schema.sql
RUN mkdir -p .data && chown nextjs:nodejs .data RUN mkdir -p .data && chown nextjs:nodejs .data
RUN apt-get update && apt-get install -y curl --no-install-recommends && rm -rf /var/lib/apt/lists/* RUN apt-get update && apt-get install -y curl --no-install-recommends && rm -rf /var/lib/apt/lists/*
USER nextjs USER nextjs
EXPOSE 3000
ENV PORT=3000 ENV PORT=3000
EXPOSE 3000
ENV HOSTNAME=0.0.0.0 ENV HOSTNAME=0.0.0.0
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \ HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD curl -f http://localhost:3000/login || exit 1 CMD curl -f http://localhost:${PORT:-3000}/login || exit 1
CMD ["node", "server.js"] CMD ["node", "server.js"]

View File

@ -3,7 +3,9 @@ services:
build: . build: .
container_name: mission-control container_name: mission-control
ports: ports:
- "${MC_PORT:-3000}:3000" - "${MC_PORT:-3000}:${PORT:-3000}"
environment:
- PORT=${PORT:-3000}
env_file: env_file:
- path: .env - path: .env
required: false required: false

View File

@ -3,9 +3,9 @@
"version": "1.3.0", "version": "1.3.0",
"description": "OpenClaw Mission Control — open-source agent orchestration dashboard", "description": "OpenClaw Mission Control — open-source agent orchestration dashboard",
"scripts": { "scripts": {
"dev": "next dev --hostname 127.0.0.1", "dev": "next dev --hostname 127.0.0.1 --port ${PORT:-3000}",
"build": "next build", "build": "next build",
"start": "next start --hostname 0.0.0.0 --port 3005", "start": "next start --hostname 0.0.0.0 --port ${PORT:-3000}",
"lint": "eslint .", "lint": "eslint .",
"typecheck": "tsc --noEmit", "typecheck": "tsc --noEmit",
"test": "vitest run", "test": "vitest run",