From 919970338679c57f12f07d6cc06a2a63ed048fb7 Mon Sep 17 00:00:00 2001 From: Huzaifa Inam Date: Fri, 7 Aug 2026 18:58:55 +0500 Subject: [PATCH] Ports fixed v0.3 --- .env.example | 4 ---- COOLIFY.md | 8 +++----- README.md | 18 ++++++------------ docker-compose.yml | 10 ++++------ src/App.tsx | 2 +- src/components/HolographicCanvas.tsx | 8 +++++++- 6 files changed, 21 insertions(+), 29 deletions(-) diff --git a/.env.example b/.env.example index c154fd8..d7f459e 100644 --- a/.env.example +++ b/.env.example @@ -2,10 +2,6 @@ PORT=3000 NODE_ENV=production -# Host Port Mappings for Docker / Coolify (Exposed on host as 7000 and 7001 to prevent conflicts with other applications) -HOST_PORT=7000 -POSTGRES_HOST_PORT=7001 - # PostgreSQL Database Configuration DATABASE_URL=postgresql://postgres:postgres_secure_pass_2026@postgres:5432/balance_sheet_db POSTGRES_PASSWORD=postgres_secure_pass_2026 diff --git a/COOLIFY.md b/COOLIFY.md index d72d28a..f13fd96 100644 --- a/COOLIFY.md +++ b/COOLIFY.md @@ -19,8 +19,6 @@ This application consists of: ```env NODE_ENV=production PORT=3000 - HOST_PORT=7000 # Mapped host port (7000:3000) to avoid conflicts - POSTGRES_HOST_PORT=7001 # Mapped host database port (7001:5432) to avoid conflicts POSTGRES_PASSWORD=your_custom_secure_password # SMTP Email Dispatch Settings @@ -32,7 +30,7 @@ This application consists of: SMTP_USE_TLS=true ``` 3. **Deploy**: - - Coolify will build the app container and spin up a dedicated `postgres:16-alpine` database container with health checks and persistent volume storage (`balance_sheet_postgres_data`). Access the app on host port `7000`. + - Coolify will build the app container and spin up a dedicated `postgres:16-alpine` database container with health checks and persistent volume storage (`balance_sheet_postgres_data`). The application uses `expose: "3000"` to avoid host port binding conflicts while allowing Coolify's reverse proxy (Traefik/Nginx) to route external web traffic. --- @@ -63,8 +61,8 @@ If you prefer using Coolify's built-in managed PostgreSQL database resource: ## 2. Server-Side Architecture & Configuration -- **Internal Container Port**: Application listens on `3000` inside the container. -- **Conflict Prevention**: Host port mappings in `docker-compose.yml` use `${HOST_PORT:-7000}:3000` and `${POSTGRES_HOST_PORT:-7001}:5432` to avoid conflicts on host ports 3000, 8080, and 5432. +- **Internal Container Port**: Application listens on `3000` inside the container (`EXPOSE 3000`). +- **Conflict Prevention**: Uses Docker Compose `expose` (`3000` for app, `5432` for postgres) instead of direct host port bindings to eliminate host interface port allocation conflicts. - **SMTP Environment Overrides**: SMTP configuration (`SMTP_HOST`, `SMTP_PORT`, `SMTP_USER`, `SMTP_PASS`, `SMTP_FROM`, `SMTP_USE_TLS`) is fully managed via environment variables. - **Automatic Table Creation**: On server boot, the backend runs `initPgDatabase()` to verify/create `app_portal_state`. - **Automatic State Recovery**: If PostgreSQL contains existing data, portal state is loaded directly from PostgreSQL. diff --git a/README.md b/README.md index 36472a2..901d32a 100644 --- a/README.md +++ b/README.md @@ -17,10 +17,10 @@ A full-stack enterprise web application built for multi-branch balance sheet con | File | Description | | :--- | :--- | -| `Dockerfile` & `dockerfile` | Multi-stage production container build (Vite client + Express CJS server). | -| `docker-compose.yml` | Full-stack orchestration (App container mapped to host port 7000 + PostgreSQL container mapped to host port 7001). | +| `Dockerfile` & `dockerfile` | Multi-stage production container build (Vite client + Express CJS server, exposing port 3000). | +| `docker-compose.yml` | Full-stack orchestration using `expose: "3000"` and `expose: "5432"` to prevent host port binding conflicts. | | `.dockerignore` | Defines context exclusions for slim Docker image builds. | -| `.env.example` | Template environment variables (`DATABASE_URL`, `PORT`, `HOST_PORT`, `POSTGRES_HOST_PORT`, `DATA_PATH`, `SMTP_*`). | +| `.env.example` | Template environment variables (`DATABASE_URL`, `PORT`, `DATA_PATH`, `SMTP_*`). | | `COOLIFY.md` | Complete deployment guide for Coolify platform & managed databases. | | `server.ts` | Express server entry point with PostgreSQL initialization, environment SMTP dispatching, and REST API routes. | @@ -28,22 +28,16 @@ A full-stack enterprise web application built for multi-branch balance sheet con ## 🛠️ Local Development & Running via Docker -### 1. Run via Docker Compose (With PostgreSQL & Non-Conflicting Host Ports) +### 1. Run via Docker Compose (With PostgreSQL & Exposed Port 3000) ```bash docker-compose up --build -d ``` -By default, the application will be accessible on host port `http://localhost:7000` (mapped to internal container port `3000`), and PostgreSQL on host port `7001` (mapped to internal container port `5432`), preventing conflicts with common host ports like 3000, 8080, or 5432. - -If you wish to use different custom host ports, set them in `.env`: -```env -HOST_PORT=7000 -POSTGRES_HOST_PORT=7001 -``` +The application container exposes port `3000` internally via Docker network `expose` configuration, avoiding host port allocation conflicts. Reverse proxies (Coolify, Traefik, Nginx) or container networks route directly to port `3000`. ### 2. Run via Docker CLI ```bash docker build -t balance-sheet-portal . -docker run -p 7000:3000 -v portal_data:/app/data balance-sheet-portal +docker run -p 3000:3000 -v portal_data:/app/data balance-sheet-portal ``` ### 3. Native Node.js Development diff --git a/docker-compose.yml b/docker-compose.yml index 71af54f..c64f5bb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,9 +10,8 @@ services: POSTGRES_DB: balance_sheet_db POSTGRES_USER: postgres POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-postgres_secure_pass_2026} - ports: - # Use POSTGRES_HOST_PORT (default 7001) to prevent conflicts on standard DB host ports - - "${POSTGRES_HOST_PORT:-7001}:5432" + expose: + - "5432" volumes: - postgres_db_data:/var/lib/postgresql/data healthcheck: @@ -32,9 +31,8 @@ services: depends_on: postgres: condition: service_healthy - ports: - # Use HOST_PORT (default 7000) to prevent conflicts with other web applications - - "${HOST_PORT:-7000}:3000" + expose: + - "3000" environment: - NODE_ENV=production - PORT=3000 diff --git a/src/App.tsx b/src/App.tsx index 79bbc5b..added0b 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -19,7 +19,7 @@ export default function App() { const [activePeriod, setActivePeriod] = useState('22-May-26'); const [priorPeriod, setPriorPeriod] = useState('15-May-26'); const [periodsList, setPeriodsList] = useState(['22-May-26', '15-May-26', '08-May-26', '01-May-26']); - const [themeMode, setThemeMode] = useState('cyan'); + const [themeMode, setThemeMode] = useState('amber'); const [isAuthModalOpen, setIsAuthModalOpen] = useState(false); const [submissions, setSubmissions] = useState>({} as any); diff --git a/src/components/HolographicCanvas.tsx b/src/components/HolographicCanvas.tsx index c4925e8..6bcbb98 100644 --- a/src/components/HolographicCanvas.tsx +++ b/src/components/HolographicCanvas.tsx @@ -10,11 +10,17 @@ interface HolographicCanvasProps { } export const HolographicCanvas: React.FC = ({ - themeMode = 'cyan', + themeMode = 'amber', onThemeChange }) => { const mountRef = useRef(null); const [currentTheme, setCurrentTheme] = useState(themeMode); + + useEffect(() => { + if (themeMode) { + setCurrentTheme(themeMode); + } + }, [themeMode]); const [soundEnabled, setSoundEnabled] = useState(false); const [particleDensity, setParticleDensity] = useState<'high' | 'ultra'>('high'); const [hudVisible, setHudVisible] = useState(true);