From 22419106c138b5f4ff50806ad57598cd8fef2448 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 5 Mar 2026 20:39:26 +0000 Subject: [PATCH] Fix APP_PORT: make container listen port and healthcheck follow APP_PORT Co-authored-by: xCyanGrizzly <53275238+xCyanGrizzly@users.noreply.github.com> --- .env.example | 2 ++ Dockerfile | 1 + docker-compose.yml | 5 +++-- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.env.example b/.env.example index 119b703..bf3752b 100644 --- a/.env.example +++ b/.env.example @@ -13,6 +13,8 @@ AUTH_GITHUB_ID="" AUTH_GITHUB_SECRET="" # App +# APP_PORT controls the port the container listens on AND how it is exposed on the host. +# If you change APP_PORT, also update NEXT_PUBLIC_APP_URL to match. NEXT_PUBLIC_APP_URL="http://localhost:3000" APP_PORT=3000 diff --git a/Dockerfile b/Dockerfile index 7ae07af..f48c101 100644 --- a/Dockerfile +++ b/Dockerfile @@ -54,6 +54,7 @@ RUN chmod +x docker-entrypoint.sh USER nextjs +# Default port — overridden at runtime by the PORT env var (set via docker-compose APP_PORT) EXPOSE 3000 ENV PORT=3000 ENV HOSTNAME="0.0.0.0" diff --git a/docker-compose.yml b/docker-compose.yml index 51839f5..285d36a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,7 +5,7 @@ services: dockerfile: Dockerfile pull_policy: never ports: - - "${APP_PORT:-3000}:3000" + - "${APP_PORT:-3000}:${APP_PORT:-3000}" environment: - DATABASE_URL=postgresql://${POSTGRES_USER:-dragons}:${POSTGRES_PASSWORD:-stash}@db:5432/${POSTGRES_DB:-dragonsstash} - AUTH_SECRET=${AUTH_SECRET:?Set AUTH_SECRET in .env} @@ -18,11 +18,12 @@ services: - BOT_USERNAME=${BOT_USERNAME:-} - LOG_LEVEL=${LOG_LEVEL:-info} - WORKER_INTERVAL_MINUTES=${WORKER_INTERVAL_MINUTES:-60} + - PORT=${APP_PORT:-3000} depends_on: db: condition: service_healthy healthcheck: - test: ["CMD", "wget", "-q", "--spider", "http://localhost:3000/api/health"] + test: ["CMD-SHELL", "wget -q --spider http://localhost:$$PORT/api/health || exit 1"] interval: 30s timeout: 5s retries: 3