Ports fixed v0.5
This commit is contained in:
parent
f7b7a27e53
commit
6339b8a43b
3 changed files with 29 additions and 30 deletions
47
COOLIFY.md
47
COOLIFY.md
|
|
@ -1,4 +1,4 @@
|
|||
# Coolify Deployment & "No Available Server" Troubleshooting Guide
|
||||
# Coolify Deployment & Port Allocation Fixes
|
||||
|
||||
This application consists of:
|
||||
1. **Server Side**: Node.js + Express backend (`server.ts`) serving REST APIs, managing authentication, ledger reconciliation, audit logs, FX rates, SMTP dispatching, and financial reports.
|
||||
|
|
@ -7,29 +7,31 @@ This application consists of:
|
|||
|
||||
---
|
||||
|
||||
## 🔧 Resolving "No Available Server" in Coolify
|
||||
## 🛑 Resolving "Bind for 0.0.0.0:3000 failed: port is already allocated"
|
||||
|
||||
If Coolify displays **"No available server"** or Traefik returns a **503 / 502 error**, follow these exact fixes:
|
||||
### Cause of the Error
|
||||
When deploying in Coolify or a multi-container Docker host, port `3000` on the host machine is frequently already taken by Coolify's internal service, another app, or a reverse proxy. Explicitly binding host port `3000:3000` causes Docker daemon to crash with:
|
||||
`Error response from daemon: Bind for 0.0.0.0:3000 failed: port is already allocated`
|
||||
|
||||
### 1. Fix Health Check Path & IPv4 Resolution (Included in codebase)
|
||||
- **Cause**: Alpine Linux `wget` resolves `localhost` to IPv6 (`::1`), while Node Express binds to IPv4 (`0.0.0.0`). When `wget` fails, Docker marks the container `unhealthy`, causing Coolify Traefik to drop the container.
|
||||
- **Fix**: The updated `Dockerfile` and `docker-compose.yml` use native Node.js HTTP checks against `http://127.0.0.1:3000/api/health`:
|
||||
```bash
|
||||
node -e "require('http').get('http://127.0.0.1:3000/api/health', (r) => process.exit(r.statusCode === 200 ? 0 : 1))"
|
||||
```
|
||||
- **Coolify UI Setting**: Under your resource in Coolify -> **Health Check**:
|
||||
- **Path**: `/api/health`
|
||||
- **Port**: `3000`
|
||||
### How It Is Fixed in This Repository
|
||||
In `docker-compose.yml`, direct host port binding (`ports: - "3000:3000"`) has been replaced with container exposure (`expose: - "3000"`).
|
||||
|
||||
### 2. Configure Exposed Port in Coolify UI
|
||||
- **In Coolify Dashboard**:
|
||||
- Open your deployed application/stack.
|
||||
- Go to **Settings** -> **Exposed Port** (or **Port**).
|
||||
- Ensure the port is set to `3000`.
|
||||
Coolify's Traefik reverse proxy routes external web traffic directly into the container on port `3000` via Docker's internal container network. No host port allocation is required!
|
||||
|
||||
---
|
||||
|
||||
## 🚀 Deployment Methods in Coolify
|
||||
## 🔧 Coolify UI Configuration Steps
|
||||
|
||||
1. **Set Container / Destination Port**:
|
||||
- In Coolify UI under **Settings** -> **Port** or **Destination Port**: Set to `3000`.
|
||||
2. **Set Health Check**:
|
||||
- **Path**: `/api/health`
|
||||
- **Port**: `3000`
|
||||
- **Type**: HTTP or Docker native check
|
||||
|
||||
---
|
||||
|
||||
## 🚀 Quick Deployment Options in Coolify
|
||||
|
||||
### Option A: Docker Compose Deployment (App + Dedicated PostgreSQL)
|
||||
|
||||
|
|
@ -51,16 +53,15 @@ If Coolify displays **"No available server"** or Traefik returns a **503 / 502 e
|
|||
SMTP_FROM="Balance Sheet Portal <noreply@networkbank.com>"
|
||||
SMTP_USE_TLS=true
|
||||
```
|
||||
3. **Health Check Endpoint**: Set path to `/api/health` on port `3000`.
|
||||
4. **Deploy**: Coolify builds the app and provisions `postgres:16-alpine`.
|
||||
3. **Deploy**: Coolify builds the app container (exposing port `3000`) and provisions `postgres:16-alpine`.
|
||||
|
||||
---
|
||||
|
||||
### Option B: Standalone Application Container (Using Coolify Managed PostgreSQL)
|
||||
### Option B: Standalone Application Container (Coolify Managed PostgreSQL)
|
||||
|
||||
1. **Create PostgreSQL Resource**:
|
||||
- Click **+ Add Resource** -> **PostgreSQL**.
|
||||
- Note the database internal connection string (e.g. `postgresql://postgres:pass@postgres-host:5432/balance_sheet_db`).
|
||||
- Note internal connection string (e.g. `postgresql://postgres:pass@postgres-host:5432/balance_sheet_db`).
|
||||
2. **Create Dockerfile Application**:
|
||||
- Add Git Repository as a **Dockerfile Application**.
|
||||
- Set Environment Variables:
|
||||
|
|
@ -69,6 +70,6 @@ If Coolify displays **"No available server"** or Traefik returns a **503 / 502 e
|
|||
PORT=3000
|
||||
DATABASE_URL=postgresql://postgres:pass@postgres-host:5432/balance_sheet_db
|
||||
```
|
||||
- In Settings -> **Exposed Port**: Set to `3000`.
|
||||
- In Settings -> **Exposed Port / Container Port**: Set to `3000`.
|
||||
- In Health Check: Set path to `/api/health`.
|
||||
3. **Deploy**: Express connects directly to PostgreSQL and initializes required tables automatically.
|
||||
|
|
|
|||
10
README.md
10
README.md
|
|
@ -18,10 +18,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, exposing port 3000 with IPv4 health check). |
|
||||
| `docker-compose.yml` | Full-stack orchestration (App container on port 3000 + PostgreSQL container on port 5432). |
|
||||
| `docker-compose.yml` | Full-stack orchestration using `expose: "3000"` (eliminates `Bind for 0.0.0.0:3000 failed` host port conflicts). |
|
||||
| `.dockerignore` | Context exclusions for slim Docker image builds. |
|
||||
| `.env.example` | Template environment variables (`DATABASE_URL`, `PORT`, `DATA_PATH`, `SMTP_*`). |
|
||||
| `COOLIFY.md` | Deployment & "No Available Server" troubleshooting guide for Coolify platform & Traefik proxies. |
|
||||
| `COOLIFY.md` | Deployment & port binding troubleshooting guide for Coolify platform & Traefik proxies. |
|
||||
| `server.ts` | Express server entry point with PostgreSQL initialization, environment SMTP dispatching, and REST API routes. |
|
||||
|
||||
---
|
||||
|
|
@ -32,16 +32,16 @@ A full-stack enterprise web application built for multi-branch balance sheet con
|
|||
```bash
|
||||
docker-compose up --build -d
|
||||
```
|
||||
The application container exposes port `3000` (`http://localhost:3000`), with an automated health check on `/api/health`.
|
||||
The application container exposes port `3000` via Docker's internal network (`expose: "3000"`), avoiding host interface port allocation collisions.
|
||||
|
||||
### 2. Run via Docker CLI
|
||||
```bash
|
||||
docker build -t balance-sheet-portal .
|
||||
docker run -p 3000:3000 -v portal_data:/app/data balance-sheet-portal
|
||||
docker run -p 7000:3000 -v portal_data:/app/data balance-sheet-portal
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## ☁️ Deployment on Coolify
|
||||
|
||||
Refer to [`COOLIFY.md`](./COOLIFY.md) for step-by-step instructions on deploying via Docker Compose or Coolify Managed PostgreSQL, and resolving Traefik "No available server" status.
|
||||
Refer to [`COOLIFY.md`](./COOLIFY.md) for step-by-step instructions on deploying via Docker Compose or Coolify Managed PostgreSQL, and resolving Traefik port allocation issues.
|
||||
|
|
|
|||
|
|
@ -31,8 +31,6 @@ services:
|
|||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
ports:
|
||||
- "3000:3000"
|
||||
expose:
|
||||
- "3000"
|
||||
labels:
|
||||
|
|
|
|||
Loading…
Reference in a new issue