fix: Bind Next.js server to 0.0.0.0 for external access

The deployment was unreachable because the Next.js server was binding
to localhost:3000 (127.0.0.1) instead of 0.0.0.0, making it only
accessible inside the Docker container.

- Added HOSTNAME=0.0.0.0 to Dockerfile build and runtime stages
- Added HOSTNAME=0.0.0.0 to docker-compose.yml for nextjs service

This allows the server to accept connections from external hosts.
This commit is contained in:
WorkClub Automation
2026-03-20 13:29:21 +01:00
parent 3cf7c3a221
commit 1aea91da55
6 changed files with 225 additions and 1 deletions
+6 -1
View File
@@ -13,6 +13,9 @@ RUN npm install -g bun
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
# Set environment for build to ensure server binds to all interfaces
ENV HOSTNAME="0.0.0.0"
ENV PORT="3000"
RUN bun run build
# Stage 3: Runtime
@@ -36,5 +39,7 @@ EXPOSE 3000
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD node -e "require('http').get('http://localhost:3000', (r) => {if (r.statusCode !== 200) throw new Error(r.statusCode)})"
# Start standalone server
# Start standalone server - bind to all interfaces (0.0.0.0) for external access
ENV HOSTNAME="0.0.0.0"
ENV PORT="3000"
CMD ["node", "server.js"]