- Changed health check endpoint from `/api/health` to `/_health` in Dockerfile and docker-compose.yml for consistency. - Removed the now obsolete health check route file from the API. - Updated TypeScript configuration to exclude the `.next` directory, improving build performance and clarity. - Enhanced documentation in proxy.ts to reflect the updated health check endpoint.
128 lines
2.5 KiB
Markdown
128 lines
2.5 KiB
Markdown
# Customer Portal - Portainer Deployment
|
|
|
|
## Quick Setup
|
|
|
|
### 1. Load Docker Images
|
|
|
|
Upload your images to the server and load them:
|
|
|
|
```bash
|
|
docker load < portal-frontend-latest.tar
|
|
docker load < portal-backend-latest.tar
|
|
```
|
|
|
|
Verify they're loaded:
|
|
|
|
```bash
|
|
docker images | grep portal
|
|
```
|
|
|
|
### 2. Create Stack in Portainer
|
|
|
|
1. Go to Portainer → Stacks → Add Stack
|
|
2. Name: `customer-portal`
|
|
3. Paste contents of `docker-compose.yml`
|
|
4. Scroll down to **Environment Variables**
|
|
5. Copy variables from `env.example` and fill in your production values
|
|
|
|
### 3. Generate Secrets
|
|
|
|
Generate secure random values for:
|
|
|
|
```bash
|
|
# JWT Secret
|
|
openssl rand -base64 32
|
|
|
|
# CSRF Secret
|
|
openssl rand -base64 32
|
|
|
|
# PostgreSQL Password
|
|
openssl rand -base64 24 | tr -d '/+=' | cut -c1-32
|
|
```
|
|
|
|
Encode your Salesforce private key:
|
|
|
|
```bash
|
|
base64 -w 0 < sf-private.key
|
|
```
|
|
|
|
### 4. Deploy
|
|
|
|
Click **Deploy the stack** in Portainer.
|
|
|
|
---
|
|
|
|
## How It Works
|
|
|
|
This setup uses `network_mode: bridge` with Docker `links` to avoid the iptables/IPv6 issues that can occur on some servers.
|
|
|
|
### Key Points
|
|
|
|
- **No custom networks** - Uses Docker's default bridge network
|
|
- **Service discovery via links** - Services reference each other by container name
|
|
- **Localhost binding** - Ports are bound to `127.0.0.1` for security (use Nginx/Plesk to proxy)
|
|
- **All config via Portainer** - No external env files needed
|
|
|
|
### Service URLs (internal)
|
|
|
|
| Service | Internal URL |
|
|
| -------- | -------------------------- |
|
|
| Backend | http://backend:4000 |
|
|
| Database | postgresql://database:5432 |
|
|
| Redis | redis://cache:6379 |
|
|
|
|
### Nginx/Plesk Proxy
|
|
|
|
Configure your domain to proxy to:
|
|
|
|
- Frontend: `http://127.0.0.1:3000`
|
|
- Backend API: `http://127.0.0.1:4000`
|
|
|
|
---
|
|
|
|
## Updating the Stack
|
|
|
|
1. Load new images:
|
|
|
|
```bash
|
|
docker load < portal-frontend-latest.tar
|
|
docker load < portal-backend-latest.tar
|
|
```
|
|
|
|
2. In Portainer: Stacks → customer-portal → **Update the stack**
|
|
|
|
3. Check **Re-pull image** and click **Update**
|
|
|
|
---
|
|
|
|
## Troubleshooting
|
|
|
|
### View Logs
|
|
|
|
```bash
|
|
docker logs portal-frontend
|
|
docker logs portal-backend
|
|
docker logs portal-database
|
|
docker logs portal-cache
|
|
```
|
|
|
|
### Check Container Health
|
|
|
|
```bash
|
|
docker ps
|
|
```
|
|
|
|
### Access Database
|
|
|
|
```bash
|
|
docker exec -it portal-database psql -U portal -d portal_prod
|
|
```
|
|
|
|
### Test Service Connectivity
|
|
|
|
```bash
|
|
# From backend container
|
|
docker exec -it portal-backend sh -c "nc -zv database 5432"
|
|
docker exec -it portal-backend sh -c "nc -zv cache 6379"
|
|
```
|