Ports fixed v0.3
This commit is contained in:
parent
726e15cffa
commit
9199703386
6 changed files with 21 additions and 29 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
18
README.md
18
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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ export default function App() {
|
|||
const [activePeriod, setActivePeriod] = useState<string>('22-May-26');
|
||||
const [priorPeriod, setPriorPeriod] = useState<string>('15-May-26');
|
||||
const [periodsList, setPeriodsList] = useState<string[]>(['22-May-26', '15-May-26', '08-May-26', '01-May-26']);
|
||||
const [themeMode, setThemeMode] = useState<HolographicThemeMode>('cyan');
|
||||
const [themeMode, setThemeMode] = useState<HolographicThemeMode>('amber');
|
||||
const [isAuthModalOpen, setIsAuthModalOpen] = useState<boolean>(false);
|
||||
|
||||
const [submissions, setSubmissions] = useState<Record<BranchId, BranchSubmission>>({} as any);
|
||||
|
|
|
|||
|
|
@ -10,11 +10,17 @@ interface HolographicCanvasProps {
|
|||
}
|
||||
|
||||
export const HolographicCanvas: React.FC<HolographicCanvasProps> = ({
|
||||
themeMode = 'cyan',
|
||||
themeMode = 'amber',
|
||||
onThemeChange
|
||||
}) => {
|
||||
const mountRef = useRef<HTMLDivElement>(null);
|
||||
const [currentTheme, setCurrentTheme] = useState<HolographicThemeMode>(themeMode);
|
||||
|
||||
useEffect(() => {
|
||||
if (themeMode) {
|
||||
setCurrentTheme(themeMode);
|
||||
}
|
||||
}, [themeMode]);
|
||||
const [soundEnabled, setSoundEnabled] = useState(false);
|
||||
const [particleDensity, setParticleDensity] = useState<'high' | 'ultra'>('high');
|
||||
const [hudVisible, setHudVisible] = useState(true);
|
||||
|
|
|
|||
Loading…
Reference in a new issue